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

# Anthropic Messages

`POST /v1/messages`

Send structured messages to Claude models using the Anthropic native API format. Supports text and multimodal inputs, multi-turn conversations, adaptive thinking, tool use, prompt caching, streaming, and web search. Use this endpoint when you need Claude-specific features like adaptive thinking or prompt caching that are not available through the OpenAI-compatible endpoint.

## Headers

- `anthropic-version` string
- `anthropic-beta` string

## Request body

- object
  - `model` string, required — The Claude model to use. See the [Models page](/overview/models) for available Claude model IDs.
  - `messages` object[], required — The conversation messages. Must alternate between `user` and `assistant` roles. Each message's `content` can be a string or an array of content blocks (text, image, document, tool_use, tool_result). There is a limit of 100,000 messages per request.
    - `role` 'user' | 'assistant', required — The role of the message author.
    - `content` union, required — The message content. Either a plain string or an array of content blocks for multimodal input.
      - string
      - object[]
        - `type` 'text' | 'image' | 'document' | 'tool_use' | 'tool_result' — The content block type.
        - `text` string — Text content (for `text` type blocks).
        - `source` object — Source data for `image` or `document` blocks.
          - `type` 'base64' | 'url' — Image source type: `url` for a public image URL, or `base64` for inline data.
          - `media_type` string — Image MIME type for base64 sources, such as `image/jpeg` or `image/png`.
          - `data` string — Base64-encoded image bytes when `type` is `base64`.
          - `url` string — Public HTTPS image URL when `type` is `url`. The provider must be able to download it.
        - `cache_control` object — Cache control for prompt caching. Set `{"type": "ephemeral"}` to cache this content block.
          - `type` 'ephemeral' — Cache control type. Use `ephemeral`.
          - `ttl` string — Cache TTL. Options: `ephemeral_5m` (5 min), `ephemeral_1h` (1 hour).
  - `max_tokens` integer, required — The maximum number of tokens to generate. The model may stop before reaching this limit. When using `thinking`, the thinking tokens count towards this limit.
  - `system` union — System prompt providing context and instructions to Claude. Can be a plain string or an array of content blocks (useful for prompt caching).
    - string
    - object[]
      - `type` 'text' — Content block type, `text`.
      - `text` string — System prompt text for this block.
      - `cache_control` object — Marks this system block as a prompt-cache breakpoint.
        - `type` 'ephemeral' — Cache control type. Use `ephemeral`.
  - `temperature` number — Model-dependent sampling control. Many newer Claude models reject non-default `temperature` values on the Messages API. Omit this field unless you have verified that the selected model accepts it; if the model returns an unsupported or deprecated-parameter error, remove the field instead of substituting another sampling value.
  - `top_p` number — Model-dependent nucleus sampling control. Many newer Claude models reject non-default `top_p` values on the Messages API. Omit this field unless you have verified support for the selected model. Do not set `temperature` and `top_p` together.
  - `top_k` integer — Model-dependent top-k sampling control. Many newer Claude models reject non-default `top_k` values on the Messages API. Omit this field unless you have verified support for the selected model.
  - `stream` boolean — If `true`, stream the response incrementally using Server-Sent Events (SSE). Events include `message_start`, `content_block_start`, `content_block_delta`, `content_block_stop`, `message_delta`, and `message_stop`.
  - `stop_sequences` string[] — Custom strings that cause the model to stop generating when encountered. The stop sequence is not included in the response.
  - `thinking` object — Controls Claude thinking when the selected model supports a configurable thinking mode. For newer adaptive-thinking models, use `{"type":"adaptive"}` with `output_config.effort`, or omit `thinking` when adaptive thinking is already the model default. Manual `{"type":"enabled","budget_tokens":...}` is supported only by older models and is rejected by newer Claude models.
    - `type` 'adaptive' | 'disabled' | 'enabled' — Thinking mode. `adaptive` lets the model decide when and how much to think. `disabled` turns thinking off only on models that support disabling it. `enabled` is the legacy manual-budget mode and is rejected by newer Claude models.
    - `budget_tokens` integer — Legacy manual-thinking token budget. Minimum: 1,024 when accepted. These tokens count toward `max_tokens`. Do not send this field to newer adaptive-thinking models that reject manual thinking budgets.
    - `display` 'summarized' | 'omitted' — Controls visible thinking blocks on models that support display selection. `summarized` returns a readable thinking summary; `omitted` returns an empty thinking field with continuity metadata where applicable.
  - `tools` object[] — Tools the model may use. Supports client-defined functions, web search (`web_search_20250305`), web fetch (`web_fetch_20250910`), code execution (`code_execution_20250522`), and more.
    - `name` string — Tool name. The model repeats it in `tool_use` blocks when it calls the tool.
    - `description` string — A description of what the tool does.
    - `input_schema` object — JSON Schema defining the tool's input parameters.
    - `type` string — The tool type. Required for server tools (e.g., `web_search_20250305`, `web_fetch_20250910`, `code_execution_20250522`).
    - `max_uses` integer — Maximum number of times this tool can be used in a single request.
  - `tool_choice` object — Controls how the model uses tools.
    - `type` 'auto' | 'any' | 'tool' | 'none' — The tool choice mode: `auto` (model decides), `any` (must use a tool), `tool` (must use a specific tool), or `none` (no tools).
    - `name` string — The specific tool name to use. Required when `type` is `tool`.
    - `disable_parallel_tool_use` boolean — If `true`, prevent the model from calling multiple tools in parallel.
  - `metadata` object — Request metadata for tracking and analytics.
    - `user_id` string — An external identifier for the user making the request. Used for abuse detection.
  - `output_config` object — Configuration for response effort and output format. Field support depends on the selected Claude model.
    - `effort` 'low' | 'medium' | 'high' | 'xhigh' | 'max' — Controls how much effort Claude applies to the response. `high` is the default for newer effort-capable models. Use `low` or `medium` for lower latency and cost, `xhigh` for advanced coding or agentic work when supported, and `max` only for the hardest tasks with a large `max_tokens` value.
    - `format` object — Structured output configuration. Use `{"type":"json","schema":{...}}` to ask for JSON that matches your schema when the selected model supports structured output.
  - `service_tier` 'auto' | 'standard_only' — The service tier to use. `auto` tries priority capacity first, `standard_only` uses only standard capacity.

