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

# Buat chat completion

> Menjalankan inferensi model menggunakan skema OpenAI Chat Completions. Parameter permintaan termasuk streaming, visi, tool, keluaran terstruktur, dan kontrol penalaran diteruskan secara native.



## OpenAPI

````yaml /id/api-reference/openapi.json post /v1/chat/completions
openapi: 3.1.0
info:
  title: API Inferensi CerasAI
  version: 1.0.0
  description: >-
    API inferensi AI berlatensi rendah yang kompatibel dengan OpenAI Chat
    Completions (/v1/chat/completions) dan Anthropic Messages (/v1/messages).
servers:
  - url: https://api.cerasai.cloud
    description: Gateway Inferensi Produksi
security:
  - BearerAuth: []
paths:
  /v1/chat/completions:
    post:
      summary: Buat chat completion
      description: >-
        Menjalankan inferensi model menggunakan skema OpenAI Chat Completions.
        Parameter permintaan termasuk streaming, visi, tool, keluaran
        terstruktur, dan kontrol penalaran diteruskan secara native.
      operationId: createChatCompletionId
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ChatCompletionRequest'
      responses:
        '200':
          description: >-
            Respons inferensi berhasil (JSON atau text/event-stream bila
            stream=true).
          headers:
            x-request-id:
              description: Pengenal unik UUID v4 untuk mencocokkan permintaan di 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: >-
            Payload permintaan tidak valid, modalitas tidak didukung, atau
            parameter ditolak.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: API key hilang, tidak valid, telah dicabut, atau kedaluwarsa.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '402':
          description: >-
            Saldo kredit workspace habis (`insufficient_balance`) atau batas
            pengeluaran bulanan tercapai (`monthly_limit_exceeded`).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '403':
          description: >-
            IP pemanggil diblokir oleh daftar izin IP workspace
            (`ip_not_allowed`), model relay dinonaktifkan
            (`relayed_model_disabled`), atau akun pemilik workspace sedang
            ditangguhkan (`account_suspended`).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: >-
            ID model yang diminta tidak ditemukan di katalog aktif
            (`model_not_found`).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          description: >-
            Anggaran RPM, ITPM, atau OTPM per menit terlampaui
            (`rate_limit_exceeded`).
          headers:
            Retry-After:
              description: Jumlah detik hingga jendela 1 menit saat ini direset.
              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: Galat koneksi upstream atau stream terputus.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '503':
          description: >-
            Rute model belum dikonfigurasi atau layanan otorisasi sementara
            tidak dapat dihubungi.
          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: ID Model yang persis dan peka huruf besar/kecil dari GET /v1/models.
        messages:
          type: array
          items:
            $ref: '#/components/schemas/ChatMessage'
        stream:
          type: boolean
          default: false
          description: Aktifkan streaming Server-Sent Events (SSE).
        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: >-
            Mengatur tingkat penalaran pada model yang mendukungnya (mis.
            'none', 'low', 'high', 'max').
        tools:
          type: array
          items:
            type: object
            additionalProperties: true
          description: Definisi fungsi/tool yang diteruskan secara native ke 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: Batas workspace per menit (permintaan).
      schema:
        type: integer
    x-ratelimit-remaining-requests:
      description: Sisa kuota workspace (permintaan).
      schema:
        type: integer
    x-ratelimit-reset-requests:
      description: Waktu hingga jendela kuota direset (permintaan).
      schema:
        type: string
        example: 30s
    x-ratelimit-limit-tokens:
      description: >-
        Batas workspace per menit (token pada kuota input atau output dengan
        proporsi sisa terkecil).
      schema:
        type: integer
    x-ratelimit-remaining-tokens:
      description: >-
        Sisa kuota workspace (token pada kuota input atau output dengan proporsi
        sisa terkecil).
      schema:
        type: integer
    x-ratelimit-reset-tokens:
      description: >-
        Waktu hingga jendela kuota direset (token pada kuota input atau output
        dengan proporsi sisa terkecil).
      schema:
        type: string
        example: 30s
    retry-after-ms:
      description: Jeda sebelum mencoba kembali, dalam milidetik.
      schema:
        type: integer
    x-should-retry:
      description: Menunjukkan apakah permintaan dapat dicoba kembali.
      schema:
        type: boolean
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: 'API key workspace CerasAI (`Authorization: Bearer $CERASAI_API_KEY`).'

````

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