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

# Chat completions

> Generate a model response for a chat conversation. See [Text generation](https://docs.liquid.ai/api/guides/text-generation).



## OpenAPI

````yaml /api/openapi.json post /openai/v1/chat/completions
openapi: 3.1.0
info:
  title: Liquid inference API
  version: 1.0.0
  description: >-
    OpenAI-compatible inference API plus native endpoints.


    **Authentication** — Every request needs an API key, sent as a bearer token:
    `Authorization: Bearer $LIQUID_API_KEY`. Create a key on the [API
    keys](https://console.liquid.ai/dashboard/api-keys) page of Liquid Console;
    it is shown once.


    **Batch uploads** — Batch input files are uploaded through a presigned URL
    from `POST /v1/files`; see the [Batch
    guide](https://docs.liquid.ai/api/guides/batch).


    **Decision models** — `POST /decisions/v1/systemone` implements TypeSafe's
    System One API for typed Choice, Score, and Noul decisions from decision
    models such as `d1.1` and `d1-ultra`.
servers:
  - url: https://api.liquid.ai
security:
  - apiKey: []
tags:
  - name: Models
  - name: Chat
  - name: Decision models
  - name: Files
  - name: Batches
  - name: Large uploads
paths:
  /openai/v1/chat/completions:
    post:
      tags:
        - Chat
      summary: Chat completions
      description: >-
        Generate a model response for a chat conversation. See [Text
        generation](https://docs.liquid.ai/api/guides/text-generation).
      operationId: chat-completions
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                model:
                  type: string
                  description: The model id to use.
                  example: $MODEL_ID
                messages:
                  type: array
                  items: {}
                  description: >-
                    The conversation so far. Messages follow OpenAI
                    role-specific content requirements. User messages may
                    include `image_url` parts for models that take images, each
                    a base64 `data:` URL or an http(s) URL, and `input_audio`
                    parts (base64 WAV, `format: "wav"`) for models that take
                    audio; other models return 400. Liquid downloads linked
                    images itself before the request reaches the model, from
                    public addresses only, and returns 400 when one cannot be
                    downloaded or is not a PNG, JPEG, WebP, or GIF image; a
                    request may link up to 8 images, of at most 10 MB each and
                    20 MB together.
                stream:
                  type: boolean
                  description: When true, tokens stream back as server-sent events.
                modalities:
                  type: array
                  items: {}
                  description: >-
                    Output types. ["text", "audio"] asks a model with speech
                    output for a spoken reply, returned in `message.audio` (or
                    streamed in `delta.audio`) beside the text. Defaults to
                    ["text"]; models without speech output return 400.
                audio:
                  type: object
                  additionalProperties: true
                  description: >-
                    Spoken reply options when `modalities` includes "audio", as
                    in OpenAI: `{ "voice", "format" }`. `format` is `pcm16`
                    (headerless 16-bit PCM, 24 kHz mono), or `wav` (each
                    streamed chunk a complete WAV file); other formats return
                    400. The reply arrives in `message.audio` or streamed
                    `delta.audio`, with its words in `transcript`. `voice` is
                    accepted but does not change the voice.
              required:
                - model
                - messages
            example:
              model: $MODEL_ID
              messages:
                - role: system
                  content: You are a helpful assistant.
                - role: user
                  content: Hello!
      responses:
        '200':
          description: Successful response.
          content:
            application/json:
              example:
                id: chatcmpl-abc123
                object: chat.completion
                created: 1730419200
                model: $MODEL_ID
                choices:
                  - index: 0
                    message:
                      role: assistant
                      content: Hello! How can I help you today?
                    finish_reason: stop
                usage:
                  prompt_tokens: 19
                  completion_tokens: 10
                  total_tokens: 29
              schema:
                type: object
                properties:
                  id:
                    type: string
                    description: The completion id.
                  object:
                    type: string
                    description: Always "chat.completion".
                  created:
                    type: integer
                    description: Unix timestamp (seconds).
                  model:
                    type: string
                    description: The model that generated the response.
                  choices:
                    type: array
                    items: {}
                    description: The generated choices.
                  usage:
                    type: object
                    additionalProperties: true
                    description: >-
                      Token counts: { prompt_tokens, completion_tokens,
                      total_tokens }, plus `cost` in USD when the model is
                      priced. Audio models also report OpenAI's
                      `prompt_tokens_details` and `completion_tokens_details`,
                      whose `audio_tokens` say how much of each total was audio.
                      Some vision models bill each image as a multiple of its
                      tokens, counted in `prompt_tokens` as OpenAI does.
                      Streaming responses report it on the final usage chunk.
        '429':
          description: >-
            The organization's request or token limit for the model was
            exceeded.
          headers:
            Retry-After:
              description: Integral seconds until the request can be retried.
              schema:
                type: integer
                minimum: 1
            x-ratelimit-limit-requests:
              description: >-
                Maximum requests per minute (per second when only that limit is
                set), when a request limit applies.
              schema:
                type: integer
                minimum: 1
            x-ratelimit-remaining-requests:
              description: Requests remaining in that window.
              schema:
                type: integer
                minimum: 0
            x-ratelimit-reset-requests:
              description: >-
                Rounded-up duration until that window resets, such as 42s or
                1m0s.
              schema:
                type: string
                pattern: ^([1-9][0-9]*h)?([0-9]+m)?[0-9]+s$
            x-ratelimit-limit-tokens:
              description: >-
                Estimated tokens per minute (per second when only that limit is
                set), when a token limit applies.
              schema:
                type: integer
                minimum: 1
            x-ratelimit-remaining-tokens:
              description: Estimated tokens remaining in that window.
              schema:
                type: integer
                minimum: 0
            x-ratelimit-reset-tokens:
              description: >-
                Rounded-up duration until that window resets, such as 42s or
                1m0s.
              schema:
                type: string
                pattern: ^([1-9][0-9]*h)?([0-9]+m)?[0-9]+s$
          content:
            application/json:
              example:
                error:
                  message: >-
                    Rate limit exceeded for model `$MODEL_ID`. To request a
                    higher limit, contact us at https://www.liquid.ai/connect.
                  type: rate_limit_error
                  param: null
                  code: rate_limit_exceeded
      x-codeSamples:
        - lang: curl
          label: cURL
          source: |-
            curl https://api.liquid.ai/openai/v1/chat/completions \
              -H "Authorization: Bearer $LIQUID_API_KEY" \
              -H "Content-Type: application/json" \
              -d '{
                "model": "$MODEL_ID",
                "messages": [
                  {"role": "system", "content": "You are a helpful assistant."},
                  {"role": "user", "content": "Hello!"}
                ]
              }'
components:
  securitySchemes:
    apiKey:
      type: http
      scheme: bearer
      description: >-
        A Liquid API key from the [API
        keys](https://console.liquid.ai/dashboard/api-keys) page of Liquid
        Console, sent as `Authorization: Bearer $LIQUID_API_KEY`.

````

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