---
title: "Create a Message"
method: POST
path: "/v1/messages"
---

# Create a Message

`POST /v1/messages`

Send a structured list of input messages with text and/or image content, and the model will generate the next message in the conversation.

The Messages API can be used for either single queries or stateless multi-turn conversations.

Learn more about the Messages API in our [user guide](https://docs.claude.com/en/docs/initial-setup)

## Headers

- `anthropic-version` string — The version of the Claude API you want to use. Read more about versioning and our version history [here](https://docs.claude.com/en/api/versioning).

## Request body

- CreateMessageParams
  - `model` union, required — The model that will complete your prompt.\n\nSee [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.
    - string
    - 'claude-opus-4-6' — Most intelligent model for building agents and coding
    - 'claude-sonnet-4-6' — Best combination of speed and intelligence
    - 'claude-haiku-4-5' — Fastest model with near-frontier intelligence
    - 'claude-haiku-4-5-20251001' — Fastest model with near-frontier intelligence
    - 'claude-opus-4-5' — Premium model combining maximum intelligence with practical performance
    - 'claude-opus-4-5-20251101' — Premium model combining maximum intelligence with practical performance
    - 'claude-sonnet-4-5' — High-performance model for agents and coding
    - 'claude-sonnet-4-5-20250929' — High-performance model for agents and coding
    - 'claude-opus-4-1' — Exceptional model for specialized complex tasks
    - 'claude-opus-4-1-20250805' — Exceptional model for specialized complex tasks
    - 'claude-opus-4-0' — Powerful model for complex tasks
    - 'claude-opus-4-20250514' — Powerful model for complex tasks
    - 'claude-sonnet-4-0' — High-performance model with extended thinking
    - 'claude-sonnet-4-20250514' — High-performance model with extended thinking
    - 'claude-3-haiku-20240307' — Fast and cost-effective model
  - `messages` InputMessage[], required — Input messages. Our models are trained to operate on alternating `user` and `assistant` conversational turns. When creating a new `Message`, you specify the prior conversational turns with the `messages` parameter, and the model then generates the next `Message` in the conversation. Consecutive `user` or `assistant` turns in your request will be combined into a single turn. Each input message must be an object with a `role` and `content`. You can specify a single `user`-role message, or you can include multiple `user` and `assistant` messages. If the final message uses the `assistant` role, the response content will continue immediately from the content in that message. This can be used to constrain part of the model's response. Example with a single `user` message: ```json [{"role": "user", "content": "Hello, Claude"}] ``` Example with multiple conversational turns: ```json [ {"role": "user", "content": "Hello there."}, {"role": "assistant", "content": "Hi, I'm Claude. How can I help you?"}, {"role": "user", "content": "Can you explain LLMs in plain English?"}, ] ``` Example with a partially-filled response from Claude: ```json [ {"role": "user", "content": "What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun"}, {"role": "assistant", "content": "The best answer is ("}, ] ``` Each input message `content` may be either a single `string` or an array of content blocks, where each block has a specific `type`. Using a `string` for `content` is shorthand for an array of one content block of type `"text"`. The following input messages are equivalent: ```json {"role": "user", "content": "Hello, Claude"} ``` ```json {"role": "user", "content": [{"type": "text", "text": "Hello, Claude"}]} ``` See [input examples](https://docs.claude.com/en/api/messages-examples). Note that if you want to include a [system prompt](https://docs.claude.com/en/docs/system-prompts), you can use the top-level `system` parameter — there is no `"system"` role for input messages in the Messages API. There is a limit of 100,000 messages in a single request.
    - `content` union, required
      - string
      - InputContentBlock[]
        - union
          - object
            - `cache_control` CacheControlEphemeral
              - …
            - `citations` union[], nullable
              - …
            - `text` string, required
            - `type` 'text', required
          - object
            - `cache_control` CacheControlEphemeral
              - …
            - `source` union, required
              - …
            - `type` 'image', required
          - object
            - `cache_control` CacheControlEphemeral
              - …
            - `citations` RequestCitationsConfig
              - …
            - `context` string, nullable
            - `source` union, required
              - …
            - `title` string, nullable
            - `type` 'document', required
          - object
            - `cache_control` CacheControlEphemeral
              - …
            - `citations` RequestCitationsConfig
              - …
            - `content` RequestTextBlock[], required
              - …
            - `source` string, required
            - `title` string, required
            - `type` 'search_result', required
          - object
            - `signature` string, required
            - `thinking` string, required
            - `type` 'thinking', required
          - object
            - `data` string, required
            - `type` 'redacted_thinking', required
          - object
            - `cache_control` CacheControlEphemeral
              - …
            - `caller` union
              - …
            - `id` string, required
            - `input` object, required
            - `name` string, required
            - `type` 'tool_use', required
          - object
            - `cache_control` CacheControlEphemeral
              - …
            - `content` union
              - …
            - `is_error` boolean
            - `tool_use_id` string, required
            - `type` 'tool_result', required
          - object
            - `cache_control` CacheControlEphemeral
              - …
            - `caller` union
              - …
            - `id` string, required
            - `input` object, required
            - `name` 'web_search' | 'web_fetch' | 'code_execution' | 'bash_code_execution' | 'text_editor_code_execution' | 'tool_search_tool_regex' | 'tool_search_tool_bm25', required
            - `type` 'server_tool_use', required
          - object
            - `cache_control` CacheControlEphemeral
              - …
            - `caller` union
              - …
            - `content` union, required
              - …
            - `tool_use_id` string, required
            - `type` 'web_search_tool_result', required
          - object
            - `cache_control` CacheControlEphemeral
              - …
            - `caller` union
              - …
            - `content` union, required
              - …
            - `tool_use_id` string, required
            - `type` 'web_fetch_tool_result', required
          - object
            - `cache_control` CacheControlEphemeral
              - …
            - `content` union, required
              - …
            - `tool_use_id` string, required
            - `type` 'code_execution_tool_result', required
          - object
            - `cache_control` CacheControlEphemeral
              - …
            - `content` union, required
              - …
            - `tool_use_id` string, required
            - `type` 'bash_code_execution_tool_result', required
          - object
            - `cache_control` CacheControlEphemeral
              - …
            - `content` union, required
              - …
            - `tool_use_id` string, required
            - `type` 'text_editor_code_execution_tool_result', required
          - object
            - `cache_control` CacheControlEphemeral
              - …
            - `content` union, required
              - …
            - `tool_use_id` string, required
            - `type` 'tool_search_tool_result', required
          - object — A content block that represents a file to be uploaded to the container Files uploaded via this block will be available in the container's input directory.
            - `cache_control` CacheControlEphemeral
              - …
            - `file_id` string, required
            - `type` 'container_upload', required
    - `role` 'user' | 'assistant', required
  - `cache_control` CacheControlEphemeral
    - `ttl` '5m' | '1h' — The time-to-live for the cache control breakpoint. This may be one the following values: - `5m`: 5 minutes - `1h`: 1 hour Defaults to `5m`.
    - `type` 'ephemeral', required
  - `container` string, nullable — Container identifier for reuse across requests.
  - `inference_geo` string, nullable — Specifies the geographic region for inference processing. If not specified, the workspace's `default_inference_geo` is used.
  - `max_tokens` integer, required — The maximum number of tokens to generate before stopping. Note that our models may stop _before_ reaching this maximum. This parameter only specifies the absolute maximum number of tokens to generate. Different models have different maximum values for this parameter. See [models](https://docs.claude.com/en/docs/models-overview) for details.
  - `metadata` Metadata
    - `user_id` string, nullable — An external identifier for the user who is associated with the request. This should be a uuid, hash value, or other opaque identifier. Anthropic may use this id to help detect abuse. Do not include any identifying information such as name, email address, or phone number.
  - `output_config` OutputConfig
    - `effort` 'low' | 'medium' | 'high' | 'max' — All possible effort levels.
    - `format` JsonOutputFormat
      - `schema` object, required — The JSON schema of the format
      - `type` 'json_schema', required
  - `service_tier` 'auto' | 'standard_only' — Determines whether to use priority capacity (if available) or standard capacity for this request. Anthropic offers different levels of service for your API requests. See [service-tiers](https://docs.claude.com/en/api/service-tiers) for details.
  - `stop_sequences` string[] — Custom text sequences that will cause the model to stop generating. Our models will normally stop when they have naturally completed their turn, which will result in a response `stop_reason` of `"end_turn"`. If you want the model to stop generating when it encounters custom strings of text, you can use the `stop_sequences` parameter. If the model encounters one of the custom sequences, the response `stop_reason` value will be `"stop_sequence"` and the response `stop_sequence` value will contain the matched stop sequence.
  - `stream` boolean — Whether to incrementally stream the response using server-sent events. See [streaming](https://docs.claude.com/en/api/messages-streaming) for details.
  - `system` union — System prompt. A system prompt is a way of providing context and instructions to Claude, such as specifying a particular goal or role. See our [guide to system prompts](https://docs.claude.com/en/docs/system-prompts).
    - string
    - RequestTextBlock[]
      - `cache_control` CacheControlEphemeral
        - `ttl` '5m' | '1h' — The time-to-live for the cache control breakpoint. This may be one the following values: - `5m`: 5 minutes - `1h`: 1 hour Defaults to `5m`.
        - `type` 'ephemeral', required
      - `citations` union[], nullable
        - union
          - RequestCharLocationCitation
            - `cited_text` string, required
            - `document_index` integer, required
            - `document_title` string, nullable, required
            - `end_char_index` integer, required
            - `start_char_index` integer, required
            - `type` 'char_location', required
          - RequestPageLocationCitation
            - `cited_text` string, required
            - `document_index` integer, required
            - `document_title` string, nullable, required
            - `end_page_number` integer, required
            - `start_page_number` integer, required
            - `type` 'page_location', required
          - RequestContentBlockLocationCitation
            - `cited_text` string, required
            - `document_index` integer, required
            - `document_title` string, nullable, required
            - `end_block_index` integer, required
            - `start_block_index` integer, required
            - `type` 'content_block_location', required
          - RequestWebSearchResultLocationCitation
            - `cited_text` string, required
            - `encrypted_index` string, required
            - `title` string, nullable, required
            - `type` 'web_search_result_location', required
            - `url` string, required
          - RequestSearchResultLocationCitation
            - `cited_text` string, required
            - `end_block_index` integer, required
            - `search_result_index` integer, required
            - `source` string, required
            - `start_block_index` integer, required
            - `title` string, nullable, required
            - `type` 'search_result_location', required
      - `text` string, required
      - `type` 'text', required
  - `temperature` number — Amount of randomness injected into the response. Defaults to `1.0`. Ranges from `0.0` to `1.0`. Use `temperature` closer to `0.0` for analytical / multiple choice, and closer to `1.0` for creative and generative tasks. Note that even with `temperature` of `0.0`, the results will not be fully deterministic.
  - `thinking` union — Configuration for enabling Claude's extended thinking. When enabled, responses include `thinking` content blocks showing Claude's thinking process before the final answer. Requires a minimum budget of 1,024 tokens and counts towards your `max_tokens` limit. See [extended thinking](https://docs.claude.com/en/docs/build-with-claude/extended-thinking) for details.
    - ThinkingConfigEnabled
      - `budget_tokens` integer, required — Determines how many tokens Claude can use for its internal reasoning process. Larger budgets can enable more thorough analysis for complex problems, improving response quality. Must be ≥1024 and less than `max_tokens`. See [extended thinking](https://docs.claude.com/en/docs/build-with-claude/extended-thinking) for details.
      - `display` 'summarized' | 'omitted'
      - `type` 'enabled', required
    - ThinkingConfigDisabled
      - `type` 'disabled', required
    - ThinkingConfigAdaptive
      - `display` 'summarized' | 'omitted'
      - `type` 'adaptive', required
  - `tool_choice` union — How the model should use the provided tools. The model can use a specific tool, any available tool, decide by itself, or not use tools at all.
    - ToolChoiceAuto — The model will automatically decide whether to use tools.
      - `disable_parallel_tool_use` boolean — Whether to disable parallel tool use. Defaults to `false`. If set to `true`, the model will output at most one tool use.
      - `type` 'auto', required
    - ToolChoiceAny — The model will use any available tools.
      - `disable_parallel_tool_use` boolean — Whether to disable parallel tool use. Defaults to `false`. If set to `true`, the model will output exactly one tool use.
      - `type` 'any', required
    - ToolChoiceTool — The model will use the specified tool with `tool_choice.name`.
      - `disable_parallel_tool_use` boolean — Whether to disable parallel tool use. Defaults to `false`. If set to `true`, the model will output exactly one tool use.
      - `name` string, required — The name of the tool to use.
      - `type` 'tool', required
    - ToolChoiceNone — The model will not be allowed to use tools.
      - `type` 'none', required
  - `tools` union[] — Definitions of tools that the model may use. If you include `tools` in your API request, the model may return `tool_use` content blocks that represent the model's use of those tools. You can then run those tools using the tool input generated by the model and then optionally return results back to the model using `tool_result` content blocks. There are two types of tools: **client tools** and **server tools**. The behavior described below applies to client tools. For [server tools](https://docs.claude.com/en/docs/agents-and-tools/tool-use/overview\#server-tools), see their individual documentation as each has its own behavior (e.g., the [web search tool](https://docs.claude.com/en/docs/agents-and-tools/tool-use/web-search-tool)). Each tool definition includes: * `name`: Name of the tool. * `description`: Optional, but strongly-recommended description of the tool. * `input_schema`: [JSON schema](https://json-schema.org/draft/2020-12) for the tool `input` shape that the model will produce in `tool_use` output content blocks. For example, if you defined `tools` as: ```json [ { "name": "get_stock_price", "description": "Get the current stock price for a given ticker symbol.", "input_schema": { "type": "object", "properties": { "ticker": { "type": "string", "description": "The stock ticker symbol, e.g. AAPL for Apple Inc." } }, "required": ["ticker"] } } ] ``` And then asked the model "What's the S&P 500 at today?", the model might produce `tool_use` content blocks in the response like this: ```json [ { "type": "tool_use", "id": "toolu_01D7FLrfh4GYq7yT1ULFeyMV", "name": "get_stock_price", "input": { "ticker": "^GSPC" } } ] ``` You might then run your `get_stock_price` tool with `{"ticker": "^GSPC"}` as an input, and return the following back to the model in a subsequent `user` message: ```json [ { "type": "tool_result", "tool_use_id": "toolu_01D7FLrfh4GYq7yT1ULFeyMV", "content": "259.75 USD" } ] ``` Tools can be used for workflows that include running client-side tools and functions, or more generally whenever you want the model to produce a particular JSON structure of output. See our [guide](https://docs.claude.com/en/docs/tool-use) for more details.
    - union
      - Tool
        - `type` 'custom', nullable
        - `description` string — Description of what this tool does. Tool descriptions should be as detailed as possible. The more information that the model has about what the tool is and how to use it, the better it will perform. You can use natural language descriptions to reinforce important aspects of the tool input JSON schema.
        - `name` string, required — Name of the tool. This is how the tool will be called by the model and in `tool_use` blocks.
        - `input_schema` InputSchema, required
          - `properties` object, nullable
          - `required` string[], nullable
          - `type` 'object', required
        - `cache_control` CacheControlEphemeral
          - `ttl` '5m' | '1h' — The time-to-live for the cache control breakpoint. This may be one the following values: - `5m`: 5 minutes - `1h`: 1 hour Defaults to `5m`.
          - `type` 'ephemeral', required
        - `strict` boolean — When true, guarantees schema validation on tool names and inputs
        - `eager_input_streaming` boolean, nullable — Enable eager input streaming for this tool. When true, tool input parameters will be streamed incrementally as they are generated, and types will be inferred on-the-fly rather than buffering the full JSON output. When false, streaming is disabled for this tool even if the fine-grained-tool-streaming beta is active. When null (default), uses the default behavior based on beta headers.
        - `allowed_callers` AllowedCaller[]
        - `defer_loading` boolean — If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.
        - `input_examples` object[]
      - BashTool20250124
        - `allowed_callers` AllowedCaller[]
        - `cache_control` CacheControlEphemeral
          - `ttl` '5m' | '1h' — The time-to-live for the cache control breakpoint. This may be one the following values: - `5m`: 5 minutes - `1h`: 1 hour Defaults to `5m`.
          - `type` 'ephemeral', required
        - `defer_loading` boolean — If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.
        - `input_examples` object[]
        - `name` 'bash', required — Name of the tool. This is how the tool will be called by the model and in `tool_use` blocks.
        - `strict` boolean — When true, guarantees schema validation on tool names and inputs
        - `type` 'bash_20250124', required
      - CodeExecutionTool20250522
        - `allowed_callers` AllowedCaller[]
        - `cache_control` CacheControlEphemeral
          - `ttl` '5m' | '1h' — The time-to-live for the cache control breakpoint. This may be one the following values: - `5m`: 5 minutes - `1h`: 1 hour Defaults to `5m`.
          - `type` 'ephemeral', required
        - `defer_loading` boolean — If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.
        - `name` 'code_execution', required — Name of the tool. This is how the tool will be called by the model and in `tool_use` blocks.
        - `strict` boolean — When true, guarantees schema validation on tool names and inputs
        - `type` 'code_execution_20250522', required
      - CodeExecutionTool20250825
        - `allowed_callers` AllowedCaller[]
        - `cache_control` CacheControlEphemeral
          - `ttl` '5m' | '1h' — The time-to-live for the cache control breakpoint. This may be one the following values: - `5m`: 5 minutes - `1h`: 1 hour Defaults to `5m`.
          - `type` 'ephemeral', required
        - `defer_loading` boolean — If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.
        - `name` 'code_execution', required — Name of the tool. This is how the tool will be called by the model and in `tool_use` blocks.
        - `strict` boolean — When true, guarantees schema validation on tool names and inputs
        - `type` 'code_execution_20250825', required
      - CodeExecutionTool20260120 — Code execution tool with REPL state persistence (daemon mode + gVisor checkpoint).
        - `allowed_callers` AllowedCaller[]
        - `cache_control` CacheControlEphemeral
          - `ttl` '5m' | '1h' — The time-to-live for the cache control breakpoint. This may be one the following values: - `5m`: 5 minutes - `1h`: 1 hour Defaults to `5m`.
          - `type` 'ephemeral', required
        - `defer_loading` boolean — If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.
        - `name` 'code_execution', required — Name of the tool. This is how the tool will be called by the model and in `tool_use` blocks.
        - `strict` boolean — When true, guarantees schema validation on tool names and inputs
        - `type` 'code_execution_20260120', required
      - MemoryTool20250818
        - `allowed_callers` AllowedCaller[]
        - `cache_control` CacheControlEphemeral
          - `ttl` '5m' | '1h' — The time-to-live for the cache control breakpoint. This may be one the following values: - `5m`: 5 minutes - `1h`: 1 hour Defaults to `5m`.
          - `type` 'ephemeral', required
        - `defer_loading` boolean — If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.
        - `input_examples` object[]
        - `name` 'memory', required — Name of the tool. This is how the tool will be called by the model and in `tool_use` blocks.
        - `strict` boolean — When true, guarantees schema validation on tool names and inputs
        - `type` 'memory_20250818', required
      - TextEditor20250124
        - `allowed_callers` AllowedCaller[]
        - `cache_control` CacheControlEphemeral
          - `ttl` '5m' | '1h' — The time-to-live for the cache control breakpoint. This may be one the following values: - `5m`: 5 minutes - `1h`: 1 hour Defaults to `5m`.
          - `type` 'ephemeral', required
        - `defer_loading` boolean — If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.
        - `input_examples` object[]
        - `name` 'str_replace_editor', required — Name of the tool. This is how the tool will be called by the model and in `tool_use` blocks.
        - `strict` boolean — When true, guarantees schema validation on tool names and inputs
        - `type` 'text_editor_20250124', required
      - TextEditor20250429
        - `allowed_callers` AllowedCaller[]
        - `cache_control` CacheControlEphemeral
          - `ttl` '5m' | '1h' — The time-to-live for the cache control breakpoint. This may be one the following values: - `5m`: 5 minutes - `1h`: 1 hour Defaults to `5m`.
          - `type` 'ephemeral', required
        - `defer_loading` boolean — If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.
        - `input_examples` object[]
        - `name` 'str_replace_based_edit_tool', required — Name of the tool. This is how the tool will be called by the model and in `tool_use` blocks.
        - `strict` boolean — When true, guarantees schema validation on tool names and inputs
        - `type` 'text_editor_20250429', required
      - TextEditor20250728
        - `allowed_callers` AllowedCaller[]
        - `cache_control` CacheControlEphemeral
          - `ttl` '5m' | '1h' — The time-to-live for the cache control breakpoint. This may be one the following values: - `5m`: 5 minutes - `1h`: 1 hour Defaults to `5m`.
          - `type` 'ephemeral', required
        - `defer_loading` boolean — If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.
        - `input_examples` object[]
        - `max_characters` integer, nullable — Maximum number of characters to display when viewing a file. If not specified, defaults to displaying the full file.
        - `name` 'str_replace_based_edit_tool', required — Name of the tool. This is how the tool will be called by the model and in `tool_use` blocks.
        - `strict` boolean — When true, guarantees schema validation on tool names and inputs
        - `type` 'text_editor_20250728', required
      - WebSearchTool20250305
        - `allowed_callers` AllowedCaller[]
        - `allowed_domains` string[], nullable — If provided, only these domains will be included in results. Cannot be used alongside `blocked_domains`.
        - `blocked_domains` string[], nullable — If provided, these domains will never appear in results. Cannot be used alongside `allowed_domains`.
        - `cache_control` CacheControlEphemeral
          - `ttl` '5m' | '1h' — The time-to-live for the cache control breakpoint. This may be one the following values: - `5m`: 5 minutes - `1h`: 1 hour Defaults to `5m`.
          - `type` 'ephemeral', required
        - `defer_loading` boolean — If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.
        - `max_uses` integer, nullable — Maximum number of times the tool can be used in the API request.
        - `name` 'web_search', required — Name of the tool. This is how the tool will be called by the model and in `tool_use` blocks.
        - `strict` boolean — When true, guarantees schema validation on tool names and inputs
        - `type` 'web_search_20250305', required
        - `user_location` UserLocation
          - `city` string, nullable — The city of the user.
          - `country` string, nullable — The two letter [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) of the user.
          - `region` string, nullable — The region of the user.
          - `timezone` string, nullable — The [IANA timezone](https://nodatime.org/TimeZones) of the user.
          - `type` 'approximate', required
      - WebFetchTool20250910
        - `allowed_callers` AllowedCaller[]
        - `allowed_domains` string[], nullable — List of domains to allow fetching from
        - `blocked_domains` string[], nullable — List of domains to block fetching from
        - `cache_control` CacheControlEphemeral
          - `ttl` '5m' | '1h' — The time-to-live for the cache control breakpoint. This may be one the following values: - `5m`: 5 minutes - `1h`: 1 hour Defaults to `5m`.
          - `type` 'ephemeral', required
        - `citations` RequestCitationsConfig
          - `enabled` boolean
        - `defer_loading` boolean — If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.
        - `max_content_tokens` integer, nullable — Maximum number of tokens used by including web page text content in the context. The limit is approximate and does not apply to binary content such as PDFs.
        - `max_uses` integer, nullable — Maximum number of times the tool can be used in the API request.
        - `name` 'web_fetch', required — Name of the tool. This is how the tool will be called by the model and in `tool_use` blocks.
        - `strict` boolean — When true, guarantees schema validation on tool names and inputs
        - `type` 'web_fetch_20250910', required
      - WebSearchTool20260209
        - `allowed_callers` AllowedCaller[]
        - `allowed_domains` string[], nullable — If provided, only these domains will be included in results. Cannot be used alongside `blocked_domains`.
        - `blocked_domains` string[], nullable — If provided, these domains will never appear in results. Cannot be used alongside `allowed_domains`.
        - `cache_control` CacheControlEphemeral
          - `ttl` '5m' | '1h' — The time-to-live for the cache control breakpoint. This may be one the following values: - `5m`: 5 minutes - `1h`: 1 hour Defaults to `5m`.
          - `type` 'ephemeral', required
        - `defer_loading` boolean — If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.
        - `max_uses` integer, nullable — Maximum number of times the tool can be used in the API request.
        - `name` 'web_search', required — Name of the tool. This is how the tool will be called by the model and in `tool_use` blocks.
        - `strict` boolean — When true, guarantees schema validation on tool names and inputs
        - `type` 'web_search_20260209', required
        - `user_location` UserLocation
          - `city` string, nullable — The city of the user.
          - `country` string, nullable — The two letter [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) of the user.
          - `region` string, nullable — The region of the user.
          - `timezone` string, nullable — The [IANA timezone](https://nodatime.org/TimeZones) of the user.
          - `type` 'approximate', required
      - WebFetchTool20260209
        - `allowed_callers` AllowedCaller[]
        - `allowed_domains` string[], nullable — List of domains to allow fetching from
        - `blocked_domains` string[], nullable — List of domains to block fetching from
        - `cache_control` CacheControlEphemeral
          - `ttl` '5m' | '1h' — The time-to-live for the cache control breakpoint. This may be one the following values: - `5m`: 5 minutes - `1h`: 1 hour Defaults to `5m`.
          - `type` 'ephemeral', required
        - `citations` RequestCitationsConfig
          - `enabled` boolean
        - `defer_loading` boolean — If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.
        - `max_content_tokens` integer, nullable — Maximum number of tokens used by including web page text content in the context. The limit is approximate and does not apply to binary content such as PDFs.
        - `max_uses` integer, nullable — Maximum number of times the tool can be used in the API request.
        - `name` 'web_fetch', required — Name of the tool. This is how the tool will be called by the model and in `tool_use` blocks.
        - `strict` boolean — When true, guarantees schema validation on tool names and inputs
        - `type` 'web_fetch_20260209', required
      - WebFetchTool20260309 — Web fetch tool with use_cache parameter for bypassing cached content.
        - `allowed_callers` AllowedCaller[]
        - `allowed_domains` string[], nullable — List of domains to allow fetching from
        - `blocked_domains` string[], nullable — List of domains to block fetching from
        - `cache_control` CacheControlEphemeral
          - `ttl` '5m' | '1h' — The time-to-live for the cache control breakpoint. This may be one the following values: - `5m`: 5 minutes - `1h`: 1 hour Defaults to `5m`.
          - `type` 'ephemeral', required
        - `citations` RequestCitationsConfig
          - `enabled` boolean
        - `defer_loading` boolean — If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.
        - `max_content_tokens` integer, nullable — Maximum number of tokens used by including web page text content in the context. The limit is approximate and does not apply to binary content such as PDFs.
        - `max_uses` integer, nullable — Maximum number of times the tool can be used in the API request.
        - `name` 'web_fetch', required — Name of the tool. This is how the tool will be called by the model and in `tool_use` blocks.
        - `strict` boolean — When true, guarantees schema validation on tool names and inputs
        - `type` 'web_fetch_20260309', required
        - `use_cache` boolean — Whether to use cached content. Set to false to bypass the cache and fetch fresh content. Only set to false when the user explicitly requests fresh content or when fetching rapidly-changing sources.
      - ToolSearchToolBM2520251119
        - `allowed_callers` AllowedCaller[]
        - `cache_control` CacheControlEphemeral
          - `ttl` '5m' | '1h' — The time-to-live for the cache control breakpoint. This may be one the following values: - `5m`: 5 minutes - `1h`: 1 hour Defaults to `5m`.
          - `type` 'ephemeral', required
        - `defer_loading` boolean — If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.
        - `name` 'tool_search_tool_bm25', required — Name of the tool. This is how the tool will be called by the model and in `tool_use` blocks.
        - `strict` boolean — When true, guarantees schema validation on tool names and inputs
        - `type` 'tool_search_tool_bm25_20251119' | 'tool_search_tool_bm25', required
      - ToolSearchToolRegex20251119
        - `allowed_callers` AllowedCaller[]
        - `cache_control` CacheControlEphemeral
          - `ttl` '5m' | '1h' — The time-to-live for the cache control breakpoint. This may be one the following values: - `5m`: 5 minutes - `1h`: 1 hour Defaults to `5m`.
          - `type` 'ephemeral', required
        - `defer_loading` boolean — If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.
        - `name` 'tool_search_tool_regex', required — Name of the tool. This is how the tool will be called by the model and in `tool_use` blocks.
        - `strict` boolean — When true, guarantees schema validation on tool names and inputs
        - `type` 'tool_search_tool_regex_20251119' | 'tool_search_tool_regex', required
  - `top_k` integer — Only sample from the top K options for each subsequent token. Used to remove "long tail" low probability responses. [Learn more technical details here](https://towardsdatascience.com/how-to-sample-from-language-models-682bceb97277). Recommended for advanced use cases only. You usually only need to use `temperature`.
  - `top_p` number — Use nucleus sampling. In nucleus sampling, we compute the cumulative distribution over all the options for each subsequent token in decreasing probability order and cut it off once it reaches a particular probability specified by `top_p`. You should either alter `temperature` or `top_p`, but not both. Recommended for advanced use cases only. You usually only need to use `temperature`.

## Response `200`

Message object.

- Message
  - `id` string, required — Unique object identifier. The format and length of IDs may change over time.
  - `type` 'message', required — Object type. For Messages, this is always `"message"`.
  - `role` 'assistant', required — Conversational role of the generated message. This will always be `"assistant"`.
  - `content` ContentBlock[], required — Content generated by the model. This is an array of content blocks, each of which has a `type` that determines its shape. Example: ```json [{"type": "text", "text": "Hi, I'm Claude."}] ``` If the request input `messages` ended with an `assistant` turn, then the response `content` will continue directly from that last turn. You can use this to constrain the model's output. For example, if the input `messages` were: ```json [ {"role": "user", "content": "What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun"}, {"role": "assistant", "content": "The best answer is ("} ] ``` Then the response `content` might be: ```json [{"type": "text", "text": "B)"}] ```
    - union
      - ResponseTextBlock
        - `citations` union[], nullable, required — Citations supporting the text block. The type of citation returned will depend on the type of document being cited. Citing a PDF results in `page_location`, plain text results in `char_location`, and content document results in `content_block_location`.
          - union
            - ResponseCharLocationCitation
              - …
            - ResponsePageLocationCitation
              - …
            - ResponseContentBlockLocationCitation
              - …
            - ResponseWebSearchResultLocationCitation
              - …
            - ResponseSearchResultLocationCitation
              - …
        - `text` string, required
        - `type` 'text', required
      - ResponseThinkingBlock
        - `signature` string, required
        - `thinking` string, required
        - `type` 'thinking', required
      - ResponseRedactedThinkingBlock
        - `data` string, required
        - `type` 'redacted_thinking', required
      - ResponseToolUseBlock
        - `caller` union, required
          - DirectCaller — Tool invocation directly from the model.
            - `type` 'direct', required
          - ServerToolCaller — Tool invocation generated by a server-side tool.
            - `tool_id` string, required
            - `type` 'code_execution_20250825', required
          - ServerToolCaller20260120
            - `tool_id` string, required
            - `type` 'code_execution_20260120', required
        - `id` string, required
        - `input` object, required
        - `name` string, required
        - `type` 'tool_use', required
      - ResponseServerToolUseBlock
        - `caller` union, required
          - DirectCaller — Tool invocation directly from the model.
            - `type` 'direct', required
          - ServerToolCaller — Tool invocation generated by a server-side tool.
            - `tool_id` string, required
            - `type` 'code_execution_20250825', required
          - ServerToolCaller20260120
            - `tool_id` string, required
            - `type` 'code_execution_20260120', required
        - `id` string, required
        - `input` object, required
        - `name` 'web_search' | 'web_fetch' | 'code_execution' | 'bash_code_execution' | 'text_editor_code_execution' | 'tool_search_tool_regex' | 'tool_search_tool_bm25', required
        - `type` 'server_tool_use', required
      - ResponseWebSearchToolResultBlock
        - `caller` union, required
          - DirectCaller — Tool invocation directly from the model.
            - `type` 'direct', required
          - ServerToolCaller — Tool invocation generated by a server-side tool.
            - `tool_id` string, required
            - `type` 'code_execution_20250825', required
          - ServerToolCaller20260120
            - `tool_id` string, required
            - `type` 'code_execution_20260120', required
        - `content` union, required
          - ResponseWebSearchToolResultError
            - `error_code` 'invalid_tool_input' | 'unavailable' | 'max_uses_exceeded' | 'too_many_requests' | 'query_too_long' | 'request_too_large', required
            - `type` 'web_search_tool_result_error', required
          - ResponseWebSearchResultBlock[]
            - `encrypted_content` string, required
            - `page_age` string, nullable, required
            - `title` string, required
            - `type` 'web_search_result', required
            - `url` string, required
        - `tool_use_id` string, required
        - `type` 'web_search_tool_result', required
      - ResponseWebFetchToolResultBlock
        - `caller` union, required
          - DirectCaller — Tool invocation directly from the model.
            - `type` 'direct', required
          - ServerToolCaller — Tool invocation generated by a server-side tool.
            - `tool_id` string, required
            - `type` 'code_execution_20250825', required
          - ServerToolCaller20260120
            - `tool_id` string, required
            - `type` 'code_execution_20260120', required
        - `content` union, required
          - ResponseWebFetchToolResultError
            - `error_code` 'invalid_tool_input' | 'url_too_long' | 'url_not_allowed' | 'url_not_accessible' | 'unsupported_content_type' | 'too_many_requests' | 'max_uses_exceeded' | 'unavailable', required
            - `type` 'web_fetch_tool_result_error', required
          - ResponseWebFetchResultBlock
            - `content` ResponseDocumentBlock, required
              - …
            - `retrieved_at` string, nullable, required — ISO 8601 timestamp when the content was retrieved
            - `type` 'web_fetch_result', required
            - `url` string, required — Fetched content URL
        - `tool_use_id` string, required
        - `type` 'web_fetch_tool_result', required
      - ResponseCodeExecutionToolResultBlock
        - `content` union, required
          - ResponseCodeExecutionToolResultError
            - `error_code` 'invalid_tool_input' | 'unavailable' | 'too_many_requests' | 'execution_time_exceeded', required
            - `type` 'code_execution_tool_result_error', required
          - ResponseCodeExecutionResultBlock
            - `content` ResponseCodeExecutionOutputBlock[], required
              - …
            - `return_code` integer, required
            - `stderr` string, required
            - `stdout` string, required
            - `type` 'code_execution_result', required
          - ResponseEncryptedCodeExecutionResultBlock — Code execution result with encrypted stdout for PFC + web_search results.
            - `content` ResponseCodeExecutionOutputBlock[], required
              - …
            - `encrypted_stdout` string, required
            - `return_code` integer, required
            - `stderr` string, required
            - `type` 'encrypted_code_execution_result', required
        - `tool_use_id` string, required
        - `type` 'code_execution_tool_result', required
      - ResponseBashCodeExecutionToolResultBlock
        - `content` union, required
          - ResponseBashCodeExecutionToolResultError
            - `error_code` 'invalid_tool_input' | 'unavailable' | 'too_many_requests' | 'execution_time_exceeded' | 'output_file_too_large', required
            - `type` 'bash_code_execution_tool_result_error', required
          - ResponseBashCodeExecutionResultBlock
            - `content` ResponseBashCodeExecutionOutputBlock[], required
              - …
            - `return_code` integer, required
            - `stderr` string, required
            - `stdout` string, required
            - `type` 'bash_code_execution_result', required
        - `tool_use_id` string, required
        - `type` 'bash_code_execution_tool_result', required
      - ResponseTextEditorCodeExecutionToolResultBlock
        - `content` union, required
          - ResponseTextEditorCodeExecutionToolResultError
            - `error_code` 'invalid_tool_input' | 'unavailable' | 'too_many_requests' | 'execution_time_exceeded' | 'file_not_found', required
            - `error_message` string, nullable, required
            - `type` 'text_editor_code_execution_tool_result_error', required
          - ResponseTextEditorCodeExecutionViewResultBlock
            - `content` string, required
            - `file_type` 'text' | 'image' | 'pdf', required
            - `num_lines` integer, nullable, required
            - `start_line` integer, nullable, required
            - `total_lines` integer, nullable, required
            - `type` 'text_editor_code_execution_view_result', required
          - ResponseTextEditorCodeExecutionCreateResultBlock
            - `is_file_update` boolean, required
            - `type` 'text_editor_code_execution_create_result', required
          - ResponseTextEditorCodeExecutionStrReplaceResultBlock
            - `lines` string[], nullable, required
            - `new_lines` integer, nullable, required
            - `new_start` integer, nullable, required
            - `old_lines` integer, nullable, required
            - `old_start` integer, nullable, required
            - `type` 'text_editor_code_execution_str_replace_result', required
        - `tool_use_id` string, required
        - `type` 'text_editor_code_execution_tool_result', required
      - ResponseToolSearchToolResultBlock
        - `content` union, required
          - ResponseToolSearchToolResultError
            - `error_code` 'invalid_tool_input' | 'unavailable' | 'too_many_requests' | 'execution_time_exceeded', required
            - `error_message` string, nullable, required
            - `type` 'tool_search_tool_result_error', required
          - ResponseToolSearchToolSearchResultBlock
            - `tool_references` ResponseToolReferenceBlock[], required
              - …
            - `type` 'tool_search_tool_search_result', required
        - `tool_use_id` string, required
        - `type` 'tool_search_tool_result', required
      - ResponseContainerUploadBlock — Response model for a file uploaded to the container.
        - `file_id` string, required
        - `type` 'container_upload', required
  - `model` union, required — The model that will complete your prompt.\n\nSee [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.
    - string
    - 'claude-opus-4-6' — Most intelligent model for building agents and coding
    - 'claude-sonnet-4-6' — Best combination of speed and intelligence
    - 'claude-haiku-4-5' — Fastest model with near-frontier intelligence
    - 'claude-haiku-4-5-20251001' — Fastest model with near-frontier intelligence
    - 'claude-opus-4-5' — Premium model combining maximum intelligence with practical performance
    - 'claude-opus-4-5-20251101' — Premium model combining maximum intelligence with practical performance
    - 'claude-sonnet-4-5' — High-performance model for agents and coding
    - 'claude-sonnet-4-5-20250929' — High-performance model for agents and coding
    - 'claude-opus-4-1' — Exceptional model for specialized complex tasks
    - 'claude-opus-4-1-20250805' — Exceptional model for specialized complex tasks
    - 'claude-opus-4-0' — Powerful model for complex tasks
    - 'claude-opus-4-20250514' — Powerful model for complex tasks
    - 'claude-sonnet-4-0' — High-performance model with extended thinking
    - 'claude-sonnet-4-20250514' — High-performance model with extended thinking
    - 'claude-3-haiku-20240307' — Fast and cost-effective model
  - `stop_reason` 'end_turn' | 'max_tokens' | 'stop_sequence' | 'tool_use' | 'pause_turn' | 'refusal', required
  - `stop_sequence` string, nullable, required — Which custom stop sequence was generated, if any. This value will be a non-null string if one of your custom stop sequences was generated.
  - `usage` Usage, required
    - `cache_creation` CacheCreation, required
      - `ephemeral_1h_input_tokens` integer, required — The number of input tokens used to create the 1 hour cache entry.
      - `ephemeral_5m_input_tokens` integer, required — The number of input tokens used to create the 5 minute cache entry.
    - `cache_creation_input_tokens` integer, nullable, required — The number of input tokens used to create the cache entry.
    - `cache_read_input_tokens` integer, nullable, required — The number of input tokens read from the cache.
    - `inference_geo` string, nullable, required — The geographic region where inference was performed for this request.
    - `input_tokens` integer, required — The number of input tokens which were used.
    - `output_tokens` integer, required — The number of output tokens which were used.
    - `server_tool_use` ServerToolUsage, required
      - `web_fetch_requests` integer, required — The number of web fetch tool requests.
      - `web_search_requests` integer, required — The number of web search tool requests.
    - `service_tier` 'standard' | 'priority' | 'batch', nullable, required — If the request used the priority, standard, or batch tier.
  - `container` Container, required — Information about the container used in the request (for the code execution tool)
    - `expires_at` string, date-time, required — The time at which the container will expire.
    - `id` string, required — Identifier for the container used in this request

## Other responses

- `4XX` — Error response. See our [errors documentation](https://docs.claude.com/en/api/errors) for more details.

## Changes

- **2026-03-18** `dd2dcd00a757` — 1 info
  - the `metadata/user_id/anyOf[subschema #1]/` request property's maxLength was increased from `256` to `512`
- **2026-03-16** `7fce94a3c9f7` — 1 breaking, 6 info
  - removed `subschema #3, subschema #6, subschema #7, subschema #8, subschema #9, subschema #10, subschema #11, subschema #14, subschema #15, subschema #16, subschema #17, subschema #18, subschema #19, subschema #20, subschema #21, subschema #22, subschema #23` from the `model` request property `anyOf` list
  - added the new optional request property `thinking/oneOf[subschema #1: ThinkingConfigEnabled]/display`
  - added the new optional request property `thinking/oneOf[subschema #3: ThinkingConfigAdaptive]/display`
  - added `subschema #3, subschema #4, subschema #5, subschema #8, subschema #9, subschema #10, subschema #11, subschema #12, subschema #13, subschema #16` to the `model` request property `anyOf` list
  - …3 more
- **2026-02-19** `29a6b7ba5194` — 1 info
  - added the new optional request property `cache_control`
- …earlier changes not shown

[Full history](https://skmtc.dev/anthropics/apis/anthropic-api/changes/v1/messages/post.md)

---

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