## Response `200`

Successful response. When `stream` is `true`, the response is a stream of SSE events.

- object
  - `id` string — Unique identifier for this message (e.g., `msg_01XFDUDYJgAACzvnptvVoYEL`).
  - `type` 'message' — Always `message`.
  - `role` 'assistant' — Always `assistant`.
  - `content` object[] — The response content blocks. May include `text`, `thinking`, `tool_use`, and other block types.
    - `type` 'text' | 'thinking' | 'tool_use' — The content block type.
    - `text` string — The generated text (for `text` blocks).
    - `thinking` string — Thinking text or summary for `thinking` blocks when the selected model returns visible thinking content.
    - `signature` string — Cryptographic signature for the thinking block.
    - `id` string — Tool use ID (for `tool_use` blocks).
    - `name` string — Tool name (for `tool_use` blocks).
    - `input` object — Tool input arguments (for `tool_use` blocks).
  - `model` string — The specific model version that generated this response, such as `claude-sonnet-5`.
  - `stop_reason` 'end_turn' | 'max_tokens' | 'stop_sequence' | 'tool_use' | 'pause_turn' | 'refusal' — Why the model stopped generating. `refusal` can be returned as a successful HTTP response when the model declines a request.
  - `stop_sequence` string, nullable — The stop sequence that caused the model to stop, if applicable.
  - `usage` object — Token usage statistics.
    - `input_tokens` integer — Number of input tokens (prompt + conversation history).
    - `output_tokens` integer — Number of output tokens generated.
    - `cache_creation_input_tokens` integer — Number of input tokens used to create the prompt cache.
    - `cache_read_input_tokens` integer — Number of input tokens read from the prompt cache.
    - `cache_creation` object — Detailed cache creation token breakdown by TTL tier.
      - `ephemeral_5m_input_tokens` integer — Tokens written to 5-minute ephemeral cache.
      - `ephemeral_1h_input_tokens` integer — Tokens written to 1-hour ephemeral cache.
    - `output_tokens_details` object — Detailed output token breakdown when returned by the selected model.
      - `thinking_tokens` integer — Number of output tokens used for model thinking when reported.

---

[API](https://skmtc.net/cometapi/apis/create-api-key.md) · [All operations](https://skmtc.net/cometapi/apis/create-api-key/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/cometapi/create-api-key/versions/0863102dbf34/schema)
