> ## 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 pesan (Anthropic)

> Jalankan inferensi model menggunakan skema Anthropic Messages API.

Menghasilkan respons menggunakan skema Anthropic Messages API. Autentikasi dengan `x-api-key: $CERASAI_API_KEY` atau `Authorization: Bearer $CERASAI_API_KEY`.

Setiap respons menyertakan header `x-request-id` berformat UUID v4 untuk penelusuran di [Logs](https://console.cerasai.cloud/logs).

> [!NOTE]
>
> CerasAI meneruskan permintaan Messages dalam protokol yang sama ke rute model. Dukungan untuk gambar, tool, thinking, dan blok dokumen bergantung pada rute model yang dipilih.


## OpenAPI

````yaml id/api-reference/openapi.json POST /v1/messages
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/messages:
    post:
      summary: Buat pesan
      description: >-
        Menjalankan inferensi model menggunakan skema Anthropic Messages API.
        Permintaan diteruskan dalam protokol yang sama ke rute model, yang
        menentukan dukungan untuk gambar, tool, thinking, dan blok dokumen.
      operationId: createAnthropicMessageId
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AnthropicMessageRequest'
      responses:
        '200':
          description: >-
            Respons Anthropic Message 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/AnthropicMessageResponse'
        '400':
          description: Permintaan tidak valid atau opsi ditolak oleh rute model.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AnthropicErrorResponse'
        '401':
          description: API key hilang, tidak valid, telah dicabut, atau kedaluwarsa.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AnthropicErrorResponse'
        '402':
          description: >-
            Saldo kredit workspace habis atau batas pengeluaran bulanan
            tercapai.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AnthropicErrorResponse'
        '403':
          description: >-
            IP pemanggil tidak diizinkan, model relay dinonaktifkan, atau akun
            pemilik workspace sedang ditangguhkan.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AnthropicErrorResponse'
        '404':
          description: ID model tidak ditemukan di katalog aktif.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AnthropicErrorResponse'
        '429':
          description: Anggaran RPM, ITPM, atau OTPM per menit terlampaui.
          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/AnthropicErrorResponse'
        '502':
          description: Galat upstream atau stream terputus.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AnthropicErrorResponse'
        '503':
          description: >-
            Rute model belum dikonfigurasi atau backend sementara tidak dapat
            dihubungi.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AnthropicErrorResponse'
      security:
        - AnthropicKeyAuth: []
        - BearerAuth: []
components:
  schemas:
    AnthropicMessageRequest:
      type: object
      required:
        - model
        - max_tokens
        - 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.
        max_tokens:
          type: integer
          minimum: 1
          example: 1024
        system:
          oneOf:
            - type: string
            - type: array
              items:
                type: object
                additionalProperties: true
        stream:
          type: boolean
          default: false
        temperature:
          type: number
        top_p:
          type: number
        stop_sequences:
          type: array
          items:
            type: string
        messages:
          type: array
          items:
            type: object
            required:
              - role
              - content
            properties:
              role:
                type: string
                enum:
                  - user
                  - assistant
              content:
                oneOf:
                  - type: string
                  - type: array
                    items:
                      type: object
                      additionalProperties: true
      additionalProperties: true
    AnthropicMessageResponse:
      type: object
      properties:
        id:
          type: string
        type:
          type: string
          example: message
        role:
          type: string
          example: assistant
        model:
          type: string
          example: deepseek-ai/DeepSeek-V4.1-Flash-1017
        content:
          type: array
          items:
            type: object
            properties:
              type:
                type: string
                example: text
              text:
                type: string
        stop_reason:
          type:
            - string
            - 'null'
        stop_sequence:
          type:
            - string
            - 'null'
        usage:
          type: object
          properties:
            input_tokens:
              type: integer
            cache_read_input_tokens:
              type: integer
            output_tokens:
              type: integer
    AnthropicErrorResponse:
      type: object
      properties:
        type:
          type: string
          example: error
        error:
          type: object
          properties:
            type:
              type: string
              example: invalid_request_error
            message:
              type: string
        request_id:
          type:
            - string
            - 'null'
          format: uuid
  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`).'
    AnthropicKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: 'API key workspace CerasAI (`x-api-key: $CERASAI_API_KEY`).'

````

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