> ## 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

> Generate Chat Completions directly from the selected model without Gloo governance.

<Card title="Error Reference: Direct Completions" icon="triangle-exclamation" href="/api-reference/general/errors#completions-v2">
  Common errors: unsupported model, unsupported sampling parameter, missing messages, context window exceeded, provider timeout, provider unavailable.
</Card>


## 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
paths:
  /ai/v2/direct/chat/completions:
    post:
      tags:
        - v2
      summary: Direct Chat Completions
      description: >-
        Generate Chat Completions directly from the selected model without Gloo
        governance.
      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'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
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-sonnet-4.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 tokens to generate
        temperature:
          anyOf:
            - type: number
            - type: 'null'
          title: Temperature
          description: Sampling temperature
        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
        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 not provided.
        reasoning_effort:
          anyOf:
            - type: string
            - type: 'null'
          title: Reasoning Effort
          description: >-
            Controls reasoning effort for supported models (e.g. 'none', 'low',
            'medium', 'high'). Ignored for models that do not reason. A graded
            effort ('low'/'medium'/'high') also requests a reasoning summary,
            which streams as reasoning_content; 'none' requests no reasoning and
            therefore no summary.
        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-sonnet-4.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.
        service_tier:
          type:
            - string
            - 'null'
        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'
        service_tier:
          type:
            - string
            - '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
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    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: >-
        Sampling parameters ignored because the selected model does not support
        them.
      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 returned by a compatible provider.
        reasoning_content:
          type:
            - string
            - 'null'
          description: Provider-specific reasoning content when available.
        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
      additionalProperties: true
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: api-key
      x-default: <api-key>
      description: >-
        Bearer authentication header of the form Bearer `<api-key>`, where
        `<api-key>` is your [API key](/studio/manage-api-credentials).

````