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

# Create chat completion

> Runs model inference using the OpenAI Chat Completions schema. Request parameters including streaming, vision, tools, structured outputs, and reasoning controls are forwarded natively.



## OpenAPI

````yaml /api-reference/openapi.json post /v1/chat/completions
openapi: 3.1.0
info:
  title: CerasAI Inference API
  version: 1.0.0
  description: >-
    Low-latency AI inference API compatible with OpenAI Chat Completions
    (/v1/chat/completions) and Anthropic Messages (/v1/messages).
servers:
  - url: https://api.cerasai.cloud
    description: Production Inference Gateway
security:
  - BearerAuth: []
paths:
  /v1/chat/completions:
    post:
      summary: Create chat completion
      description: >-
        Runs model inference using the OpenAI Chat Completions schema. Request
        parameters including streaming, vision, tools, structured outputs, and
        reasoning controls are forwarded natively.
      operationId: createChatCompletion
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ChatCompletionRequest'
      responses:
        '200':
          description: >-
            Inference response succeeded (JSON or text/event-stream when
            stream=true).
          headers:
            x-request-id:
              description: Unique UUID v4 identifier for matching the request in Logs.
              schema:
                type: string
                format: uuid
            x-ratelimit-limit-requests:
              $ref: '#/components/headers/x-ratelimit-limit-requests'
            x-ratelimit-remaining-requests:
              $ref: '#/components/headers/x-ratelimit-remaining-requests'
            x-ratelimit-reset-requests:
              $ref: '#/components/headers/x-ratelimit-reset-requests'
            x-ratelimit-limit-tokens:
              $ref: '#/components/headers/x-ratelimit-limit-tokens'
            x-ratelimit-remaining-tokens:
              $ref: '#/components/headers/x-ratelimit-remaining-tokens'
            x-ratelimit-reset-tokens:
              $ref: '#/components/headers/x-ratelimit-reset-tokens'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ChatCompletionResponse'
        '400':
          description: >-
            Invalid request payload, unsupported modality, or rejected
            parameter.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Missing, invalid, revoked, or expired API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '402':
          description: >-
            Workspace credit balance is exhausted (`insufficient_balance`) or
            monthly spend limit reached (`monthly_limit_exceeded`).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '403':
          description: >-
            Caller IP is blocked by workspace IP allowlist (`ip_not_allowed`),
            relayed models are disabled (`relayed_model_disabled`), or the
            workspace owner account is suspended (`account_suspended`).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: >-
            Requested model ID was not found in the active catalog
            (`model_not_found`).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          description: >-
            Per-minute RPM, ITPM, or OTPM budget exceeded
            (`rate_limit_exceeded`).
          headers:
            Retry-After:
              description: Seconds until the current 1-minute window resets.
              schema:
                type: integer
            x-ratelimit-limit-requests:
              $ref: '#/components/headers/x-ratelimit-limit-requests'
            x-ratelimit-remaining-requests:
              $ref: '#/components/headers/x-ratelimit-remaining-requests'
            x-ratelimit-reset-requests:
              $ref: '#/components/headers/x-ratelimit-reset-requests'
            x-ratelimit-limit-tokens:
              $ref: '#/components/headers/x-ratelimit-limit-tokens'
            x-ratelimit-remaining-tokens:
              $ref: '#/components/headers/x-ratelimit-remaining-tokens'
            x-ratelimit-reset-tokens:
              $ref: '#/components/headers/x-ratelimit-reset-tokens'
            retry-after-ms:
              $ref: '#/components/headers/retry-after-ms'
            x-should-retry:
              $ref: '#/components/headers/x-should-retry'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '502':
          description: Upstream provider connection error or interrupted stream.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '503':
          description: >-
            Route provider not configured or authorization backend temporarily
            unreachable.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    ChatCompletionRequest:
      type: object
      required:
        - model
        - messages
      properties:
        model:
          type: string
          example: deepseek-ai/DeepSeek-V4.1-Flash-1017
          description: Exact case-sensitive Model ID from GET /v1/models.
        messages:
          type: array
          items:
            $ref: '#/components/schemas/ChatMessage'
        stream:
          type: boolean
          default: false
          description: Enable Server-Sent Events (SSE) streaming.
        stream_options:
          type: object
          properties:
            include_usage:
              type: boolean
          additionalProperties: true
        temperature:
          type: number
          minimum: 0
          maximum: 2
          example: 0.7
        top_p:
          type: number
          minimum: 0
          maximum: 1
          example: 1
        max_tokens:
          type: integer
          minimum: 1
          example: 2048
        reasoning_effort:
          type: string
          description: >-
            Controls reasoning effort on models that support it (e.g. 'none',
            'low', 'high', 'max').
        tools:
          type: array
          items:
            type: object
            additionalProperties: true
          description: Function/tool definitions forwarded natively to the model.
        tool_choice:
          oneOf:
            - type: string
            - type: object
              additionalProperties: true
        response_format:
          type: object
          additionalProperties: true
        stop:
          oneOf:
            - type: string
            - type: array
              items:
                type: string
        seed:
          type: integer
      additionalProperties: true
    ChatCompletionResponse:
      type: object
      properties:
        id:
          type: string
        object:
          type: string
          example: chat.completion
        created:
          type: integer
        model:
          type: string
          example: deepseek-ai/DeepSeek-V4.1-Flash-1017
        choices:
          type: array
          items:
            type: object
            properties:
              index:
                type: integer
              message:
                $ref: '#/components/schemas/ChatMessage'
              finish_reason:
                type:
                  - string
                  - 'null'
        usage:
          $ref: '#/components/schemas/Usage'
    ErrorResponse:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
            type:
              type: string
            param:
              type:
                - string
                - 'null'
            code:
              type: string
    ChatMessage:
      type: object
      required:
        - role
        - content
      properties:
        role:
          type: string
          enum:
            - system
            - user
            - assistant
            - tool
        content:
          oneOf:
            - type: string
            - type: array
              items:
                type: object
                additionalProperties: true
        reasoning_content:
          type:
            - string
            - 'null'
        tool_calls:
          type: array
          items:
            type: object
            additionalProperties: true
        tool_call_id:
          type: string
      additionalProperties: true
    Usage:
      type: object
      properties:
        prompt_tokens:
          type: integer
        completion_tokens:
          type: integer
        total_tokens:
          type: integer
        prompt_tokens_details:
          type: object
          properties:
            cached_tokens:
              type: integer
  headers:
    x-ratelimit-limit-requests:
      description: Workspace limit per minute (requests).
      schema:
        type: integer
    x-ratelimit-remaining-requests:
      description: Remaining workspace quota (requests).
      schema:
        type: integer
    x-ratelimit-reset-requests:
      description: Time until the current window resets (requests).
      schema:
        type: string
        example: 30s
    x-ratelimit-limit-tokens:
      description: >-
        Workspace limit per minute (tokens in the more constrained input or
        output bucket).
      schema:
        type: integer
    x-ratelimit-remaining-tokens:
      description: >-
        Remaining workspace quota (tokens in the more constrained input or
        output bucket).
      schema:
        type: integer
    x-ratelimit-reset-tokens:
      description: >-
        Time until the current window resets (tokens in the more constrained
        input or output bucket).
      schema:
        type: string
        example: 30s
    retry-after-ms:
      description: Delay before retrying, in milliseconds.
      schema:
        type: integer
    x-should-retry:
      description: Whether retrying is appropriate.
      schema:
        type: boolean
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: 'CerasAI workspace API key (`Authorization: Bearer $CERASAI_API_KEY`).'

````

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