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

# Create chat completion

> Generate a model response for a conversation. OpenAI-compatible; supports streaming, tool calls, and structured output. Supports gateway fallback models (`fallbacks`) and, when the workspace has [response caching](/billing/caching) enabled, serves identical repeat requests from cache at a discount (see the `X-Omnia-Cache` response header).



## OpenAPI

````yaml /openapi-inference.json post /chat/completions
openapi: 3.1.0
info:
  title: Omnia Inference API
  description: >-
    OpenAI-compatible inference endpoints: chat completions, embeddings, rerank,
    and the Responses API. Authenticated with a workspace API key
    (sk_sovereign_...).
  version: 1.0.0
servers:
  - url: https://gateway.omnia-voice.com/v1
    description: Production
security:
  - bearerAuth: []
paths:
  /chat/completions:
    post:
      tags:
        - Chat
      summary: Create chat completion
      description: >-
        Generate a model response for a conversation. OpenAI-compatible;
        supports streaming, tool calls, and structured output. Supports gateway
        fallback models (`fallbacks`) and, when the workspace has [response
        caching](/billing/caching) enabled, serves identical repeat requests
        from cache at a discount (see the `X-Omnia-Cache` response header).
      operationId: createChatCompletion
      parameters:
        - name: X-Omnia-Cache-Control
          in: header
          required: false
          schema:
            type: string
            enum:
              - no-cache
              - no-store
          description: >-
            Per-request cache control (only meaningful when the workspace has
            response caching enabled — it can reduce caching, never enable it).
            `no-cache`: skip the cache and force a fresh model run, refreshing
            the stored copy. `no-store`: fresh run AND keep this response out of
            cache storage entirely. Either way the response carries
            `X-Omnia-Cache: bypass`.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - model
                - messages
              properties:
                model:
                  type: string
                  description: >-
                    The model id, e.g. Qwen/Qwen3-32B. A dedicated endpoint is
                    addressed as dedicated/<routing-key>.
                  example: Qwen/Qwen3-32B
                messages:
                  type: array
                  description: The conversation so far.
                  items:
                    type: object
                    properties:
                      role:
                        type: string
                        enum:
                          - system
                          - user
                          - assistant
                          - tool
                      content:
                        description: >-
                          String, or an array of content parts (text/image) for
                          vision.
                stream:
                  type: boolean
                  default: false
                  description: Stream the response as server-sent events.
                stream_options:
                  type:
                    - object
                    - 'null'
                  description: >-
                    Streaming options. Usage reporting is included
                    automatically.
                temperature:
                  type: number
                  description: Sampling temperature (0–2).
                top_p:
                  type: number
                  description: Nucleus sampling probability mass.
                top_k:
                  type: integer
                  description: Top-k sampling.
                'n':
                  type: integer
                  description: Number of completions to generate.
                max_tokens:
                  type: integer
                  description: >-
                    Maximum output tokens. Bounded by the model's context
                    window.
                max_completion_tokens:
                  type: integer
                  description: Alias for max_tokens.
                stop:
                  description: Up to a few stop sequences (string or array of strings).
                seed:
                  type: integer
                  description: For more reproducible sampling.
                frequency_penalty:
                  type: number
                  description: Penalize repeated tokens by frequency.
                presence_penalty:
                  type: number
                  description: Penalize tokens that have appeared.
                repetition_penalty:
                  type: number
                  description: Penalize repetition.
                logit_bias:
                  type: object
                  description: Bias specific tokens.
                logprobs:
                  type: boolean
                  description: Return log probabilities.
                top_logprobs:
                  type: integer
                  description: How many top log probabilities to return per token.
                response_format:
                  type: object
                  description: >-
                    { "type": "json_object" } or { "type": "json_schema", ... }
                    for structured output.
                tools:
                  type: array
                  description: Function definitions the model may call.
                  items:
                    type: object
                tool_choice:
                  description: auto, required, none, or a specific function.
                parallel_tool_calls:
                  type: boolean
                  description: Allow the model to call multiple tools in parallel.
                reasoning_effort:
                  type: string
                  description: Reasoning effort for reasoning-capable models.
                user:
                  type: string
                  description: A stable identifier for the end user.
                fallbacks:
                  type: array
                  maxItems: 2
                  items:
                    type: string
                  description: >-
                    Up to 2 backup model ids tried in order when the primary
                    fails with a transient error (429/timeout/5xx). Billing uses
                    the model that actually served; the X-Omnia-Fallback-From
                    response header names the model it fell back from. Gateway
                    feature — never forwarded to the model.
      responses:
        '200':
          description: >-
            A chat completion. When streaming, a text/event-stream of chunks
            ending with data: [DONE].
          headers:
            X-Omnia-Cache:
              schema:
                type: string
                enum:
                  - hit
                  - miss
                  - bypass
              description: >-
                Present when the workspace has response caching enabled: `hit`
                means this response was served from cache (billed at the cache
                discount), `miss` means it was generated fresh and may be
                stored, `bypass` means the request's `X-Omnia-Cache-Control`
                header forced a fresh run. Absent when caching is off.
            X-Omnia-Fallback-From:
              schema:
                type: string
              description: >-
                Present only when a fallback model served the request: the
                primary model id it fell back from. The body's `model` field
                names the model that actually answered.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ChatCompletion'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '402':
          $ref: '#/components/responses/InsufficientBalance'
        '404':
          $ref: '#/components/responses/ModelNotFound'
components:
  schemas:
    ChatCompletion:
      type: object
      properties:
        id:
          type: string
          example: chatcmpl-...
        object:
          type: string
          example: chat.completion
        model:
          type: string
        choices:
          type: array
          items:
            type: object
            properties:
              index:
                type: integer
              message:
                type: object
                properties:
                  role:
                    type: string
                    example: assistant
                  content:
                    type: string
                  tool_calls:
                    type: array
                    items:
                      type: object
              finish_reason:
                type: string
                example: stop
        usage:
          $ref: '#/components/schemas/Usage'
    Usage:
      type: object
      properties:
        prompt_tokens:
          type: integer
        completion_tokens:
          type: integer
        total_tokens:
          type: integer
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
            type:
              type: string
            code:
              type: string
  responses:
    BadRequest:
      description: Missing a required field (e.g. model, messages/input/query/documents).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Unauthorized:
      description: Missing, malformed, or revoked API key.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              message: Invalid API key
              type: invalid_request_error
              code: invalid_api_key
    InsufficientBalance:
      description: Your wallet can't cover the request's worst-case cost.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              message: Insufficient balance. Please top up your wallet.
              type: insufficient_quota
              code: insufficient_balance
    ModelNotFound:
      description: The model is not offered (or the id is wrong).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              message: The model 'x' does not exist or is not available.
              type: invalid_request_error
              code: model_not_found
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        Your workspace API key, e.g. sk_sovereign_..., sent as Authorization:
        Bearer <key>.

````