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

# Create a chat completion

> Generate a reply from the specified model and messages. By default, the API returns a complete response. SSE streaming is also supported.

Before making a request, confirm that the model supports this protocol and the parameters you need.



## OpenAPI

````yaml /model-inference/api/model-inference-api.json post /chat/completions
openapi: 3.1.0
info:
  title: ScitiX Model Inference API
  version: 1.0.0
  description: >-
    List models and generate output using the Chat Completions, Messages, or
    Responses protocol.


    Authenticate with `Authorization: Bearer <API_KEY>`. Supported protocols,
    parameters, and response fields vary by model. Check the model documentation
    before making a request.
servers:
  - url: https://api.scitix.ai/model-api
    description: >-
      Base URL for the ScitiX Model Inference API. This reference uses the URL
      without `/v1` and appends each endpoint path.
security:
  - BearerAuth: []
tags:
  - name: Models
    description: List models and their attributes.
  - name: Chat Completions
    description: Generate chat replies using the Chat Completions protocol.
  - name: Messages
    description: Generate messages using the Anthropic Messages protocol.
  - name: Responses
    description: Generate model responses using the Responses protocol.
paths:
  /chat/completions:
    post:
      tags:
        - Chat Completions
      summary: Create a chat completion
      description: >-
        Generate a reply from the specified model and messages. By default, the
        API returns a complete response. SSE streaming is also supported.


        Before making a request, confirm that the model supports this protocol
        and the parameters you need.
      operationId: createChatCompletion
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ChatCompletionRequest'
            examples:
              Basic request:
                summary: Basic request
                value:
                  model: deepseek-ai/deepseek-v4.1-flash-1017
                  messages:
                    - role: user
                      content: Reply with only the result of 1+1.
                  max_completion_tokens: 128
              Tool call:
                summary: Tool call
                value:
                  model: deepseek-ai/deepseek-v4.1-flash-1017
                  messages:
                    - role: user
                      content: >-
                        Call add to calculate 7 plus 5. Reply with only the
                        result.
                  tools:
                    - type: function
                      function:
                        name: add
                        description: Calculate the sum of two integers
                        parameters:
                          type: object
                          properties:
                            a:
                              type: integer
                            b:
                              type: integer
                          required:
                            - a
                            - b
                  tool_choice: required
                  max_completion_tokens: 256
              Return a tool result:
                summary: Return a tool result
                value:
                  model: deepseek-ai/deepseek-v4.1-flash-1017
                  messages:
                    - role: user
                      content: >-
                        Call add to calculate 7 plus 5. Reply with only the
                        result.
                    - role: assistant
                      content: ''
                      refusal: null
                      reasoning_content: >-
                        The user wants me to call add with 7 and 5, and only
                        answer the result.


                        Simple arithmetic: 7+5=12, but they asked to call the
                        tool. Let me call it.
                      tool_calls:
                        - id: call_00_5l1fpp7c2b2jbqhbg7y6n6gj
                          type: function
                          function:
                            name: add
                            arguments: '{"a": 7, "b": 5}'
                    - role: tool
                      tool_call_id: call_00_5l1fpp7c2b2jbqhbg7y6n6gj
                      content: '{"result": 12}'
                  tools:
                    - type: function
                      function:
                        name: add
                        description: Calculate the sum of two integers
                        parameters:
                          type: object
                          properties:
                            a:
                              type: integer
                            b:
                              type: integer
                          required:
                            - a
                            - b
                  tool_choice: auto
                  max_completion_tokens: 256
              Structured output:
                summary: Structured output
                value:
                  model: deepseek-ai/deepseek-v4.1-flash-1017
                  messages:
                    - role: user
                      content: Return a JSON object with the answer field set to YES.
                  response_format:
                    type: json_schema
                    json_schema:
                      name: check_result
                      strict: true
                      schema:
                        type: object
                        properties:
                          answer:
                            type: string
                            enum:
                              - 'YES'
                        required:
                          - answer
                        additionalProperties: false
                  max_completion_tokens: 256
              Streaming request:
                summary: Streaming request
                value:
                  model: deepseek-ai/deepseek-v4.1-flash-1017
                  messages:
                    - role: user
                      content: Reply with only 2
                  stream: true
                  max_completion_tokens: 128
              Log probabilities:
                summary: Log probabilities
                value:
                  model: deepseek-ai/deepseek-v4.1-flash-1017
                  messages:
                    - role: user
                      content: Reply with only 2
                  logprobs: true
                  top_logprobs: 2
                  max_completion_tokens: 128
              Disable tool calls:
                summary: Disable tool calls
                value:
                  model: deepseek-ai/deepseek-v4.1-flash-1017
                  messages:
                    - role: user
                      content: >-
                        Call add to calculate 7 plus 5. Reply with only the
                        result.
                  tools:
                    - type: function
                      function:
                        name: add
                        description: Calculate the sum of two integers
                        parameters:
                          type: object
                          properties:
                            a:
                              type: integer
                            b:
                              type: integer
                          required:
                            - a
                            - b
                  tool_choice: none
                  max_completion_tokens: 256
              Specify a function:
                summary: Specify a function
                value:
                  model: deepseek-ai/deepseek-v4.1-flash-1017
                  messages:
                    - role: user
                      content: >-
                        Call add to calculate 7 plus 5. Reply with only the
                        result.
                  tools:
                    - type: function
                      function:
                        name: add
                        description: Calculate the sum of two integers
                        parameters:
                          type: object
                          properties:
                            a:
                              type: integer
                            b:
                              type: integer
                          required:
                            - a
                            - b
                  tool_choice:
                    type: function
                    function:
                      name: add
                  max_completion_tokens: 256
              Omit log probabilities:
                summary: Omit log probabilities
                value:
                  model: deepseek-ai/deepseek-v4.1-flash-1017
                  messages:
                    - role: user
                      content: Reply with only 2
                  logprobs: false
                  max_completion_tokens: 128
              Non-streaming request (Qwen):
                summary: Non-streaming chat request
                value:
                  model: Qwen/Qwen3.6-27B
                  messages:
                    - role: user
                      content: Explain machine learning in one sentence.
                  max_completion_tokens: 1024
              Tool call (Qwen):
                summary: Provide function definitions for the model to choose from
                value:
                  model: Qwen/Qwen3.6-27B
                  messages:
                    - role: user
                      content: Check the weather in Beijing.
                  tools:
                    - type: function
                      function:
                        name: get_weather
                        description: Check the weather in the specified city.
                        parameters:
                          type: object
                          properties:
                            city:
                              type: string
                              description: City name, such as Beijing.
                          required:
                            - city
                  tool_choice: auto
                  max_completion_tokens: 1024
              Streaming request with usage (Qwen):
                summary: Enable streaming and request usage information
                value:
                  model: Qwen/Qwen3.6-27B
                  messages:
                    - role: user
                      content: Count to five
                  max_completion_tokens: 1024
                  stream: true
                  stream_options:
                    include_usage: true
      responses:
        '200':
          description: >-
            Request successful. Non-streaming responses return JSON. Streaming
            responses return `text/event-stream`, with each data chunk prefixed
            by `data:`. The `data: [DONE]` marker ends the stream. The examples
            below illustrate the format; content, usage, and optional fields
            depend on the actual response.
          headers:
            x-request-id:
              description: Request ID.
              schema:
                type: string
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ChatCompletionResponse'
              examples:
                Chat response:
                  summary: Chat response
                  value:
                    id: chatcmpl-191f63cf2de94c4c80f62e41d5824241
                    object: chat.completion
                    created: 1794334629
                    model: deepseek-ai/deepseek-v4.1-flash-1017
                    choices:
                      - index: 0
                        message:
                          role: assistant
                          content: '2'
                        finish_reason: stop
                    usage:
                      prompt_tokens: 40
                      completion_tokens: 26
                      total_tokens: 66
                Tool-call response:
                  summary: Tool-call response
                  value:
                    id: 02179433464137146c89d7a9df4832d26639df9e3c5ba5676abb4
                    object: chat.completion
                    created: 1794334642
                    model: deepseek-ai/deepseek-v4.1-flash-1017
                    choices:
                      - index: 0
                        message:
                          role: assistant
                          content: ''
                          tool_calls:
                            - id: call_00_5l1fpp7c2b2jbqhbg7y6n6gj
                              type: function
                              function:
                                name: add
                                arguments: '{"a": 7, "b": 5}'
                        finish_reason: tool_calls
                    usage:
                      prompt_tokens: 313
                      completion_tokens: 95
                      total_tokens: 408
                Log probabilities:
                  summary: Log-probability response
                  value:
                    id: b03f5de3-36d7-48ef-91a1-50a462b2682e
                    object: chat.completion
                    created: 1794334631
                    model: deepseek-ai/deepseek-v4.1-flash-1017
                    choices:
                      - index: 0
                        message:
                          role: assistant
                          content: '2'
                        finish_reason: stop
                        logprobs:
                          content:
                            - token: '2'
                              logprob: -1.1920928e-7
                              bytes: Mg==
                              top_logprobs:
                                - token: '2'
                                  logprob: -1.1920928e-7
                                  bytes: Mg==
                                - token: '1'
                                  logprob: -16.571737
                                  bytes: MQ==
                    usage:
                      prompt_tokens: 34
                      completion_tokens: 40
                      total_tokens: 74
                Response with usage details (Qwen):
                  summary: A response that includes usage details
                  value:
                    id: chatcmpl-EY5GkaXIdJVtcGLrMPkZGt5ZV4d6u
                    object: chat.completion
                    created: 1791792114
                    model: Qwen/Qwen3.6-27B
                    choices:
                      - index: 0
                        message:
                          role: assistant
                          content: >-
                            Machine learning enables computers to learn patterns
                            from data and use them to perform tasks.
                          refusal: null
                        finish_reason: stop
                        logprobs: null
                    usage:
                      prompt_tokens: 18
                      completion_tokens: 24
                      total_tokens: 42
                    system_fingerprint: ''
                    service_tier: default
            text/event-stream:
              schema:
                type: string
              x-event-data-schema:
                $ref: '#/components/schemas/ChatCompletionChunk'
              examples:
                Complete streaming response:
                  summary: Complete streaming response
                  value: >+
                    data: {"id": "d5fec500-aab3-47cd-8fa1-ffe1bd3f568b",
                    "object": "chat.completion.chunk", "created": 1794334633,
                    "choices": [{"index": 0, "delta": {"role": "assistant"},
                    "finish_reason": null}]}


                    data: {"id": "d5fec500-aab3-47cd-8fa1-ffe1bd3f568b",
                    "object": "chat.completion.chunk", "created": 1794334633,
                    "choices": [{"index": 0, "delta": {"content": "2"},
                    "finish_reason": null}]}


                    data: {"id": "d5fec500-aab3-47cd-8fa1-ffe1bd3f568b",
                    "object": "chat.completion.chunk", "created": 1794334633,
                    "usage": {"prompt_tokens": 34, "completion_tokens": 12,
                    "total_tokens": 46}, "choices": [{"index": 0, "delta": {},
                    "finish_reason": "stop"}]}


                    data: [DONE]

                Text delta chunk:
                  summary: Example text delta chunk
                  value: >+
                    data:
                    {"id":"766e602a420758bb40c94f49f9489abd","object":"chat.completion.chunk","created":1793927535,"model":"Qwen/Qwen3.6-27B","choices":[{"index":0,"delta":{"content":"One"},"finish_reason":null}],"system_fingerprint":""}

                Usage chunk:
                  summary: Example usage chunk (choices may be empty)
                  value: >+
                    data:
                    {"id":"766e602a420758bb40c94f49f9489abd","object":"chat.completion.chunk","created":1793927535,"model":"Qwen/Qwen3.6-27B","choices":[],"usage":{"prompt_tokens":9,"completion_tokens":25,"total_tokens":34,"completion_tokens_details":{"reasoning_tokens":7}}}

        '400':
          description: >-
            Invalid request, such as an incompatible protocol, an unsupported
            parameter, or input that exceeds model limits. Check the request
            against the error message.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples: {}
        '401':
          description: API key is missing or invalid.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                Invalid key:
                  value:
                    error:
                      msg: authorization api key not valid
                      code: unauthorized
                      message: >-
                        authorization api key not valid (request_id:
                        b2d990af-7f19-4e30-ad18-0755a284a024)
                      type: authentication_error
                      traceId: 899ca9e03c95a8ab0fd75832259d9bb9
                      request_id: b2d990af-7f19-4e30-ad18-0755a284a024
                  summary: Invalid key
                Key not found:
                  value:
                    error:
                      message: api key not exists
                      type: authentication_error
                  summary: Key not found
        '404':
          description: >-
            Model not found or not accessible to the current account. Check the
            model ID and access permissions.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '409':
          description: >-
            Request conflict. Check the request state and relevant limits
            against the error message.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          description: >-
            Rate limit exceeded, such as an RPM or TPM limit. An exhausted API
            key spending quota returns 402, not this error. If the response
            includes `Retry-After` or `error.retry_after_sec`, use the suggested
            wait time for backoff. A request may still be rate-limited after
            waiting.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  message: Rate limit exceeded, please retry later.
                  type: rate_limit_error
                  code: rate_limit_exceeded
        '500':
          description: >-
            Internal service error. Retry with backoff. If failures persist,
            retain the request identifiers and contact support.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '502':
          description: >-
            Gateway or upstream service error. Retry with backoff. If failures
            persist, retain the request identifiers and contact support.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        default:
          description: >-
            Other error response. Use the HTTP status, error message, and
            request ID to investigate.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    ChatCompletionRequest:
      type: object
      description: >-
        Chat generation request body. `model` and `messages` are required.
        Configure other parameters for your task and the capabilities of the
        selected model.
      required:
        - model
        - messages
      properties:
        model:
          type: string
          description: >-
            ID of the model to generate the reply. Use `GET /models` to list
            models, then check the model details to confirm Chat Completions
            support.
          example: Qwen/Qwen3.6-27B
        messages:
          type: array
          minItems: 1
          items:
            $ref: '#/components/schemas/ChatMessage'
          description: >-
            Messages in conversation order, with at least one message. For
            multi-turn conversations, include the history you want to retain.
        max_completion_tokens:
          type: integer
          minimum: 1
          description: >-
            Total token budget for this generation, including reasoning tokens
            and visible output tokens. Must be at least `1`; the model
            determines the maximum.


            A small budget can result in empty or truncated output, especially
            with reasoning models. Use `finish_reason` and `usage` to adjust the
            budget.


            This is the recommended parameter. Existing requests can continue to
            use `max_tokens` for compatibility. If both are provided, this
            parameter takes precedence.
          example: 1024
        temperature:
          type: number
          minimum: 0
          maximum: 2
          default: 1
          description: >-
            Sampling temperature, which adjusts output randomness. Lower values
            generally produce more focused output; higher values generally
            produce more varied output. `0` does not guarantee identical output,
            and some models support only the default value.
        top_p:
          type: number
          exclusiveMinimum: 0
          maximum: 1
          default: 1
          description: >-
            Nucleus sampling threshold. Samples from candidate tokens whose
            cumulative probability reaches this value. Lower values generally
            narrow the candidate set. Adjust either this parameter or
            `temperature`, not both.
        seed:
          type: integer
          description: >-
            Sampling seed, which can improve reproducibility across repeated
            requests. Identical parameters do not guarantee identical output.
            Support varies by model.
        'n':
          type: integer
          minimum: 1
          default: 1
          description: >-
            Number of candidate replies to generate for this request. Support
            and maximum count vary by model.
        stream:
          type: boolean
          default: false
          description: >-
            Whether to stream output. When `true`, receive incremental content
            through SSE. When `false`, receive a complete JSON response.
        stream_options:
          type: object
          description: Streaming options. Use only when `stream=true`.
          properties:
            include_usage:
              type: boolean
              default: false
              description: >-
                Whether to request usage in the stream. When `true`, models that
                support this option may send a usage chunk with empty `choices`
                near the end of the stream. If the stream is interrupted or that
                chunk is not returned, the received chunks alone do not
                establish final usage.
          additionalProperties: true
        stop:
          oneOf:
            - type: string
            - type: array
              items:
                type: string
              maxItems: 4
          description: >-
            Stop sequence, either one string or an array of up to four strings.
            When supported, the model stops generating after encountering a stop
            sequence. Support varies by model. Use `max_completion_tokens` to
            limit generation length.
        tools:
          type: array
          description: >-
            Tools available for the model to call. Only function tools
            (`type=function`) are currently supported. Tool definitions count as
            input tokens. The client executes tools after the model returns call
            information.
          items:
            type: object
            required:
              - type
              - function
            properties:
              type:
                type: string
                enum:
                  - function
                description: Tool type. Currently only `function` is supported.
              function:
                type: object
                required:
                  - name
                properties:
                  name:
                    type: string
                    description: >-
                      Function name, used to match the tool call returned by the
                      model.
                  description:
                    type: string
                    description: >-
                      Function description, used by the model to decide when to
                      call it.
                  parameters:
                    type: object
                    additionalProperties: true
                    description: JSON Schema describing the function input parameters.
                  strict:
                    type: boolean
                    description: >-
                      Whether to request strict adherence to the function
                      parameter JSON Schema. Support varies by model; the client
                      must still validate the arguments.
                additionalProperties: true
                description: >-
                  Function definition, including its name, purpose, and
                  parameter structure.
            additionalProperties: true
        tool_choice:
          oneOf:
            - type: string
              enum:
                - none
                - auto
                - required
            - type: object
              required:
                - type
                - function
              properties:
                type:
                  const: function
                function:
                  type: object
                  required:
                    - name
                  properties:
                    name:
                      type: string
                  additionalProperties: true
              additionalProperties: true
          default: auto
          description: >-
            Controls tool selection.


            - `none`: Generate a reply without calling tools.

            - `auto`: Let the model choose whether to reply or call tools.

            - `required`: Require a tool call.

            - A function object: Require a specific function, such as
            `{"type":"function","function":{"name":"get_weather"}}`.


            Provide the corresponding function definitions in `tools` when using
            tool calls.
        parallel_tool_calls:
          type: boolean
          default: true
          description: >-
            Whether the model may request multiple tool calls in one reply.
            Applies only when tools are used and the model supports parallel
            calls. Does not control how the client executes tools.
        response_format:
          type: object
          description: >-
            Output format: plain text, a JSON object, or structured content
            conforming to a JSON Schema. Support varies by model. For JSON
            output, also specify the output requirements in the messages and
            validate the result on the client.
          required:
            - type
          properties:
            type:
              type: string
              enum:
                - text
                - json_object
                - json_schema
              default: text
              description: >-
                Output format: `text` for plain text, `json_object` for a JSON
                object, or `json_schema` for JSON generated according to the
                specified schema.
            json_schema:
              type: object
              description: >-
                JSON Schema configuration. Provide this field when
                `type=json_schema`.
              additionalProperties: true
              properties:
                name:
                  type: string
                  description: Schema name for structured output.
                strict:
                  type: boolean
                  enum:
                    - true
                  description: >-
                    Set to `true` to request strict adherence to the specified
                    JSON Schema. Support varies by model. A successful request
                    does not guarantee that schema constraints were enforced.
                    Validate the response on the client.
                schema:
                  type: object
                  description: >-
                    JSON Schema defining the output object structure and field
                    constraints.
                  additionalProperties: true
              required:
                - name
                - schema
          additionalProperties: true
          allOf:
            - if:
                required:
                  - type
                properties:
                  type:
                    const: json_schema
              then:
                required:
                  - json_schema
        reasoning_effort:
          type: string
          enum:
            - minimal
            - low
            - medium
            - high
          description: >-
            Requested reasoning effort. Support and defaults vary by model.
            Acceptance of this parameter alone does not establish that it took
            effect.
        user:
          type: string
          description: >-
            End-user identifier for usage attribution. Do not include sensitive
            personal information.
        service_tier:
          type: string
          enum:
            - auto
            - default
            - flex
            - priority
          default: auto
          description: >-
            Service-tier compatibility field. Do not rely on this parameter to
            obtain different response speeds or prices.
        store:
          type: boolean
          default: false
          description: >-
            Response-storage compatibility field. This API does not provide
            retrieval of historical responses by response ID. Do not use this
            parameter as a persistence mechanism.
        metadata:
          type: object
          description: >-
            Metadata compatibility field, provided as string key-value pairs. Do
            not rely on this field being echoed back or available for later
            retrieval.
          additionalProperties:
            type: string
        presence_penalty:
          type: number
          minimum: -2
          maximum: 2
          default: 0
          description: >-
            Presence penalty, which adjusts the likelihood of generating tokens
            that have already appeared. Positive values generally discourage
            recurrence; negative values generally encourage it. Whether it takes
            effect varies by model.
        frequency_penalty:
          type: number
          minimum: -2
          maximum: 2
          default: 0
          description: >-
            Frequency penalty, which adjusts how often previously generated
            tokens are repeated. Positive values generally reduce repetition;
            negative values generally increase it. Whether it takes effect
            varies by model.
        logprobs:
          type: boolean
          default: false
          description: >-
            Whether to return output token log probabilities. Supported by some
            models only; the response field may also be `null`.
          example: true
        top_logprobs:
          type: integer
          minimum: 0
          maximum: 20
          description: >-
            Number of highest-probability candidate tokens to return at each
            output position. Requires `logprobs=true` and a model that supports
            this capability.
          example: 2
        web_search_options:
          type: object
          description: >-
            Web-search options compatibility field. Providing this field does
            not establish that web search is enabled.
          additionalProperties: true
      additionalProperties: true
      allOf:
        - if:
            required:
              - top_logprobs
          then:
            required:
              - logprobs
            properties:
              logprobs:
                const: true
    ChatCompletionResponse:
      type: object
      required:
        - id
        - object
        - created
        - model
        - choices
      properties:
        id:
          type: string
          description: >-
            Identifier for this generation response. Format varies by model or
            service; do not parse it based on a fixed prefix.
        object:
          type: string
          enum:
            - chat.completion
          description: Response object type, set to `chat.completion`.
        created:
          type: integer
          description: Response creation time as a Unix timestamp in seconds.
        model:
          type: string
          description: Identifier of the model used for this generation.
        choices:
          type: array
          items:
            $ref: '#/components/schemas/ChatCompletionChoice'
          description: >-
            Candidate replies. Each entry contains a message and the reason
            generation ended.
        usage:
          $ref: '#/components/schemas/Usage'
          description: Token usage for this request, combined across candidate replies.
        system_fingerprint:
          type: string
          description: >-
            System configuration identifier returned by the service. May be an
            empty string.
        service_tier:
          type: string
          description: >-
            Tier identifier returned by the service. Does not imply additional
            performance or pricing commitments.
      additionalProperties: true
      description: Non-streaming chat completion response.
    ErrorResponse:
      type: object
      description: >-
        Errors may use top-level fields, a nested `error` object, or an object
        with `object=error`. Handle the structure actually returned and retain
        the error information and request identifiers for troubleshooting.
      anyOf:
        - type: object
          required:
            - type
            - message
          properties:
            type:
              type: string
              example: invalid_request_error
              description: >-
                Error type, which distinguishes authentication, request format,
                rate limiting, and other issues.
            code:
              type:
                - string
                - integer
                - 'null'
              description: >-
                Error code. May be a string, integer, or `null`. Use the error
                type and message to investigate; do not rely only on numeric
                codes.
            message:
              type: string
              description: >-
                Error message, which may include a request or trace identifier.
                Retain the complete message for troubleshooting.
          additionalProperties: true
        - type: object
          required:
            - error
          properties:
            error:
              type: object
              required:
                - message
              properties:
                message:
                  type: string
                  description: >-
                    Error message, which may include a request or trace
                    identifier. Retain the complete message for troubleshooting.
                type:
                  type: string
                  description: >-
                    Error type, which distinguishes authentication, request
                    format, rate limiting, and other issues.
                code:
                  type:
                    - string
                    - integer
                    - 'null'
                  description: >-
                    Error code. May be a string, integer, or `null`. Use the
                    error type and message to investigate; do not rely only on
                    numeric codes.
                msg:
                  type: string
                  description: Short error description.
                request_id:
                  type: string
                  description: >-
                    Platform-generated request ID for request correlation and
                    troubleshooting.
                traceId:
                  type: string
                  description: Trace identifier returned in the error response.
                trace_id:
                  type: string
                  description: Trace identifier returned in the error response.
              additionalProperties: true
              description: Error information object.
            type:
              type: string
              example: error
              description: Top-level type identifier in an error response.
          additionalProperties: true
        - type: object
          required:
            - object
            - message
          properties:
            object:
              type: string
              enum:
                - error
              description: Error object type, set to `error`.
            message:
              type: string
              description: >-
                Error message, which may include a request or trace identifier.
                Retain the complete message for troubleshooting.
            type:
              type: string
              example: BadRequestError
              description: >-
                Error type, which distinguishes authentication, request format,
                rate limiting, and other issues.
            code:
              type:
                - integer
                - string
                - 'null'
              description: >-
                Error code. May be a string, integer, or `null`. Use the error
                type and message to investigate; do not rely only on numeric
                codes.
          additionalProperties: true
    ChatMessage:
      type: object
      required:
        - role
        - content
      properties:
        role:
          type: string
          enum:
            - system
            - user
            - assistant
            - tool
            - developer
          description: >-
            Message role.


            - `system`: System instructions.

            - `user`: User input.

            - `assistant`: Model reply.

            - `tool`: Tool execution result, linked to the model's tool call
            through `tool_call_id`.

            - `developer`: Developer instructions. Supported by some models
            only; confirm compatibility before using this role across models.
        content:
          oneOf:
            - type: string
            - type: array
              items:
                $ref: '#/components/schemas/ChatContentPart'
              minItems: 1
          description: >-
            Message content, either plain text or an array of content blocks.
            Use a model that supports image input when including images.
        name:
          type: string
          description: Sender name, used to distinguish participants with the same role.
        reasoning_content:
          type: string
          description: >-
            Reasoning content. The example that returns a tool result includes
            this field; whether it is required and how to handle it depend on
            the model.
        tool_calls:
          type: array
          items:
            type: object
            required:
              - id
              - type
              - function
            properties:
              id:
                type: string
                description: >-
                  Tool-call ID. Use this value as `tool_call_id` when returning
                  the tool result.
              type:
                type: string
                enum:
                  - function
                description: Tool type, set to `function`.
              function:
                type: object
                required:
                  - name
                  - arguments
                properties:
                  name:
                    type: string
                    description: Name of the function the model requests.
                  arguments:
                    type: string
                    description: Arguments as a JSON-encoded string.
                description: Name and arguments of the function the model requests.
            additionalProperties: true
          description: List of function calls in an assistant message.
        tool_call_id:
          type: string
          description: >-
            Tool-call ID. When returning a tool result, use the ID of the
            corresponding entry in `tool_calls`.
      additionalProperties: true
      description: >-
        One conversation message. Requests provide context as a list of
        messages; responses return the message generated by the model.
      allOf:
        - if:
            required:
              - tool_calls
          then:
            properties:
              role:
                const: assistant
    ChatCompletionChoice:
      type: object
      required:
        - index
        - message
        - finish_reason
      properties:
        index:
          type: integer
          description: Index of the candidate reply in the `choices` array.
        message:
          $ref: '#/components/schemas/ChatMessage'
          description: >-
            Message generated by the model, including reply content or tool-call
            information.
        finish_reason:
          type:
            - string
            - 'null'
          description: >-
            Reason generation ended.


            - `stop`: Normal completion or a stop sequence was encountered.

            - `length`: The generation length limit was reached; content may be
            incomplete.

            - `tool_calls`: The model requested tool calls.

            - `content_filter`: Content was filtered.

            - `function_call`: Compatibility indicator for a function call.

            - `null`: Generation has not ended.


            Models may return other finish reasons.
        logprobs:
          anyOf:
            - $ref: '#/components/schemas/ChatLogprobs'
            - type: 'null'
          description: Log probabilities of output tokens.
        content_filter_results:
          type: object
          additionalProperties: true
          description: >-
            Content moderation results. Whether this field is returned varies by
            model.
      additionalProperties: true
      description: A candidate reply and the reason generation ended.
    Usage:
      type: object
      required:
        - prompt_tokens
        - completion_tokens
        - total_tokens
      properties:
        prompt_tokens:
          type: integer
          description: Total input tokens, including cache-read and cache-write tokens.
        completion_tokens:
          type: integer
          description: Total output tokens, including any reasoning tokens generated.
        total_tokens:
          type: integer
          description: >-
            Combined input and output tokens for this request, equal to
            `prompt_tokens + completion_tokens`.
        prompt_tokens_details:
          type:
            - object
            - 'null'
          description: >-
            Input token details. May be absent or `null`. These counts are
            already included in `prompt_tokens`; do not add them again.
          additionalProperties: true
          properties:
            cached_tokens:
              type: integer
              description: >-
                Input tokens served from cache. Already included in
                `prompt_tokens`.
            cache_write_tokens:
              type: integer
              description: >-
                Input tokens written to cache. Already included in
                `prompt_tokens`.
        completion_tokens_details:
          type:
            - object
            - 'null'
          description: >-
            Output token details. May be absent or `null`. These counts are
            already included in `completion_tokens`; do not add them again.
          properties:
            reasoning_tokens:
              type: integer
              description: >-
                Output tokens used for reasoning. Already included in
                `completion_tokens`.
          additionalProperties: true
      additionalProperties: true
      description: >-
        Token usage for this request. Cache and reasoning details are subsets of
        input or output totals; do not add them again.
    ChatContentPart:
      type: object
      required:
        - type
      properties:
        type:
          type: string
          enum:
            - text
            - image_url
          description: 'Content block type: `text` for text or `image_url` for an image.'
        text:
          type: string
          description: Text content. Provide this field when `type=text`.
        image_url:
          type: object
          required:
            - url
          properties:
            url:
              type: string
              description: >-
                Public HTTPS image URL or a data URL containing Base64-encoded
                image data. Refer to the model documentation for image count,
                format, and size limits.
            detail:
              type: string
              enum:
                - auto
                - low
                - high
              default: auto
              description: >-
                Image detail level: `auto` lets the model choose, `low` requests
                low detail, and `high` requests high detail. Support varies by
                model.
          description: Image information. Provide this field when `type=image_url`.
      additionalProperties: true
      description: >-
        A text or image content block. Set the fields that correspond to its
        `type`.
      allOf:
        - if:
            required:
              - type
            properties:
              type:
                const: text
          then:
            required:
              - text
        - if:
            required:
              - type
            properties:
              type:
                const: image_url
          then:
            required:
              - image_url
    ChatLogprobs:
      type: object
      properties:
        content:
          type: array
          items:
            $ref: '#/components/schemas/TokenLogprob'
          description: Token log probabilities in output order.
      additionalProperties: true
    TokenLogprob:
      type: object
      required:
        - token
        - logprob
      properties:
        token:
          type: string
          description: Text of the output token.
        logprob:
          type: number
          description: Log probabilities of output tokens.
        bytes:
          type: string
          format: byte
          description: Token bytes encoded in Base64.
        top_logprobs:
          type: array
          items:
            $ref: '#/components/schemas/TokenLogprobCandidate'
          description: Highest-probability candidate tokens at this output position.
      additionalProperties: true
    TokenLogprobCandidate:
      type: object
      required:
        - token
        - logprob
      properties:
        token:
          type: string
          description: Text of the candidate token.
        logprob:
          type: number
          description: Log probability of the candidate token.
        bytes:
          type: string
          format: byte
          description: Token bytes encoded in Base64.
      additionalProperties: true
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: >-
        Authenticate with an API key using Bearer authentication. Do not expose
        real keys in documentation, code, or repositories.

````

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