> ## Documentation Index
> Fetch the complete documentation index at: https://docs.refuseless.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a chat completion

> OpenAI-compatible chat completions. Set stream=true for Server-Sent Events (data: {...} frames ending in data: [DONE]). prompt_tokens on the request is ignored — the server re-estimates, including tool definitions in the reservation.



## OpenAPI

````yaml /openapi.json post /v1/chat/completions
openapi: 3.1.0
info:
  title: Refuseless API
  version: 1.0.0
  description: >-
    OpenAI-compatible hosted inference for a named lineup of refusal-removed
    open weights.
servers:
  - url: https://api.refuseless.com
security:
  - bearerAuth: []
paths:
  /v1/chat/completions:
    post:
      tags:
        - Completions
      summary: Create a chat completion
      description: >-
        OpenAI-compatible chat completions. Set stream=true for Server-Sent
        Events (data: {...} frames ending in data: [DONE]). prompt_tokens on the
        request is ignored — the server re-estimates, including tool definitions
        in the reservation.
      operationId: createChatCompletion
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ChatCompletionRequest'
            example:
              model: glm-5.3-abliterated
              messages:
                - role: user
                  content: Write a tight system prompt.
      responses:
        '200':
          description: Chat completion (object) or event stream when stream=true
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ChatCompletionResponse'
              example:
                id: chatcmpl-abc123
                object: chat.completion
                created: 1700000000
                model: glm-5.3-abliterated
                choices:
                  - index: 0
                    message:
                      role: assistant
                      content: …
                    finish_reason: stop
                usage:
                  prompt_tokens: 12
                  completion_tokens: 64
                  total_tokens: 76
        '400':
          description: Missing model or non-JSON body
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
        '401':
          description: Missing or invalid API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
        '402':
          description: Insufficient credits
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
        '404':
          description: Unknown model
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
        '429':
          description: Model busy or warming — honor retry-after
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
        '502':
          description: Inference backend error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
        '503':
          description: Gateway or model unavailable
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
components:
  schemas:
    ChatCompletionRequest:
      type: object
      required:
        - model
        - messages
      properties:
        model:
          type: string
          examples:
            - glm-5.3-abliterated
        messages:
          type: array
          items:
            $ref: '#/components/schemas/ChatMessage'
        max_tokens:
          type: integer
          description: >-
            When omitted: the model's max output, else its context window minus
            the prompt. Clamped to the credit reservation.
        max_completion_tokens:
          type: integer
          description: Alias of max_tokens.
        stream:
          type: boolean
          default: false
        tools:
          type: array
          description: >-
            OpenAI function-calling tools. Counted toward the input-token
            reservation.
          items:
            type: object
            additionalProperties: true
        tool_choice:
          description: Passed through to the model.
          additionalProperties: true
        response_format:
          type: object
          description: Passed through to the model.
          additionalProperties: true
        stream_options:
          type: object
          description: 'e.g. {"include_usage": true}.'
          additionalProperties: true
        reasoning_effort:
          type: string
          enum:
            - 'off'
            - low
            - high
            - max
          description: >-
            Model-card reasoning effort. effort is an alias. Other levels are
            rejected. off disables reasoning. Omitted requests on a model marked
            thinking-off run with reasoning off. Other models default to low.
      additionalProperties: true
    ChatCompletionResponse:
      type: object
      required:
        - id
        - object
        - created
        - model
        - choices
        - usage
      properties:
        id:
          type: string
        object:
          type: string
          examples:
            - chat.completion
        created:
          type: integer
        model:
          type: string
          description: Always echoes your public model id.
        choices:
          type: array
          items:
            type: object
            properties:
              index:
                type: integer
              message:
                type: object
                properties:
                  role:
                    type: string
                  content:
                    type:
                      - string
                      - 'null'
                    description: Null when the turn is tool-calls only.
                  tool_calls:
                    type: array
                    items:
                      $ref: '#/components/schemas/ToolCall'
                  reasoning_content:
                    type: string
              finish_reason:
                type: string
                enum:
                  - stop
                  - tool_calls
                  - length
                  - null
        usage:
          type: object
          properties:
            prompt_tokens:
              type: integer
            completion_tokens:
              type: integer
            total_tokens:
              type: integer
            prompt_tokens_details:
              type: object
              properties:
                cached_tokens:
                  type: integer
    ApiError:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          required:
            - code
            - message
            - type
          properties:
            code:
              type: string
              examples:
                - invalid_key
                - insufficient_credits
                - model_not_found
                - model_busy
                - model_warming
                - upstream_error
                - model_unavailable
            message:
              type: string
            type:
              type: string
              examples:
                - api_error
    ChatMessage:
      type: object
      required:
        - role
        - content
      properties:
        role:
          type: string
          enum:
            - system
            - user
            - assistant
            - tool
        content:
          type:
            - string
            - 'null'
        tool_calls:
          type: array
          items:
            $ref: '#/components/schemas/ToolCall'
        reasoning_content:
          type: string
          description: Chain of thought on reasoning models.
    ToolCall:
      type: object
      properties:
        id:
          type: string
        type:
          type: string
          examples:
            - function
        function:
          type: object
          properties:
            name:
              type: string
            arguments:
              type: string
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      x-default: YOUR_API_KEY

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.