---
title: "Anthropic Messages"
method: POST
path: "/v1/messages"
---

# Anthropic Messages

`POST /v1/messages`

Create a message using Anthropic's API format

## Request body

- object
  - `model` string, required — The model to use for completion
  - `messages` object[], required — Array of message objects
    - `role` 'system' | 'developer' | 'user' | 'assistant' | 'tool' | 'function', required
    - `content` union, required
      - string
      - union[]
        - union
          - object
            - `type` 'text', required
            - `text` string, required
            - `cache_control` object
              - …
          - object
            - `type` 'image', required
            - `source` object, required
              - …
          - object
            - `type` 'tool_use', required
            - `id` string, required
            - `name` string, required
            - `input` object, required
          - object
            - `type` 'tool_result', required
            - `tool_use_id` string, required
            - `content` union
              - …
            - `is_error` boolean
            - `cache_control` object
              - …
          - object
            - `type` 'thinking', required
            - `thinking` string, required
            - `signature` string
          - object
            - `type` 'redacted_thinking', required
            - `data` string, required
          - object
            - `type` 'server_tool_use', required
            - `id` string, required
            - `name` string, required
            - `input` object
          - object
            - `type` 'web_search_tool_result', required
            - `tool_use_id` string, required
            - `content` union
              - …
          - object
            - `type` 'tool_search_tool_result', required
            - `tool_use_id` string, required
            - `content` object
    - `tool_call_id` string
    - `name` string
    - `tool_calls` object[]
      - `id` string, required
      - `type` 'function', required
      - `function` object, required
        - `name` string, required
        - `arguments` string, required
    - `function_call` object
      - `id` string
      - `name` string, required
      - `arguments` union, required
        - string
        - object
  - `max_tokens` number, required — Maximum number of tokens to generate
  - `system` union — System prompt to provide context
    - string
    - object[]
      - `type` 'text', required
      - `text` string, required
      - `cache_control` object
        - `type` 'ephemeral', required
        - `ttl` '5m' | '1h'
  - `temperature` number — Sampling temperature between 0 and 1
  - `tools` union[] — Available tools for the model to use
    - union
      - object
        - `type` 'custom'
        - `name` string, required
        - `description` string
        - `input_schema` object, required
        - `cache_control` object, nullable
          - `type` 'ephemeral', required
          - `ttl` '5m' | '1h'
        - `defer_loading` boolean
      - object
        - `type` string, required
        - `name` string
      - object
        - `type` string, required
        - `name` string, required
        - `max_uses` number
        - `allowed_domains` string[]
        - `blocked_domains` string[]
        - `user_location` object
          - `type` 'approximate'
          - `city` string
          - `region` string
          - `country` string
          - `timezone` string
        - `cache_control` object, nullable
          - `type` 'ephemeral', required
          - `ttl` '5m' | '1h'
  - `stream` boolean — Whether to stream the response
  - `metadata` object — Anthropic request metadata. Claude Code embeds the session id in user_id, which the gateway uses for sticky routing.
    - `user_id` string
  - `thinking` object — Anthropic extended-thinking configuration. Mapped onto the gateway's unified reasoning controls so the requested effort reaches the provider.
    - `type` string, required
    - `budget_tokens` integer
  - `output_config` object — Anthropic output configuration. `effort` controls adaptive reasoning depth on Opus 4.7+ models.
    - `effort` 'none' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh' | 'max'

## Response `200`

Successful response

- object
  - `id` string, required
  - `type` 'message', required
  - `role` 'assistant', required
  - `model` string, required
  - `content` object[], required
    - `type` 'text' | 'tool_use' | 'thinking' | 'server_tool_use' | 'web_search_tool_result' | 'tool_search_tool_result', required
    - `text` string
    - `thinking` string
    - `id` string
    - `name` string
    - `input` object
    - `tool_use_id` string
    - `content` union
      - unknown[]
        - unknown
      - object
  - `stop_reason` 'end_turn' | 'max_tokens' | 'stop_sequence' | 'tool_use' | 'pause_turn' | 'refusal', nullable, required
  - `stop_sequence` string, nullable, required
  - `usage` object, required
    - `input_tokens` number, required
    - `output_tokens` number, required
    - `cache_creation_input_tokens` number
    - `cache_read_input_tokens` number
    - `cache_creation` object
      - `ephemeral_5m_input_tokens` number, required
      - `ephemeral_1h_input_tokens` number, required

## Other responses

- `400` — Invalid request body or parameters.
- `401` — Missing or invalid API key.
- `402` — Insufficient credits or plan limits reached.
- `403` — Forbidden request or upstream response.
- `404` — Unknown model or upstream not-found response.
- `410` — Archived or unavailable project.
- `429` — Rate limited (organization, endpoint, or upstream provider). Back off until Retry-After elapses.
- `500` — Internal server error.
- `502` — Failed to connect to the upstream provider.
- `503` — Service unavailable upstream response.
- `504` — Upstream provider timeout.

---

[API](https://skmtc.dev/llmgateway/apis/llmgateway-api.md) · [All operations](https://skmtc.dev/llmgateway/apis/llmgateway-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/llmgateway/llmgateway-api/revisions/aaf167e3d8cc/schema)
