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

# Create a chat completion

> OpenAI-compatible Chat Completions endpoint. Supports streaming via stream: true, which returns a Server-Sent Events stream of chat.completion.chunk objects.



## OpenAPI

````yaml /openapi.json post /chat/completions
openapi: 3.1.0
info:
  title: Sail API
  version: '2026-02-18'
  description: >-
    Sail provides OpenAI-compatible Responses and Chat Completions endpoints,
    plus an Anthropic-compatible Messages endpoint. This reference documents the
    currently supported subset of fields.
servers:
  - url: https://api.sailresearch.com/v1
security:
  - BearerAuth: []
tags:
  - name: Models API
    description: Model discovery endpoints.
  - name: Responses API
    description: OpenAI-compatible Responses API endpoints.
  - name: Chat Completions API
    description: OpenAI-compatible Chat Completions API endpoints.
  - name: Messages API
    description: Anthropic-compatible Messages API endpoints.
  - name: Batches API
    description: Submit and manage batches of requests.
paths:
  /chat/completions:
    post:
      tags:
        - Chat Completions API
      summary: Create a chat completion
      description: >-
        OpenAI-compatible Chat Completions endpoint. Supports streaming via
        stream: true, which returns a Server-Sent Events stream of
        chat.completion.chunk objects.
      operationId: createChatCompletion
      parameters:
        - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateChatCompletionRequest'
            example:
              model: zai-org/GLM-5.2-FP8
              messages:
                - role: system
                  content: You are a concise assistant.
                - role: user
                  content: Summarize retrieval-augmented generation in 3 bullets.
              max_completion_tokens: 300
      responses:
        '200':
          description: >-
            Chat completion. Returns a single JSON object by default, or a
            Server-Sent Events stream of chat.completion.chunk objects when
            stream: true (terminated by a final data: [DONE] line).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ChatCompletionResponse'
            text/event-stream:
              schema:
                $ref: '#/components/schemas/ChatCompletionChunk'
        '400':
          description: Invalid request or unsupported feature.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Authentication error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '408':
          description: Timed out waiting for completion.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  parameters:
    IdempotencyKey:
      name: Idempotency-Key
      in: header
      required: false
      schema:
        type: string
        maxLength: 255
      description: >-
        Makes the request retry-safe. Sail stores a reservation keyed by
        (organization, API key, Idempotency-Key); retrying with the same value
        returns the previously stored response instead of re-running inference.
        Keys are capped at 255 characters. See [Idempotent
        Requests](/idempotency) for full semantics.
  schemas:
    CreateChatCompletionRequest:
      type: object
      required:
        - model
        - messages
      properties:
        model:
          type: string
        messages:
          type: array
          minItems: 1
          items:
            $ref: '#/components/schemas/ChatCompletionMessage'
        temperature:
          oneOf:
            - type: number
              minimum: 0
              maximum: 2
            - type: 'null'
        top_p:
          oneOf:
            - type: number
              minimum: 0
              maximum: 1
            - type: 'null'
        max_completion_tokens:
          oneOf:
            - type: integer
              minimum: 1
            - type: 'null'
        response_format:
          oneOf:
            - $ref: '#/components/schemas/ChatResponseFormatText'
            - $ref: '#/components/schemas/ChatResponseFormatJsonSchema'
        reasoning_effort:
          oneOf:
            - type: string
              enum:
                - none
                - minimal
                - low
                - medium
                - high
                - xhigh
            - type: 'null'
        'n':
          type: integer
          enum:
            - 1
          description: Only n=1 is currently supported.
        modalities:
          type: array
          minItems: 1
          maxItems: 1
          items:
            type: string
            enum:
              - text
        stream:
          type: boolean
          description: >-
            When true, the response is returned as a Server-Sent Events stream
            of chat.completion.chunk objects instead of a single JSON response.
        stream_options:
          type: object
          description: Options that apply when stream is true.
          properties:
            include_usage:
              type: boolean
              description: >-
                When true, emit a final chunk with token usage for the full
                request before the [DONE] terminator.
          additionalProperties: false
        store:
          type: boolean
          enum:
            - true
          description: Only true is supported.
        user:
          type: string
          maxLength: 256
        metadata:
          $ref: '#/components/schemas/RequestMetadata'
      additionalProperties: true
    ChatCompletionResponse:
      type: object
      required:
        - id
        - object
        - created
        - model
        - choices
      properties:
        id:
          type: string
        object:
          type: string
          enum:
            - chat.completion
        created:
          type: integer
        model:
          type: string
        choices:
          type: array
          minItems: 1
          items:
            $ref: '#/components/schemas/ChatCompletionChoice'
        usage:
          $ref: '#/components/schemas/ChatCompletionUsage'
      additionalProperties: true
    ChatCompletionChunk:
      type: object
      description: >-
        One Server-Sent Events chunk emitted when stream: true. The streamed
        response is a sequence of these chat.completion.chunk objects, each sent
        as an SSE data: line and terminated by a final data: [DONE] line.
      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/ChatCompletionChunkChoice'
        usage:
          $ref: '#/components/schemas/ChatCompletionUsage'
      additionalProperties: false
    ErrorResponse:
      type: object
      required:
        - error
      properties:
        error:
          $ref: '#/components/schemas/ErrorObject'
      additionalProperties: false
    ChatCompletionMessage:
      type: object
      required:
        - role
      properties:
        role:
          type: string
          enum:
            - system
            - user
            - assistant
            - tool
            - function
            - developer
        content:
          oneOf:
            - type: string
            - type: 'null'
            - type: array
              items:
                oneOf:
                  - $ref: '#/components/schemas/ChatTextContentPart'
                  - $ref: '#/components/schemas/ChatImageContentPart'
        name:
          type: string
        tool_calls:
          type: array
          items:
            type: object
            additionalProperties: true
        tool_call_id:
          type: string
        function_call:
          type: object
          additionalProperties: true
      additionalProperties: false
    ChatResponseFormatText:
      type: object
      required:
        - type
      properties:
        type:
          type: string
          enum:
            - text
      additionalProperties: false
    ChatResponseFormatJsonSchema:
      type: object
      required:
        - type
        - json_schema
      properties:
        type:
          type: string
          enum:
            - json_schema
        json_schema:
          type: object
          required:
            - name
          properties:
            name:
              type: string
            description:
              type: string
            schema:
              type: object
              additionalProperties: true
            strict:
              type: boolean
          additionalProperties: false
      additionalProperties: false
    RequestMetadata:
      type: object
      description: >-
        Optional string metadata. completion_window controls scheduling;
        completion_webhook/webhook_token configure completion webhooks.
      properties:
        completion_window:
          type: string
          description: >-
            [Completion window](/completion-windows) (i.e. latency tier) for the
            request. Support matrix is available on the [Pricing](/pricing)
            page. When omitted, defaults to `standard` if that window is
            supported for the model; otherwise `flex` for async requests when
            the model supports it, and `asap` in all other cases. See [default
            behavior](/completion-windows#default-behavior).
          enum:
            - asap
            - priority
            - standard
            - flex
        completion_webhook:
          type: string
          format: uri
        webhook_token:
          type: string
      additionalProperties:
        type: string
    ChatCompletionChoice:
      type: object
      required:
        - index
        - message
        - logprobs
        - finish_reason
      properties:
        index:
          type: integer
        message:
          $ref: '#/components/schemas/ChatCompletionResponseMessage'
        logprobs:
          type: 'null'
        finish_reason:
          type: string
          enum:
            - stop
            - length
            - tool_calls
            - content_filter
            - function_call
      additionalProperties: false
    ChatCompletionUsage:
      type: object
      required:
        - prompt_tokens
        - completion_tokens
        - total_tokens
      properties:
        prompt_tokens:
          type: integer
        completion_tokens:
          type: integer
        total_tokens:
          type: integer
        prompt_tokens_details:
          type: object
          additionalProperties: true
        completion_tokens_details:
          type: object
          additionalProperties: true
      additionalProperties: false
    ChatCompletionChunkChoice:
      type: object
      required:
        - index
        - delta
      properties:
        index:
          type: integer
        delta:
          $ref: '#/components/schemas/ChatCompletionChunkDelta'
        logprobs:
          type: 'null'
        finish_reason:
          type:
            - string
            - 'null'
          enum:
            - stop
            - tool_calls
            - null
      additionalProperties: false
    ErrorObject:
      type: object
      required:
        - message
        - type
      properties:
        message:
          type: string
        type:
          type: string
        param:
          oneOf:
            - type: string
            - type: 'null'
        code:
          oneOf:
            - type: string
            - type: integer
            - type: 'null'
      additionalProperties: true
    ChatTextContentPart:
      type: object
      required:
        - type
        - text
      properties:
        type:
          type: string
          enum:
            - text
        text:
          type: string
      additionalProperties: false
    ChatImageContentPart:
      type: object
      description: >-
        Image content part. Image input is supported only on multimodal models;
        see the Models page.
      required:
        - type
        - image_url
      properties:
        type:
          type: string
          enum:
            - image_url
        image_url:
          type: object
          required:
            - url
          properties:
            url:
              type: string
              description: Public http(s) URL or a base64 data URI.
            detail:
              type: string
              enum:
                - auto
                - low
                - high
          additionalProperties: false
      additionalProperties: false
    ChatCompletionResponseMessage:
      type: object
      required:
        - role
        - content
      properties:
        role:
          type: string
          enum:
            - assistant
        content:
          oneOf:
            - type: string
            - type: 'null'
        reasoning_content:
          oneOf:
            - type: string
            - type: 'null'
        refusal:
          oneOf:
            - type: string
            - type: 'null'
      additionalProperties: true
    ChatCompletionChunkDelta:
      type: object
      properties:
        role:
          type: string
        content:
          type: string
        reasoning_content:
          type: string
        refusal:
          type: string
        tool_calls:
          type: array
          items:
            $ref: '#/components/schemas/ChatCompletionChunkToolCall'
      additionalProperties: false
    ChatCompletionChunkToolCall:
      type: object
      properties:
        index:
          type: integer
        id:
          type: string
        type:
          type: string
        function:
          $ref: '#/components/schemas/ChatCompletionChunkToolCallFunction'
        custom:
          $ref: '#/components/schemas/ChatCompletionChunkToolCallFunction'
      additionalProperties: false
    ChatCompletionChunkToolCallFunction:
      type: object
      properties:
        name:
          type: string
        arguments:
          type: string
        input:
          type: string
      additionalProperties: false
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key

````