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

# Direct Completions API Reference

> Send OpenAI-compatible chat completion requests directly to a model, without guardrails.

> [card] [Guide: Direct Completions](https://docs.gloo.com/api-guides/direct-completions.md)
>
> What runs and what doesn't, output limits, sampling parameters, and reasoning summaries.

> [card] [Error Reference: Direct Completions](https://docs.gloo.com/api-reference/general/errors.md#direct-completions)
>
> Common errors: unknown model, missing messages, context window exceeded, provider rate limit, provider timeout, provider unavailable.


## OpenAPI

````yaml post /ai/v2/direct/chat/completions
openapi: 3.1.0
info:
  title: AI API
  description: |-
    Optimized for high-speed inference and scalability by Gloo AI

    [Swagger UI](./docs) | [ReDoc UI](./redoc)
  version: 1.0.0
servers:
  - url: https://platform.ai.gloo.com
security:
  - bearerAuth: []
tags:
  - name: Content Controls
  - name: Data Engine
  - name: Ingestion & Enrichment
  - name: answers
  - name: chat
  - name: completions
  - name: content
  - name: core
  - name: data
  - name: get-models
  - name: ingestion
  - name: sotc
  - name: v1
  - name: v2
  - name: decisions
paths:
  /ai/v2/direct/chat/completions:
    post:
      tags:
        - v2
      summary: Direct Chat Completions
      description: >-
        Generate Chat Completions directly from the selected model without
        Gloo's guardrails or moderation.
      operationId: post-v2-direct-chat-completions
      parameters:
        - in: header
          name: X-Cache-TTL
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: X-Cache-Ttl
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PassthroughRequestBody'
      responses:
        '200':
          description: >-
            Successful direct Chat Completion. If `stream` is false or omitted,
            the response is JSON. If `stream=true`, the response is a
            Server-Sent Events stream.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DirectChatCompletionResponse'
            text/event-stream:
              schema:
                description: >-
                  JSON payloads sent in Server-Sent Events `data:` lines. A
                  stream can include content chunks, usage chunks, and error
                  chunks.
                anyOf:
                  - $ref: '#/components/schemas/ChatCompletionStreamChunk'
                  - $ref: '#/components/schemas/AiStreamErrorChunk'
              x-event-payload-schemas:
                - '#/components/schemas/ChatCompletionStreamChunk'
                - '#/components/schemas/AiStreamErrorChunk'
        '400':
          description: >-
            Bad Request - the provider declined the request under its content
            policy (`provider_content_policy_violation`, with `reasons` when the
            provider named categories), the provider rejected it as invalid for
            the model (`1001`), the model is not in the catalog, or the input
            exceeds the model's context window (`1002`). Body follows the direct
            endpoint error contract: show `message` to end users; use
            `developer_message`, `reasons`, and `X-Gloo-Error-Code` to triage.
          headers:
            X-Gloo-Error-Code:
              description: >-
                The stable machine-readable error code: a lowercase string such
                as `provider_unavailable`, present on every error. Branch on
                this header. The body's code can take another form: a numeric
                `error.code` (for example `2002`) or an uppercase `detail.code`
                (for example `INSUFFICIENT_CREDIT`).
              schema:
                type: string
            X-Request-Id:
              description: The request's ID. Include it when you contact support.
              schema:
                type: string
          content:
            application/json:
              schema:
                oneOf:
                  - type: object
                    required:
                      - detail
                    properties:
                      detail:
                        description: >-
                          Error detail object with `message`, `type`, `code`,
                          and `retryable`.
                    additionalProperties: true
                    not:
                      required:
                        - error
                  - $ref: '#/components/schemas/AiErrorResponse'
              examples:
                content_policy:
                  summary: Content-policy refusal
                  value:
                    detail:
                      message: >-
                        This request couldn't be completed. Please rephrase it
                        and try again.
                      type: content_policy_violation
                      code: provider_content_policy_violation
                      retryable: false
                      trace_id: trace-id
                      developer_message: >-
                        The model provider declined this request under its
                        content policy. Flagged: violence. Rephrase the request
                        or route to a different model.
                      reasons:
                        - violence
                provider_rejected:
                  summary: Provider rejected the request as invalid
                  value:
                    detail: >-
                      This request couldn't be processed. Please check it and
                      try again.
                    error:
                      message: >-
                        This request couldn't be processed. Please check it and
                        try again.
                      type: invalid_request_error
                      code: 1001
                      name: INVALID_REQUEST
                      category: client_error
                      description: The request is malformed or contains invalid parameters.
                      fault: client
                      retryable: false
                      trace_id: trace-id
                      developer_message: >-
                        The model provider rejected the request as invalid for
                        this model. Check the request's parameters against what
                        the model supports.
        '401':
          description: >-
            Unauthorized - the API key is missing, malformed, invalid, or
            expired (`authentication_error`).
          headers:
            X-Gloo-Error-Code:
              description: >-
                The stable machine-readable error code: a lowercase string such
                as `provider_unavailable`, present on every error. Branch on
                this header. The body's code can take another form: a numeric
                `error.code` (for example `2002`) or an uppercase `detail.code`
                (for example `INSUFFICIENT_CREDIT`).
              schema:
                type: string
            X-Request-Id:
              description: The request's ID. Include it when you contact support.
              schema:
                type: string
          content:
            application/json:
              schema:
                type: object
                required:
                  - detail
                properties:
                  detail:
                    description: >-
                      Error detail object with `message`, `type`, `code`, and
                      `retryable`.
                additionalProperties: true
              examples:
                authentication_error:
                  summary: Missing or invalid key
                  value:
                    detail:
                      message: This request couldn't be authorized.
                      type: authentication_error
                      code: authentication_error
                      retryable: false
                      developer_message: >-
                        The API key is missing, invalid or expired. Send a valid
                        key as 'Authorization: Bearer <key>'.
        '402':
          description: >-
            Payment Required - the organization's wallet credit is exhausted
            (`insufficient_credit` / 1006).
          headers:
            X-Gloo-Error-Code:
              description: >-
                The stable machine-readable error code: a lowercase string such
                as `provider_unavailable`, present on every error. Branch on
                this header. The body's code can take another form: a numeric
                `error.code` (for example `2002`) or an uppercase `detail.code`
                (for example `INSUFFICIENT_CREDIT`).
              schema:
                type: string
            X-Request-Id:
              description: The request's ID. Include it when you contact support.
              schema:
                type: string
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AiErrorResponse'
              example:
                detail:
                  message: >-
                    Wallet credit balance is exhausted. Add credits to your
                    account to continue.
                  code: INSUFFICIENT_CREDIT
                error:
                  message: >-
                    Wallet credit balance is exhausted. Add credits to your
                    account to continue.
                  type: billing_error
                  code: 1006
                  name: INSUFFICIENT_CREDIT
                  category: client_error
                  description: The account's prepaid wallet credit balance is exhausted.
                  fault: client
                  retryable: false
                  trace_id: trace-id
                  developer_message: >-
                    This organization's wallet credit is exhausted. Add credits
                    to the account to continue.
        '403':
          description: >-
            Forbidden - the organization's access is suspended because the
            organization is blocked or the API key was revoked
            (`account_suspended`), or the credentials do not belong to an
            organization or the organization has no active billing account
            (plain-text `detail` with a top-level `developer_message`).
          headers:
            X-Gloo-Error-Code:
              description: >-
                The stable machine-readable error code: a lowercase string such
                as `provider_unavailable`, present on every error. Branch on
                this header. The body's code can take another form: a numeric
                `error.code` (for example `2002`) or an uppercase `detail.code`
                (for example `INSUFFICIENT_CREDIT`).
              schema:
                type: string
            X-Request-Id:
              description: The request's ID. Include it when you contact support.
              schema:
                type: string
          content:
            application/json:
              schema:
                type: object
                required:
                  - detail
                properties:
                  detail:
                    description: >-
                      Error detail object with `message`, `type`, `code`, and
                      `retryable`.
                additionalProperties: true
              examples:
                account_suspended:
                  summary: Access suspended
                  value:
                    detail:
                      message: This account can't make requests right now.
                      type: permission_error
                      code: account_suspended
                      retryable: false
                      developer_message: >-
                        This organization's access to the Gloo AI API is
                        suspended. Contact Gloo support to restore it.
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
          headers:
            X-Gloo-Error-Code:
              description: >-
                The stable machine-readable error code: a lowercase string such
                as `provider_unavailable`, present on every error. Branch on
                this header. The body's code can take another form: a numeric
                `error.code` (for example `2002`) or an uppercase `detail.code`
                (for example `INSUFFICIENT_CREDIT`).
              schema:
                type: string
            X-Request-Id:
              description: The request's ID. Include it when you contact support.
              schema:
                type: string
        '429':
          description: >-
            Too Many Requests - the model's provider is temporarily limiting
            requests for this model (`rate_limit` / 2004, retryable, with
            `Retry-After` and `retry_after`), or the organization reached its
            spending limit (`spending_limit_exceeded` / 1005) or monthly API
            spend limit (`monthly_spend_limit_reached` / 1009), which are not
            retryable and carry no `Retry-After`.
          headers:
            X-Gloo-Error-Code:
              description: >-
                The stable machine-readable error code: a lowercase string such
                as `provider_unavailable`, present on every error. Branch on
                this header. The body's code can take another form: a numeric
                `error.code` (for example `2002`) or an uppercase `detail.code`
                (for example `INSUFFICIENT_CREDIT`).
              schema:
                type: string
            X-Request-Id:
              description: The request's ID. Include it when you contact support.
              schema:
                type: string
            Retry-After:
              description: >-
                Seconds to wait before retrying: on `rate_limit` (2004) and
                `service_unavailable` (3003; usually 30).
              schema:
                type: integer
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AiErrorResponse'
              examples:
                provider_rate_limit:
                  summary: Provider temporarily limiting requests
                  value:
                    detail: Too many requests right now. Please try again shortly.
                    error:
                      message: Too many requests right now. Please try again shortly.
                      type: rate_limit_error
                      code: 2004
                      name: RATE_LIMIT
                      category: provider_error
                      description: >-
                        The upstream model provider's rate limit was reached for
                        this request.
                      fault: provider
                      retryable: true
                      trace_id: trace-id
                      developer_message: >-
                        The model's provider is temporarily limiting requests
                        for this model. This is not your account's quota. Please
                        retry after a short backoff.
                      retry_after: 15
                spending_limit:
                  summary: Spending limit reached
                  value:
                    detail:
                      message: Spending limit reached
                      code: SPENDING_LIMIT_EXCEEDED
                    error:
                      message: Spending limit reached
                      type: billing_error
                      code: 1005
                      name: SPENDING_LIMIT_EXCEEDED
                      category: client_error
                      description: The account's spending limit has been reached.
                      fault: client
                      retryable: false
                      trace_id: trace-id
                      developer_message: >-
                        This organization has reached the spending limit set for
                        the Gloo AI API. An organization admin can raise the
                        limit; requests are refused until then.
        '500':
          description: >-
            Internal Server Error - an unexpected provider failure
            (`provider_inference_error` / 2013, retryable), or an unexpected
            Gloo failure (`internal_error` / 3001), including Gloo being unable
            to verify the API key because of an unexpected error (the key was
            not rejected). 3001 is never retryable; its message is "Something
            went wrong."
          headers:
            X-Gloo-Error-Code:
              description: >-
                The stable machine-readable error code: a lowercase string such
                as `provider_unavailable`, present on every error. Branch on
                this header. The body's code can take another form: a numeric
                `error.code` (for example `2002`) or an uppercase `detail.code`
                (for example `INSUFFICIENT_CREDIT`).
              schema:
                type: string
            X-Request-Id:
              description: The request's ID. Include it when you contact support.
              schema:
                type: string
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AiErrorResponse'
              examples:
                provider_inference_error:
                  summary: Unexpected provider failure
                  value:
                    detail: The service is temporarily unavailable. Please try again.
                    error:
                      message: >-
                        The service is temporarily unavailable. Please try
                        again.
                      type: internal_error
                      code: 2013
                      name: PROVIDER_INFERENCE_ERROR
                      category: provider_error
                      description: >-
                        An unexpected error occurred during model inference at
                        the upstream provider.
                      fault: provider
                      retryable: true
                      trace_id: trace-id
                      developer_message: >-
                        An unexpected error occurred during model inference at
                        the provider. Retry with exponential backoff.
                internal_error:
                  summary: Unexpected Gloo failure
                  value:
                    detail: Something went wrong.
                    error:
                      message: Something went wrong.
                      type: internal_error
                      code: 3001
                      name: INTERNAL_ERROR
                      category: platform_error
                      description: An unexpected internal error occurred on the platform.
                      fault: internal
                      retryable: false
                      trace_id: trace-id
                      developer_message: >-
                        An unexpected error occurred on the Gloo AI platform. If
                        it persists, contact Gloo support with the X-Request-Id.
                identity_unclassified:
                  summary: Gloo could not verify the key (unexpected error)
                  value:
                    detail: Something went wrong.
                    error:
                      message: Something went wrong.
                      type: internal_error
                      code: 3001
                      name: INTERNAL_ERROR
                      category: platform_error
                      description: An unexpected internal error occurred on the platform.
                      fault: internal
                      retryable: false
                      trace_id: trace-id
                      developer_message: >-
                        An unexpected error occurred while the Gloo AI platform
                        verified this request; your API key was not rejected. If
                        it persists, contact Gloo support with the X-Request-Id.
        '503':
          description: >-
            Service Unavailable - the provider is unavailable or overloaded, or
            every provider serving the model was unavailable
            (`provider_unavailable` / 2002), a temporary problem on Gloo's side
            (`service_unavailable` / 3003, `Retry-After`), including Gloo being
            unable to verify the API key (the key was not rejected), or the
            provider returned no content (`empty_completion` / 2006). A streamed
            request that fails before any output gets this status too.
          headers:
            X-Gloo-Error-Code:
              description: >-
                The stable machine-readable error code: a lowercase string such
                as `provider_unavailable`, present on every error. Branch on
                this header. The body's code can take another form: a numeric
                `error.code` (for example `2002`) or an uppercase `detail.code`
                (for example `INSUFFICIENT_CREDIT`).
              schema:
                type: string
            X-Request-Id:
              description: The request's ID. Include it when you contact support.
              schema:
                type: string
            Retry-After:
              description: >-
                Seconds to wait before retrying: on `rate_limit` (2004) and
                `service_unavailable` (3003; usually 30).
              schema:
                type: integer
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AiErrorResponse'
              examples:
                provider_unavailable:
                  summary: Provider unavailable
                  value:
                    detail: The service is temporarily unavailable. Please try again.
                    error:
                      message: >-
                        The service is temporarily unavailable. Please try
                        again.
                      type: service_unavailable_error
                      code: 2002
                      name: PROVIDER_UNAVAILABLE
                      category: provider_error
                      description: The upstream model provider is temporarily unavailable.
                      fault: provider
                      retryable: true
                      trace_id: trace-id
                      developer_message: >-
                        The model provider is temporarily unavailable for this
                        model. Retry with exponential backoff; if it persists,
                        try a different model.
                empty_completion:
                  summary: Empty completion
                  value:
                    detail: The service is temporarily unavailable. Please try again.
                    error:
                      message: >-
                        The service is temporarily unavailable. Please try
                        again.
                      type: service_unavailable_error
                      code: 2006
                      name: EMPTY_COMPLETION
                      category: provider_error
                      description: >-
                        The upstream provider returned a completion with no
                        content.
                      fault: provider
                      retryable: true
                      trace_id: trace-id
                      developer_message: >-
                        The model provider returned a completion with no
                        content. Retry the request.
                service_unavailable:
                  summary: Temporary problem on Gloo's side
                  value:
                    detail: The service is temporarily unavailable. Please try again.
                    error:
                      message: >-
                        The service is temporarily unavailable. Please try
                        again.
                      type: service_unavailable_error
                      code: 3003
                      name: SERVICE_UNAVAILABLE
                      category: platform_error
                      description: >-
                        The service could not complete the request because of a
                        temporary problem on Gloo's side; the request and API
                        key were not at fault. Retry after the Retry-After
                        delay, and contact Gloo support with the trace_id if it
                        persists.
                      fault: internal
                      retryable: true
                      trace_id: trace-id
                      developer_message: >-
                        The service could not complete the request because of a
                        temporary problem on our side; the request and API key
                        were not at fault. Retry after the Retry-After delay,
                        and contact Gloo support with the X-Request-Id if it
                        persists.
                      retry_after: 30
        '504':
          description: >-
            Gateway Timeout - the model provider did not respond in time
            (`provider_timeout` / 2001, retryable), or a non-streaming request
            ran past Gloo's own deadline (`gateway_deadline` / 3007, not
            retryable unchanged).
          headers:
            X-Gloo-Error-Code:
              description: >-
                The stable machine-readable error code: a lowercase string such
                as `provider_unavailable`, present on every error. Branch on
                this header. The body's code can take another form: a numeric
                `error.code` (for example `2002`) or an uppercase `detail.code`
                (for example `INSUFFICIENT_CREDIT`).
              schema:
                type: string
            X-Request-Id:
              description: The request's ID. Include it when you contact support.
              schema:
                type: string
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AiErrorResponse'
              examples:
                provider_timeout:
                  summary: Provider timeout
                  value:
                    detail: The service is temporarily unavailable. Please try again.
                    error:
                      message: >-
                        The service is temporarily unavailable. Please try
                        again.
                      type: timeout_error
                      code: 2001
                      name: PROVIDER_TIMEOUT
                      category: provider_error
                      description: >-
                        The upstream model provider did not respond within the
                        allowed time window.
                      fault: provider
                      retryable: true
                      trace_id: trace-id
                      developer_message: >-
                        The model provider did not respond in time. Retry with
                        exponential backoff; if it persists, try a different
                        model.
                gateway_deadline:
                  summary: Gloo's own deadline
                  value:
                    detail: >-
                      This request took too long to complete. Please try again
                      with a shorter request.
                    error:
                      message: >-
                        This request took too long to complete. Please try again
                        with a shorter request.
                      type: timeout_error
                      code: 3007
                      name: GATEWAY_DEADLINE
                      category: platform_error
                      description: >-
                        The request exceeded the gateway's non-streaming
                        response deadline.
                      fault: internal
                      retryable: false
                      trace_id: trace-id
                      developer_message: >-
                        The request exceeded the non-streaming response
                        deadline. Stream long generations, or lower max_tokens.
components:
  schemas:
    PassthroughRequestBody:
      properties:
        messages:
          items:
            additionalProperties: true
            type: object
          type: array
          title: Messages
          description: Chat messages array
        model:
          type: string
          title: Model
          description: Gloo model ID (e.g. 'gloo-anthropic-claude-opus-5.5')
        stream:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Stream
          description: Enable streaming
          default: false
        max_tokens:
          anyOf:
            - type: integer
            - type: 'null'
          title: Max Tokens
          description: >-
            Maximum output, in tokens. It holds the reasoning as well as the
            answer. When the model is reasoning, a value below 8,192 is raised
            to 8,192; a larger one is sent as you set it, up to the model's
            maximum output. With reasoning_effort 'none' on a model that can
            turn reasoning off (`can_disable: true` in the model catalog), from
            any provider, the value is sent as you set it, up to the model's
            maximum output. With no value, a reasoning model gets its full
            output allowance (up to 65,536) and other models get the model's
            default. A value of 0 or less counts as no value. See [Set your
            output limit for reasoning
            models](/api-guides/reasoning#set-your-output-limit-for-reasoning-models).
        max_completion_tokens:
          anyOf:
            - type: integer
            - type: 'null'
          title: Max Completion Tokens
          description: >-
            OpenAI's name for `max_tokens`. If you send both,
            `max_completion_tokens` is used.
        temperature:
          anyOf:
            - type: number
            - type: 'null'
          title: Temperature
          description: >-
            Sampling temperature. A model that does not take one (Claude 5
            models, and OpenAI GPT-5 and later models while they reason) does
            not get it, and it is listed in ignored_params (X-Ignored-Params on
            a stream). See [Sampling
            parameters](/api-guides/direct-completions#sampling-parameters).
        top_p:
          anyOf:
            - type: number
            - type: 'null'
          title: Top P
          description: Nucleus sampling parameter
        frequency_penalty:
          anyOf:
            - type: number
            - type: 'null'
          title: Frequency Penalty
          description: Frequency penalty
        presence_penalty:
          anyOf:
            - type: number
            - type: 'null'
          title: Presence Penalty
          description: Presence penalty
        stop:
          anyOf:
            - {}
            - type: 'null'
          title: Stop
          description: Stop sequences
        tools:
          anyOf:
            - items:
                additionalProperties: true
                type: object
              type: array
            - type: 'null'
          title: Tools
          description: >-
            Tool definitions. Supported tool types: 'function' (custom function
            tools), native web search (any 'web_search'-prefixed type), and
            'image_generation'; other tool types are rejected with a validation
            error.
        tool_choice:
          anyOf:
            - {}
            - type: 'null'
          title: Tool Choice
          description: Tool choice strategy
        response_format:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Response Format
          description: Response format
        stream_options:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Stream Options
          description: >-
            Streaming options, e.g. {include_usage: true} to receive a usage SSE
            chunk at the end of the stream.
        parallel_tool_calls:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Parallel Tool Calls
          description: >-
            Whether to enable parallel function calling. Stripped automatically
            when tools is missing, null, or empty.
        reasoning_effort:
          anyOf:
            - $ref: '#/components/schemas/ReasoningEffort'
            - type: 'null'
          title: Reasoning Effort
          description: >-
            How much a reasoning model thinks: 'none', 'minimal', 'low',
            'medium', 'high', 'xhigh' or 'max'. The nested form reasoning:
            {effort, summary} is accepted too; this field wins if both are sent.
            An effort other than 'none' also returns the model's reasoning: on a
            non-streamed answer as message.reasoning_content, and on a stream as
            delta.reasoning_content chunks before the answer. The reasoning is
            not moderated. A level the model does not run as sent (a model that
            does not reason, or a level it does not have) is not refused: it
            runs at the nearest level the model has, or without an effort, and
            is listed in ignored_params (X-Ignored-Params on a stream). See the
            Reasoning guide (/api-guides/reasoning).
        reasoning:
          anyOf:
            - type: object
              additionalProperties: true
              properties:
                effort:
                  type: string
                  description: >-
                    The effort, as in reasoning_effort. Only none, minimal, low,
                    medium, high, xhigh and max are read; any other value is not
                    sent to the model and is listed in ignored_params as
                    reasoning.effort=<value>.
                summary:
                  type: string
                  description: >-
                    auto, concise, detailed or none, read only beside an effort
                    that reaches the model; none asks for no summary. A summary
                    sent with no effort turns nothing on and is listed in
                    ignored_params as reasoning.summary=<value>.
            - type: 'null'
          title: Reasoning
          description: >-
            The nested OpenAI form of reasoning_effort: {"effort": "high"}.
            reasoning_effort wins if both are sent; a different nested effort it
            overrode is listed in ignored_params. Fields that cannot be read are
            listed in ignored_params and never cause an error.
        prompt_cache_key:
          anyOf:
            - type: string
            - type: 'null'
          title: Prompt Cache Key
          description: OpenAI Responses API cache key. Enables persistent prompt caching.
      additionalProperties: true
      type: object
      required:
        - messages
        - model
      title: DirectChatCompletionsRequestBody
      description: >-
        OpenAI-compatible chat completion request. Both messages and model are
        required; all other fields are optional and forwarded to the selected
        provider as-is.
      example:
        messages:
          - content: Hello world!
            role: user
        model: gloo-anthropic-claude-opus-5.5
        stream: true
        stream_options:
          include_usage: true
        temperature: 0
    DirectChatCompletionResponse:
      type: object
      title: Direct Chat Completion Response
      description: >-
        A non-streaming OpenAI-compatible Chat Completion returned by the
        selected model.
      additionalProperties: true
      properties:
        id:
          type: string
          description: Unique completion identifier.
        object:
          type: string
          const: chat.completion
          default: chat.completion
          description: Object type, always `chat.completion`.
        created:
          type: integer
          description: Unix timestamp when the completion was created.
        model:
          type: string
          description: Model that generated the completion.
        choices:
          type: array
          description: Completions generated by the model.
          items:
            $ref: '#/components/schemas/DirectChatCompletionChoice'
        usage:
          anyOf:
            - $ref: '#/components/schemas/DirectChatCompletionUsage'
            - type: 'null'
          description: Token usage when supplied by the provider.
        system_fingerprint:
          type:
            - string
            - 'null'
        ignored_params:
          $ref: '#/components/schemas/DirectChatCompletionIgnoredParams'
      required:
        - id
        - object
        - created
        - model
        - choices
      example:
        id: chatcmpl_123
        object: chat.completion
        created: 1716912000
        model: gloo-openai-gpt-5.5
        choices:
          - index: 0
            message:
              role: assistant
              content: Hello! How can I help?
            finish_reason: stop
            logprobs: null
        usage:
          prompt_tokens: 8
          completion_tokens: 7
          total_tokens: 15
    ChatCompletionStreamChunk:
      type: object
      title: Content or Usage Event
      description: >-
        JSON payload carried in each `data:` line of a chat completion
        Server-Sent Events stream.
      required:
        - id
        - object
        - created
        - model
        - choices
      properties:
        id:
          type: string
        object:
          type: string
          enum:
            - chat.completion.chunk
        created:
          type: integer
        model:
          type: string
        choices:
          type: array
          items:
            $ref: '#/components/schemas/ChatCompletionStreamChoice'
        usage:
          anyOf:
            - $ref: '#/components/schemas/ChatCompletionStreamUsage'
            - type: 'null'
        system_fingerprint:
          type:
            - string
            - 'null'
        ttft_ms:
          type:
            - number
            - 'null'
      additionalProperties: true
    AiStreamErrorChunk:
      title: Error Event
      allOf:
        - $ref: '#/components/schemas/ChatCompletionStreamChunk'
        - type: object
          title: Error Event
          description: >-
            SSE payload emitted after stream headers have already been sent and
            a provider/platform error occurs.
          required:
            - error
          properties:
            choices:
              type: array
              items:
                type: object
                properties:
                  finish_reason:
                    type: string
                    enum:
                      - error
                additionalProperties: true
            error:
              $ref: '#/components/schemas/AiError'
          additionalProperties: true
    AiErrorResponse:
      type: object
      title: AiErrorResponse
      description: >-
        AI API error response with existing detail field plus enriched error
        metadata.
      required:
        - detail
        - error
      properties:
        detail:
          description: Existing endpoint-specific error detail. May be a string or object.
        error:
          $ref: '#/components/schemas/AiError'
      additionalProperties: true
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ReasoningEffort:
      type: string
      title: Reasoning Effort
      description: >-
        How much a reasoning model thinks before it answers, from least to most.
        The levels a given model takes are in its `reasoning.effort_levels` on
        GET /platform/v2/models. A level the model does not take is not refused:
        it runs at the nearest level the model has, or without an effort, and is
        listed in `ignored_params` (`X-Ignored-Params` on a stream). See the
        Reasoning guide (/api-guides/reasoning).
      enum:
        - none
        - minimal
        - low
        - medium
        - high
        - xhigh
        - max
    DirectChatCompletionChoice:
      type: object
      title: Completion Choice
      description: One completion generated by the model.
      additionalProperties: true
      properties:
        index:
          type: integer
          description: Position of this choice in the response.
        message:
          $ref: '#/components/schemas/DirectChatCompletionMessage'
        finish_reason:
          type:
            - string
            - 'null'
          description: Why generation stopped, such as `stop`, `length`, or `tool_calls`.
        logprobs:
          type:
            - object
            - 'null'
          description: Log probability information when requested.
          additionalProperties: true
        native_finish_reason:
          type: string
          description: Provider-native finish reason when available.
      required:
        - index
        - message
        - finish_reason
    DirectChatCompletionUsage:
      type: object
      title: Usage
      description: Token usage for the completion.
      additionalProperties: true
      properties:
        prompt_tokens:
          type: integer
          description: Tokens in the prompt.
        completion_tokens:
          type: integer
          description: Tokens generated by the model.
        total_tokens:
          type: integer
          description: Total prompt and completion tokens.
        prompt_tokens_details:
          type:
            - object
            - 'null'
          description: Detailed prompt token counts when provided.
          additionalProperties: true
        completion_tokens_details:
          type:
            - object
            - 'null'
          description: Detailed completion token counts when provided.
          additionalProperties: true
      required:
        - prompt_tokens
        - completion_tokens
        - total_tokens
    DirectChatCompletionIgnoredParams:
      type: object
      title: Ignored Parameters
      description: >-
        Parameters that were ignored or not applied as sent. The request still
        succeeds. Entries include sampling parameters the selected model does
        not take; reasoning efforts the model ran at another level or without
        (for example `reasoning_effort=minimal`); nested `reasoning` fields that
        were not read (for example `reasoning.summary=auto` sent with no
        effort); and `messages.thinking=<n>`: the number of `thinking` or
        `redacted_thinking` parts removed from assistant messages you sent back.
        Reasoning is not carried between requests; the model reasons afresh. On
        a stream, the parameter names are in the `X-Ignored-Params` header
        instead.
      properties:
        params:
          type: array
          items:
            type: string
        model:
          type: string
        reason:
          type: string
      required:
        - params
        - model
        - reason
    ChatCompletionStreamChoice:
      type: object
      title: Stream Choice
      required:
        - delta
        - finish_reason
        - index
      properties:
        delta:
          $ref: '#/components/schemas/ChatCompletionStreamDelta'
        finish_reason:
          type:
            - string
            - 'null'
          description: >-
            Null while content is streaming; terminal values include stop,
            error, content_filter, tool_calls, and function_call.
        index:
          type: integer
        logprobs:
          type:
            - object
            - 'null'
          additionalProperties: true
      additionalProperties: true
    ChatCompletionStreamUsage:
      type: object
      title: Usage Details
      required:
        - prompt_tokens
        - completion_tokens
        - total_tokens
      properties:
        prompt_tokens:
          type: integer
        completion_tokens:
          type: integer
        total_tokens:
          type: integer
        completion_tokens_details:
          type:
            - object
            - 'null'
          additionalProperties: true
        prompt_tokens_details:
          type:
            - object
            - 'null'
          additionalProperties: true
      additionalProperties: true
    AiError:
      type: object
      title: AiError
      description: >-
        Standard AI API error object emitted by global provider/model error
        handlers.
      required:
        - message
        - type
        - code
        - name
        - category
        - description
        - fault
        - retryable
        - trace_id
      properties:
        message:
          type: string
          description: Request-specific customer-facing error message.
        type:
          type: string
          description: Stable wire-format error type.
        code:
          type: integer
          description: Stable numeric internal error code.
        name:
          type: string
          description: Stable symbolic error code name.
        category:
          type: string
          enum:
            - client_error
            - provider_error
            - platform_error
          description: Error category derived from the numeric code range.
        description:
          type: string
          description: Stable one-sentence explanation of what the error code means.
        fault:
          type: string
          enum:
            - client
            - provider
            - internal
          description: System responsible for the failure.
        retryable:
          type: boolean
          description: Whether retrying the same request may succeed.
        trace_id:
          type:
            - string
            - 'null'
          description: Sentry trace identifier when available.
      additionalProperties: true
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
    DirectChatCompletionMessage:
      type: object
      title: Assistant Message
      description: The assistant message generated by the selected model.
      additionalProperties: true
      properties:
        role:
          type: string
          description: Role of the message author, typically `assistant`.
        content:
          description: Generated message content. Tool-call-only responses can return null.
          anyOf:
            - type: string
            - items:
                additionalProperties: true
                type: object
              type: array
            - type: 'null'
        refusal:
          type:
            - string
            - 'null'
          description: Refusal text when the model declines the request.
        annotations:
          type:
            - array
            - 'null'
          description: Annotations associated with the generated content.
          items:
            additionalProperties: true
            type: object
        audio:
          type:
            - object
            - 'null'
          additionalProperties: true
        function_call:
          type:
            - object
            - 'null'
          description: Legacy function call generated by the model.
          additionalProperties: true
        tool_calls:
          type:
            - array
            - 'null'
          description: Tool calls generated by the model.
          items:
            additionalProperties: true
            type: object
        reasoning:
          type:
            - string
            - 'null'
          description: >-
            Reasoning text some providers return in this field instead of
            reasoning_content.
        reasoning_content:
          type:
            - string
            - 'null'
          description: >-
            The model's reasoning, when a reasoning_effort was set and the model
            returns it. Claude, Gemini and OpenAI models return a summary;
            open-weight models such as DeepSeek, GLM and gpt-oss return their
            raw reasoning.
        images:
          type:
            - array
            - 'null'
          description: Images generated by a compatible model.
          items:
            additionalProperties: true
            type: object
      required:
        - role
        - content
    ChatCompletionStreamDelta:
      type: object
      title: Stream Delta
      properties:
        content:
          type:
            - string
            - 'null'
        role:
          type:
            - string
            - 'null'
        function_call:
          type:
            - object
            - 'null'
          additionalProperties: true
        refusal:
          type:
            - string
            - 'null'
        tool_calls:
          type:
            - array
            - 'null'
          items:
            additionalProperties: true
            type: object
        reasoning_content:
          type:
            - string
            - 'null'
          description: >-
            A piece of the model's reasoning, sent in the chunks before the
            answer. On every chat endpoint, sent when the request set a
            reasoning effort other than 'none' and the model returns reasoning.
            Not moderated on the guarded endpoints.
      additionalProperties: true
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: api-key
      x-default: Bearer <api-key>
      description: >-
        Bearer authentication header of the form Bearer `<api-key>`, where
        `<api-key>` is your [API key](/studio/manage-api-credentials).

````

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