---
title: "Create a Message"
method: POST
path: "/v1/messages?beta=true"
---

# Create a Message

`POST /v1/messages?beta=true`

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://platform.claude.com/docs/en/get-started)

## Headers

- `anthropic-beta` string — Optional header to specify the beta version(s) you want to use. To use multiple betas, use a comma separated list like `beta1,beta2` or specify the header multiple times for each beta.
- `anthropic-version` string — The version of the Claude API you want to use. Read more about versioning and our version history [here](https://platform.claude.com/docs/en/api/versioning).
- `anthropic-user-profile-id` string — The user profile ID to attribute this request to. Use when acting on behalf of a party other than your organization. Requires the `user-profiles` beta header.

## Request body

- BetaCreateMessageParams
  - `model` union, required — The model that will complete your prompt. See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.
    - string
    - 'claude-sonnet-5' — High-performance model for coding and agents
    - 'claude-fable-5' — Next generation of intelligence for the hardest knowledge work and coding problems
    - 'claude-mythos-5' — Most capable model for cybersecurity and biology research
    - 'claude-opus-5' — Powerful intelligence for long-running agents and coding
    - 'claude-opus-4-8' — Powerful intelligence for long-running agents and coding
    - 'claude-opus-4-7' — Powerful intelligence for long-running agents and coding
    - 'claude-mythos-preview' — New class of intelligence, strongest in coding and cybersecurity
    - 'claude-opus-4-6' — Powerful intelligence for long-running 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' — Powerful intelligence for long-running agents and coding
    - 'claude-opus-4-5-20251101' — Powerful intelligence for long-running agents and coding
    - 'claude-sonnet-4-5' — High-performance model for agents and coding
    - 'claude-sonnet-4-5-20250929' — High-performance model for agents and coding
  - `messages` BetaInputMessage[], 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://platform.claude.com/docs/en/build-with-claude/working-with-messages). Note that if you want to include a [system prompt](https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/claude-prompting-best-practices#give-claude-a-role), 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
      - BetaInputContentBlock[]
        - union
          - object
            - `cache_control` BetaCacheControlEphemeral
              - …
            - `citations` union[], nullable
              - …
            - `text` string, required
            - `type` 'text', required
          - object
            - `cache_control` BetaCacheControlEphemeral
              - …
            - `source` union, required
              - …
            - `type` 'image', required
          - object
            - `cache_control` BetaCacheControlEphemeral
              - …
            - `citations` BetaRequestCitationsConfig
              - …
            - `context` string, nullable
            - `source` union, required
              - …
            - `title` string, nullable
            - `type` 'document', required
          - object
            - `cache_control` BetaCacheControlEphemeral
              - …
            - `citations` BetaRequestCitationsConfig
              - …
            - `content` BetaRequestTextBlock[], required
              - …
            - `source` string, required
            - `title` string, required
            - `type` 'search_result', required
          - object
            - `signature` string, required — The `signature` value of this thinking block, exactly as returned by the API in a previous response. Used to verify that the block was generated by Claude. Thinking blocks must be passed back unmodified and in their original order; a modified block results in a 400 `invalid_request_error`.
            - `thinking` string, required — The `thinking` text of this block as returned by the API.
            - `type` 'thinking', required
          - object
            - `data` string, required — The `data` value of this redacted thinking block, exactly as returned by the API in a previous response. Opaque and encrypted; pass it back unchanged.
            - `type` 'redacted_thinking', required
          - object
            - `cache_control` BetaCacheControlEphemeral
              - …
            - `caller` union
              - …
            - `id` string, required
            - `input` object, required
            - `name` string, required
            - `type` 'tool_use', required
          - object
            - `cache_control` BetaCacheControlEphemeral
              - …
            - `content` union
              - …
            - `is_error` boolean
            - `tool_use_id` string, required
            - `type` 'tool_result', required
          - object
            - `cache_control` BetaCacheControlEphemeral
              - …
            - `caller` union
              - …
            - `id` string, required
            - `input` object, required
            - `name` 'advisor' | '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` BetaCacheControlEphemeral
              - …
            - `caller` union
              - …
            - `content` union, required
              - …
            - `tool_use_id` string, required
            - `type` 'web_search_tool_result', required
          - object
            - `cache_control` BetaCacheControlEphemeral
              - …
            - `caller` union
              - …
            - `content` union, required
              - …
            - `tool_use_id` string, required
            - `type` 'web_fetch_tool_result', required
          - object
            - `cache_control` BetaCacheControlEphemeral
              - …
            - `content` union, required
              - …
            - `tool_use_id` string, required
            - `type` 'advisor_tool_result', required
          - object
            - `cache_control` BetaCacheControlEphemeral
              - …
            - `content` union, required
              - …
            - `tool_use_id` string, required
            - `type` 'code_execution_tool_result', required
          - object
            - `cache_control` BetaCacheControlEphemeral
              - …
            - `content` union, required
              - …
            - `tool_use_id` string, required
            - `type` 'bash_code_execution_tool_result', required
          - object
            - `cache_control` BetaCacheControlEphemeral
              - …
            - `content` union, required
              - …
            - `tool_use_id` string, required
            - `type` 'text_editor_code_execution_tool_result', required
          - object
            - `cache_control` BetaCacheControlEphemeral
              - …
            - `content` union, required
              - …
            - `tool_use_id` string, required
            - `type` 'tool_search_tool_result', required
          - object
            - `cache_control` BetaCacheControlEphemeral
              - …
            - `id` string, required
            - `input` object, required
            - `name` string, required
            - `server_name` string, required — The name of the MCP server
            - `type` 'mcp_tool_use', required
          - object
            - `cache_control` BetaCacheControlEphemeral
              - …
            - `content` union
              - …
            - `is_error` boolean
            - `tool_use_id` string, required
            - `type` 'mcp_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` BetaCacheControlEphemeral
              - …
            - `file_id` string, required
            - `type` 'container_upload', required
          - object — A compaction block containing summary of previous context. Users should round-trip these blocks from responses to subsequent requests to maintain context across compaction boundaries. When content is None, the block represents a failed compaction. The server treats these as no-ops. Empty string content is not allowed.
            - `cache_control` BetaCacheControlEphemeral
              - …
            - `content` string, nullable — Summary of previously compacted content, or null if compaction failed
            - `encrypted_content` string, nullable — Opaque metadata from prior compaction, to be round-tripped verbatim
            - `type` 'compaction', required
          - object — System instructions that appear mid-conversation. Use this block to provide or update system-level instructions at a specific point in the conversation, rather than only via the top-level `system` parameter.
            - `cache_control` BetaCacheControlEphemeral
              - …
            - `content` union[], required — System instruction text blocks.
              - …
            - `type` 'mid_conv_system', required
          - object — Mid-conversation directive to surface a declared tool. ``tool`` references a tool (or MCP toolset) by name from the request's ``tools``; it is offered to the model from this point in the conversation onward.
            - `cache_control` BetaCacheControlEphemeral
              - …
            - `tool` union, required
              - …
            - `type` 'tool_addition', required
          - object — Mid-conversation directive to withdraw a tool. ``tool`` references a tool (or MCP toolset) by name from the request's ``tools``; it is no longer offered to the model from this point in the conversation onward.
            - `cache_control` BetaCacheControlEphemeral
              - …
            - `tool` union, required
              - …
            - `type` 'tool_removal', required
          - object — A `fallback` block echoed back from a prior response. Accepted in `messages[].content` and not rendered into the prompt; not validated against the request's `fallbacks` chain or top-level `model`. Echo the assistant turn back verbatim, including this block in its original position. The block marks the boundary between content produced before and after a fallback hop, and the server relies on that boundary to validate the turn: when thinking runs flank the boundary, omitting the block merges them into one span the server cannot validate (the request is rejected), and moving it into the middle of a single run is likewise rejected; between non-thinking blocks the block's placement has no validation effect.
            - `from` BetaRequestFallbackHopInfo, required — Identifies one hop of a fallback transition.
              - …
            - `to` BetaRequestFallbackHopInfo, required — Identifies one hop of a fallback transition.
              - …
            - `trigger` unknown
            - `type` 'fallback', required
    - `role` 'user' | 'assistant' | 'system', required
  - `cache_control` BetaCacheControlEphemeral
    - `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`. See [prompt caching pricing](https://platform.claude.com/docs/en/build-with-claude/prompt-caching) for details.
    - `type` 'ephemeral', required
  - `container` union — Container identifier for reuse across requests.
    - BetaContainerParams — Container parameters with skills to be loaded.
      - `id` string, nullable — Container id
      - `skills` BetaSkillParams[], nullable — List of skills to load in the container
        - `skill_id` string, required — Skill ID
        - `type` 'anthropic' | 'custom', required — Type of skill - either 'anthropic' (built-in) or 'custom' (user-defined)
        - `version` string — Skill version or 'latest' for most recent version
    - string
  - `context_management` BetaContextManagementConfig
    - `edits` union[] — List of context management edits to apply
      - union
        - BetaClearToolUses20250919
          - `clear_at_least` BetaInputTokensClearAtLeast
            - `type` 'input_tokens', required
            - `value` integer, required
          - `clear_tool_inputs` union — Whether to clear all tool inputs (bool) or specific tool inputs to clear (list)
            - boolean
            - string[]
          - `exclude_tools` string[], nullable — Tool names whose uses are preserved from clearing
          - `keep` BetaToolUsesKeep
            - `type` 'tool_uses', required
            - `value` integer, required
          - `trigger` union — Condition that triggers the context management strategy
            - BetaInputTokensTrigger
              - …
            - BetaToolUsesTrigger
              - …
          - `type` 'clear_tool_uses_20250919', required
        - BetaClearThinking20251015
          - `keep` union — Number of most recent assistant turns to keep thinking blocks for. Older turns will have their thinking blocks removed.
            - union
              - …
            - 'all'
          - `type` 'clear_thinking_20251015', required
        - BetaCompact20260112 — Automatically compact older context when reaching the configured trigger threshold.
          - `instructions` string, nullable — Additional instructions for summarization.
          - `pause_after_compaction` boolean — Whether to pause after compaction and return the compaction block to the user.
          - `trigger` BetaInputTokensTrigger
            - `type` 'input_tokens', required
            - `value` integer, required
          - `type` 'compact_20260112', required
  - `diagnostics` BetaDiagnosticsParam — Request-level diagnostics. Currently carries the previous response id for prompt-cache divergence reporting.
    - `previous_message_id` string, nullable — The `id` (`msg_...`) from this client's previous /v1/messages response. The server compares that request's prompt fingerprint against this one and returns `diagnostics.cache_miss_reason` when the prompt-cache prefix could not be reused. Pass `null` on the first turn to opt in without a prior message to compare.
  - `fallback_credit_token` union — The `fallback_credit_token` from a prior refusal's `stop_details`. When a preceding request was refused and returned a `fallback_credit_token`, pass that code here on the retry to have the retry's cache-creation tokens for the prefix that was warm on the refused model billed at the cache-read rate. Must be redeemed by the same organization and workspace, with the same request body (optionally extended by one appended `assistant` message whose content is the partial text — with any trailing whitespace stripped from the final text block — and paired server-tool blocks streamed before the refusal; the appended-assistant form is not available for requests with `output_format` set or forced `tool_choice`), on an eligible fallback model, on the same platform, and within 5 minutes of the refusal; a mismatch is a 400. A token minted mid-server-tool-loop whose partial content was continuable may only be redeemed with the appended-assistant form — if an exact-body retry is rejected with a 400 saying the token must be redeemed by continuing the partial response, retry with the appended-assistant form instead. When the appended-assistant form is used on a model that otherwise disallows assistant-turn prefill, this token also authorizes that one prefill.
    - string
    - BetaFallbackCreditTokenParam — Object form of ``fallback_credit_token``: the token plus a redemption mode. Requires ``anthropic-beta: fallback-credit-2026-07-01``; without that header the field accepts the bare string only. The bare string and the mode-less object are equivalent (both select ``strict``), so wrapping an existing token changes nothing by itself.
      - `mode` 'strict' | 'best_effort' — How a failing token affects the retry. `strict` (the default, and the bare-string behavior): a failing redemption is a 400 and the retry is not served. `best_effort`: the retry is served either way — a token-layer failure no longer rejects the request; the retry proceeds at normal price and the outcome is reported on the response's `usage.fallback_credit`. Two failures stay hard in both modes: a malformed token, and combining `fallback_credit_token` with `fallbacks`.
      - `token` string, required — The opaque `fallback_credit_token` from a prior refusal's `stop_details` — the same string the bare-string form carries.
  - `fallbacks` union — Opt-in server-side retry on one or more substitute models when the requested model declines for policy reasons. Tried in order: if the first entry also declines, the second is tried, and so on. The string "default" requests the requested model's server-defined default fallback configuration.
    - BetaFallbackConfigV2[]
      - `max_tokens` integer, nullable
      - `model` union, required — The model that will complete your prompt. See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.
        - string
        - 'claude-sonnet-5' — High-performance model for coding and agents
        - 'claude-fable-5' — Next generation of intelligence for the hardest knowledge work and coding problems
        - 'claude-mythos-5' — Most capable model for cybersecurity and biology research
        - 'claude-opus-5' — Powerful intelligence for long-running agents and coding
        - 'claude-opus-4-8' — Powerful intelligence for long-running agents and coding
        - 'claude-opus-4-7' — Powerful intelligence for long-running agents and coding
        - 'claude-mythos-preview' — New class of intelligence, strongest in coding and cybersecurity
        - 'claude-opus-4-6' — Powerful intelligence for long-running 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' — Powerful intelligence for long-running agents and coding
        - 'claude-opus-4-5-20251101' — Powerful intelligence for long-running agents and coding
        - 'claude-sonnet-4-5' — High-performance model for agents and coding
        - 'claude-sonnet-4-5-20250929' — High-performance model for agents and coding
      - `output_config` BetaOutputConfig
        - `effort` 'low' | 'medium' | 'high' | 'xhigh' | 'max' — All possible effort levels.
        - `format` BetaJsonOutputFormat
          - `schema` object, required — The JSON schema of the format
          - `type` 'json_schema', required
        - `task_budget` BetaTokenTaskBudget — User-configurable total token budget across contexts.
          - `remaining` integer, nullable — Remaining tokens in the budget. Use this to track usage across contexts when implementing compaction client-side. Defaults to total if not provided.
          - `total` integer, required — Total token budget across all contexts in the session.
          - `type` 'tokens', required — The budget type. Currently only 'tokens' is supported.
      - `speed` 'standard' | 'fast' — Inference speed mode. `fast` provides significantly faster output token generation at premium pricing. Not all models support `fast`; invalid combinations are rejected at create time.
      - `thinking` union
        - BetaThinkingConfigEnabled
          - `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://platform.claude.com/docs/en/build-with-claude/extended-thinking) for details.
          - `display` 'summarized' | 'omitted'
          - `type` 'enabled', required
        - BetaThinkingConfigDisabled
          - `type` 'disabled', required
        - BetaThinkingConfigAdaptive
          - `display` 'summarized' | 'omitted'
          - `type` 'adaptive', required
    - 'default'
  - `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. Set to `0` to populate the [prompt cache](https://platform.claude.com/docs/en/build-with-claude/prompt-caching#pre-warming-the-cache) without generating a response. Different models have different maximum values for this parameter. See [models](https://platform.claude.com/docs/en/about-claude/models/overview) for details.
  - `mcp_servers` BetaRequestMCPServerURLDefinition[] — MCP servers to be utilized in this request
    - `authorization_token` string, nullable
    - `name` string, required
    - `tool_configuration` BetaRequestMCPServerToolConfiguration
      - `allowed_tools` string[], nullable
      - `enabled` boolean, nullable
    - `type` 'url', required
    - `url` string, required
  - `metadata` BetaMetadata
    - `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` BetaOutputConfig
    - `effort` 'low' | 'medium' | 'high' | 'xhigh' | 'max' — All possible effort levels.
    - `format` BetaJsonOutputFormat
      - `schema` object, required — The JSON schema of the format
      - `type` 'json_schema', required
    - `task_budget` BetaTokenTaskBudget — User-configurable total token budget across contexts.
      - `remaining` integer, nullable — Remaining tokens in the budget. Use this to track usage across contexts when implementing compaction client-side. Defaults to total if not provided.
      - `total` integer, required — Total token budget across all contexts in the session.
      - `type` 'tokens', required — The budget type. Currently only 'tokens' is supported.
  - `output_format` BetaJsonOutputFormat
    - `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://platform.claude.com/docs/en/api/service-tiers) for details.
  - `speed` 'standard' | 'fast' — Inference speed mode. `fast` provides significantly faster output token generation at premium pricing. Not all models support `fast`; invalid combinations are rejected at create time.
  - `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://platform.claude.com/docs/en/build-with-claude/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://platform.claude.com/docs/en/build-with-claude/prompt-engineering/claude-prompting-best-practices#give-claude-a-role).
    - string
    - BetaRequestTextBlock[]
      - `cache_control` BetaCacheControlEphemeral
        - `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`. See [prompt caching pricing](https://platform.claude.com/docs/en/build-with-claude/prompt-caching) for details.
        - `type` 'ephemeral', required
      - `citations` union[], nullable
        - union
          - BetaRequestCharLocationCitation
            - `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
          - BetaRequestPageLocationCitation
            - `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
          - BetaRequestContentBlockLocationCitation
            - `cited_text` string, required — The full text of the cited block range, concatenated. Always equals the contents of `content[start_block_index:end_block_index]` joined together. The text block is the minimal citable unit; this field is never a substring of a single block. Not counted toward output tokens, and not counted toward input tokens when sent back in subsequent turns.
            - `document_index` integer, required
            - `document_title` string, nullable, required
            - `end_block_index` integer, required — Exclusive 0-based end index of the cited block range in the source's `content` array. Always greater than `start_block_index`; a single-block citation has `end_block_index = start_block_index + 1`.
            - `start_block_index` integer, required — 0-based index of the first cited block in the source's `content` array.
            - `type` 'content_block_location', required
          - BetaRequestWebSearchResultLocationCitation
            - `cited_text` string, required
            - `encrypted_index` string, required
            - `title` string, nullable, required
            - `type` 'web_search_result_location', required
            - `url` string, required
          - BetaRequestSearchResultLocationCitation
            - `cited_text` string, required — The full text of the cited block range, concatenated. Always equals the contents of `content[start_block_index:end_block_index]` joined together. The text block is the minimal citable unit; this field is never a substring of a single block. Not counted toward output tokens, and not counted toward input tokens when sent back in subsequent turns.
            - `end_block_index` integer, required — Exclusive 0-based end index of the cited block range in the source's `content` array. Always greater than `start_block_index`; a single-block citation has `end_block_index = start_block_index + 1`.
            - `search_result_index` integer, required — 0-based index of the cited search result among all `search_result` content blocks in the request, in the order they appear across messages and tool results. Counted separately from `document_index`; server-side web search results are not included in this count.
            - `source` string, required
            - `start_block_index` integer, required — 0-based index of the first cited block in the source's `content` array.
            - `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://platform.claude.com/docs/en/build-with-claude/extended-thinking) for details.
    - BetaThinkingConfigEnabled
      - `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://platform.claude.com/docs/en/build-with-claude/extended-thinking) for details.
      - `display` 'summarized' | 'omitted'
      - `type` 'enabled', required
    - BetaThinkingConfigDisabled
      - `type` 'disabled', required
    - BetaThinkingConfigAdaptive
      - `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.
    - BetaToolChoiceAuto — 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
    - BetaToolChoiceAny — 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
    - BetaToolChoiceTool — 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
    - BetaToolChoiceNone — 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://platform.claude.com/docs/en/agents-and-tools/tool-use/server-tools), see their individual documentation as each has its own behavior (e.g., the [web search tool](https://platform.claude.com/docs/en/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://platform.claude.com/docs/en/agents-and-tools/tool-use/overview) for more details.
    - union
      - BetaTool
        - `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` BetaInputSchema, required
          - `properties` object, nullable
          - `required` string[], nullable
          - `type` 'object', required
        - `cache_control` BetaCacheControlEphemeral
          - `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`. See [prompt caching pricing](https://platform.claude.com/docs/en/build-with-claude/prompt-caching) for details.
          - `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` BetaAllowedCaller[]
        - `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[]
      - BetaBashTool20241022
        - `allowed_callers` BetaAllowedCaller[]
        - `cache_control` BetaCacheControlEphemeral
          - `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`. See [prompt caching pricing](https://platform.claude.com/docs/en/build-with-claude/prompt-caching) for details.
          - `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_20241022', required
      - BetaBashTool20250124
        - `allowed_callers` BetaAllowedCaller[]
        - `cache_control` BetaCacheControlEphemeral
          - `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`. See [prompt caching pricing](https://platform.claude.com/docs/en/build-with-claude/prompt-caching) for details.
          - `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
      - BetaCodeExecutionTool20250522
        - `allowed_callers` BetaAllowedCaller[]
        - `cache_control` BetaCacheControlEphemeral
          - `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`. See [prompt caching pricing](https://platform.claude.com/docs/en/build-with-claude/prompt-caching) for details.
          - `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
      - BetaCodeExecutionTool20250825
        - `allowed_callers` BetaAllowedCaller[]
        - `cache_control` BetaCacheControlEphemeral
          - `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`. See [prompt caching pricing](https://platform.claude.com/docs/en/build-with-claude/prompt-caching) for details.
          - `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
      - BetaCodeExecutionTool20260120 — Code execution tool with REPL state persistence (daemon mode + gVisor checkpoint).
        - `allowed_callers` BetaAllowedCaller[]
        - `cache_control` BetaCacheControlEphemeral
          - `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`. See [prompt caching pricing](https://platform.claude.com/docs/en/build-with-claude/prompt-caching) for details.
          - `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
      - BetaCodeExecutionTool20260521 — Code execution tool with REPL state persistence.
        - `allowed_callers` BetaAllowedCaller[]
        - `cache_control` BetaCacheControlEphemeral
          - `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`. See [prompt caching pricing](https://platform.claude.com/docs/en/build-with-claude/prompt-caching) for details.
          - `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_20260521', required
      - BetaComputerUseTool20241022
        - `allowed_callers` BetaAllowedCaller[]
        - `cache_control` BetaCacheControlEphemeral
          - `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`. See [prompt caching pricing](https://platform.claude.com/docs/en/build-with-claude/prompt-caching) for details.
          - `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.
        - `display_height_px` integer, required — The height of the display in pixels.
        - `display_number` integer, nullable — The X11 display number (e.g. 0, 1) for the display.
        - `display_width_px` integer, required — The width of the display in pixels.
        - `input_examples` object[]
        - `name` 'computer', 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` 'computer_20241022', required
      - BetaMemoryTool20250818
        - `allowed_callers` BetaAllowedCaller[]
        - `cache_control` BetaCacheControlEphemeral
          - `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`. See [prompt caching pricing](https://platform.claude.com/docs/en/build-with-claude/prompt-caching) for details.
          - `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
      - BetaComputerUseTool20250124
        - `allowed_callers` BetaAllowedCaller[]
        - `cache_control` BetaCacheControlEphemeral
          - `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`. See [prompt caching pricing](https://platform.claude.com/docs/en/build-with-claude/prompt-caching) for details.
          - `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.
        - `display_height_px` integer, required — The height of the display in pixels.
        - `display_number` integer, nullable — The X11 display number (e.g. 0, 1) for the display.
        - `display_width_px` integer, required — The width of the display in pixels.
        - `input_examples` object[]
        - `name` 'computer', 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` 'computer_20250124', required
      - BetaTextEditor20241022
        - `allowed_callers` BetaAllowedCaller[]
        - `cache_control` BetaCacheControlEphemeral
          - `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`. See [prompt caching pricing](https://platform.claude.com/docs/en/build-with-claude/prompt-caching) for details.
          - `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_20241022', required
      - BetaComputerUseTool20251124
        - `allowed_callers` BetaAllowedCaller[]
        - `cache_control` BetaCacheControlEphemeral
          - `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`. See [prompt caching pricing](https://platform.claude.com/docs/en/build-with-claude/prompt-caching) for details.
          - `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.
        - `display_height_px` integer, required — The height of the display in pixels.
        - `display_number` integer, nullable — The X11 display number (e.g. 0, 1) for the display.
        - `display_width_px` integer, required — The width of the display in pixels.
        - `enable_zoom` boolean — Whether to enable an action to take a zoomed-in screenshot of the screen.
        - `input_examples` object[]
        - `name` 'computer', 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` 'computer_20251124', required
      - BetaTextEditor20250124
        - `allowed_callers` BetaAllowedCaller[]
        - `cache_control` BetaCacheControlEphemeral
          - `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`. See [prompt caching pricing](https://platform.claude.com/docs/en/build-with-claude/prompt-caching) for details.
          - `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
      - BetaTextEditor20250429
        - `allowed_callers` BetaAllowedCaller[]
        - `cache_control` BetaCacheControlEphemeral
          - `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`. See [prompt caching pricing](https://platform.claude.com/docs/en/build-with-claude/prompt-caching) for details.
          - `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
      - BetaTextEditor20250728
        - `allowed_callers` BetaAllowedCaller[]
        - `cache_control` BetaCacheControlEphemeral
          - `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`. See [prompt caching pricing](https://platform.claude.com/docs/en/build-with-claude/prompt-caching) for details.
          - `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
      - BetaWebSearchTool20250305
        - `allowed_callers` BetaAllowedCaller[]
        - `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` BetaCacheControlEphemeral
          - `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`. See [prompt caching pricing](https://platform.claude.com/docs/en/build-with-claude/prompt-caching) for details.
          - `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` BetaUserLocation
          - `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
      - BetaWebFetchTool20250910
        - `allowed_callers` BetaAllowedCaller[]
        - `allowed_domains` string[], nullable — List of domains to allow fetching from
        - `blocked_domains` string[], nullable — List of domains to block fetching from
        - `cache_control` BetaCacheControlEphemeral
          - `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`. See [prompt caching pricing](https://platform.claude.com/docs/en/build-with-claude/prompt-caching) for details.
          - `type` 'ephemeral', required
        - `citations` BetaRequestCitationsConfig
          - `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
      - BetaWebSearchTool20260209
        - `allowed_callers` BetaAllowedCaller[]
        - `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` BetaCacheControlEphemeral
          - `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`. See [prompt caching pricing](https://platform.claude.com/docs/en/build-with-claude/prompt-caching) for details.
          - `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` BetaUserLocation
          - `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
      - BetaWebFetchTool20260209
        - `allowed_callers` BetaAllowedCaller[]
        - `allowed_domains` string[], nullable — List of domains to allow fetching from
        - `blocked_domains` string[], nullable — List of domains to block fetching from
        - `cache_control` BetaCacheControlEphemeral
          - `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`. See [prompt caching pricing](https://platform.claude.com/docs/en/build-with-claude/prompt-caching) for details.
          - `type` 'ephemeral', required
        - `citations` BetaRequestCitationsConfig
          - `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
      - BetaWebFetchTool20260309 — Web fetch tool with use_cache parameter for bypassing cached content.
        - `allowed_callers` BetaAllowedCaller[]
        - `allowed_domains` string[], nullable — List of domains to allow fetching from
        - `blocked_domains` string[], nullable — List of domains to block fetching from
        - `cache_control` BetaCacheControlEphemeral
          - `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`. See [prompt caching pricing](https://platform.claude.com/docs/en/build-with-claude/prompt-caching) for details.
          - `type` 'ephemeral', required
        - `citations` BetaRequestCitationsConfig
          - `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.
      - BetaWebSearchTool20260318
        - `allowed_callers` BetaAllowedCaller[]
        - `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` BetaCacheControlEphemeral
          - `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`. See [prompt caching pricing](https://platform.claude.com/docs/en/build-with-claude/prompt-caching) for details.
          - `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.
        - `response_inclusion` 'full' | 'excluded' — How this tool's result blocks appear in the API response when the result was consumed by a completed code_execution call in the same turn. 'full' returns the complete content (default). 'excluded' drops the nested server_tool_use and result block pair entirely. Results from direct calls, or from code_execution calls that paused before completing, are always returned in full so they can be sent back on the next turn.
        - `strict` boolean — When true, guarantees schema validation on tool names and inputs
        - `type` 'web_search_20260318', required
        - `user_location` BetaUserLocation
          - `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
      - BetaWebFetchTool20260318
        - `allowed_callers` BetaAllowedCaller[]
        - `allowed_domains` string[], nullable — List of domains to allow fetching from
        - `blocked_domains` string[], nullable — List of domains to block fetching from
        - `cache_control` BetaCacheControlEphemeral
          - `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`. See [prompt caching pricing](https://platform.claude.com/docs/en/build-with-claude/prompt-caching) for details.
          - `type` 'ephemeral', required
        - `citations` BetaRequestCitationsConfig
          - `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.
        - `response_inclusion` 'full' | 'excluded' — How this tool's result blocks appear in the API response when the result was consumed by a completed code_execution call in the same turn. 'full' returns the complete content (default). 'excluded' drops the nested server_tool_use and result block pair entirely. Results from direct calls, or from code_execution calls that paused before completing, are always returned in full so they can be sent back on the next turn.
        - `strict` boolean — When true, guarantees schema validation on tool names and inputs
        - `type` 'web_fetch_20260318', 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.
      - BetaAdvisorTool20260301
        - `allowed_callers` BetaAllowedCaller[]
        - `cache_control` BetaCacheControlEphemeral
          - `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`. See [prompt caching pricing](https://platform.claude.com/docs/en/build-with-claude/prompt-caching) for details.
          - `type` 'ephemeral', required
        - `caching` BetaCacheControlEphemeral
          - `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`. See [prompt caching pricing](https://platform.claude.com/docs/en/build-with-claude/prompt-caching) for details.
          - `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_tokens` integer, nullable — Bounds the advisor's total output (thinking + text) per call. When the advisor hits this cap, the returned advisor_result or advisor_redacted_result block carries stop_reason='max_tokens', and a truncation note is appended to the advice text the worker model sees (inside the encrypted blob in redacted mode). When set, the server also emits a remaining-tokens budget block in the advisor's prompt so the advisor self-shapes toward the cap. When omitted, the advisor model's default output cap applies and no budget block is emitted.
        - `max_uses` integer, nullable — Maximum number of times the tool can be used in the API request.
        - `model` union, required — The model that will complete your prompt. See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.
          - string
          - 'claude-sonnet-5' — High-performance model for coding and agents
          - 'claude-fable-5' — Next generation of intelligence for the hardest knowledge work and coding problems
          - 'claude-mythos-5' — Most capable model for cybersecurity and biology research
          - 'claude-opus-5' — Powerful intelligence for long-running agents and coding
          - 'claude-opus-4-8' — Powerful intelligence for long-running agents and coding
          - 'claude-opus-4-7' — Powerful intelligence for long-running agents and coding
          - 'claude-mythos-preview' — New class of intelligence, strongest in coding and cybersecurity
          - 'claude-opus-4-6' — Powerful intelligence for long-running 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' — Powerful intelligence for long-running agents and coding
          - 'claude-opus-4-5-20251101' — Powerful intelligence for long-running agents and coding
          - 'claude-sonnet-4-5' — High-performance model for agents and coding
          - 'claude-sonnet-4-5-20250929' — High-performance model for agents and coding
        - `name` 'advisor', 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` 'advisor_20260301', required
      - BetaToolSearchToolBM2520251119
        - `allowed_callers` BetaAllowedCaller[]
        - `cache_control` BetaCacheControlEphemeral
          - `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`. See [prompt caching pricing](https://platform.claude.com/docs/en/build-with-claude/prompt-caching) for details.
          - `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
      - BetaToolSearchToolRegex20251119
        - `allowed_callers` BetaAllowedCaller[]
        - `cache_control` BetaCacheControlEphemeral
          - `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`. See [prompt caching pricing](https://platform.claude.com/docs/en/build-with-claude/prompt-caching) for details.
          - `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
      - BetaMCPToolset — Configuration for a group of tools from an MCP server. Allows configuring enabled status and defer_loading for all tools from an MCP server, with optional per-tool overrides.
        - `cache_control` BetaCacheControlEphemeral
          - `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`. See [prompt caching pricing](https://platform.claude.com/docs/en/build-with-claude/prompt-caching) for details.
          - `type` 'ephemeral', required
        - `configs` object, nullable — Configuration overrides for specific tools, keyed by tool name
        - `default_config` BetaMCPToolDefaultConfig — Default configuration for tools in an MCP toolset.
          - `defer_loading` boolean
          - `enabled` boolean
        - `mcp_server_name` string, required — Name of the MCP server to configure tools for
        - `type` 'mcp_toolset', 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.
  - `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`. Recommended for advanced use cases only.

## Response `200`

Message object.

- BetaMessage
  - `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` BetaContentBlock[], 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
      - BetaResponseTextBlock
        - `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
            - BetaResponseCharLocationCitation
              - …
            - BetaResponsePageLocationCitation
              - …
            - BetaResponseContentBlockLocationCitation
              - …
            - BetaResponseWebSearchResultLocationCitation
              - …
            - BetaResponseSearchResultLocationCitation
              - …
        - `text` string, required
        - `type` 'text', required
      - BetaResponseThinkingBlock
        - `signature` string, required — A value used to verify that this thinking block was generated by Claude when it is passed back to the API. This is an opaque field and should not be interpreted or parsed. When passing thinking blocks back to the API (required when using tools with extended thinking), pass them back exactly as received, with this field intact. See [extended thinking](https://platform.claude.com/docs/en/build-with-claude/extended-thinking) for details.
        - `thinking` string, required — The text of Claude's thinking process for this block.
        - `type` 'thinking', required
      - BetaResponseRedactedThinkingBlock
        - `data` string, required — The contents of this redacted thinking block, returned when portions of the model's thinking were safety-redacted. This field is opaque and encrypted, with no readable content. Pass `redacted_thinking` blocks back to the API unchanged when continuing a multi-turn conversation. See [extended thinking](https://platform.claude.com/docs/en/build-with-claude/extended-thinking#redacted-thinking-blocks) for details.
        - `type` 'redacted_thinking', required
      - BetaResponseToolUseBlock
        - `caller` union
          - BetaDirectCaller — Tool invocation directly from the model.
            - `type` 'direct', required
          - BetaServerToolCaller — Tool invocation generated by a server-side tool.
            - `tool_id` string, required
            - `type` 'code_execution_20250825', required
          - BetaServerToolCaller20260120
            - `tool_id` string, required
            - `type` 'code_execution_20260120', required
        - `id` string, required
        - `input` object, required
        - `name` string, required
        - `type` 'tool_use', required
      - BetaResponseServerToolUseBlock
        - `caller` union
          - BetaDirectCaller — Tool invocation directly from the model.
            - `type` 'direct', required
          - BetaServerToolCaller — Tool invocation generated by a server-side tool.
            - `tool_id` string, required
            - `type` 'code_execution_20250825', required
          - BetaServerToolCaller20260120
            - `tool_id` string, required
            - `type` 'code_execution_20260120', required
        - `id` string, required
        - `input` object, required
        - `name` 'advisor' | '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
      - BetaResponseWebSearchToolResultBlock
        - `caller` union
          - BetaDirectCaller — Tool invocation directly from the model.
            - `type` 'direct', required
          - BetaServerToolCaller — Tool invocation generated by a server-side tool.
            - `tool_id` string, required
            - `type` 'code_execution_20250825', required
          - BetaServerToolCaller20260120
            - `tool_id` string, required
            - `type` 'code_execution_20260120', required
        - `content` union, required
          - BetaResponseWebSearchToolResultError
            - `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
          - BetaResponseWebSearchResultBlock[]
            - `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
      - BetaResponseWebFetchToolResultBlock
        - `caller` union
          - BetaDirectCaller — Tool invocation directly from the model.
            - `type` 'direct', required
          - BetaServerToolCaller — Tool invocation generated by a server-side tool.
            - `tool_id` string, required
            - `type` 'code_execution_20250825', required
          - BetaServerToolCaller20260120
            - `tool_id` string, required
            - `type` 'code_execution_20260120', required
        - `content` union, required
          - BetaResponseWebFetchToolResultError
            - `error_code` 'invalid_tool_input' | 'url_too_long' | 'url_not_allowed' | 'url_not_in_prior_context' | 'url_not_accessible' | 'unsupported_content_type' | 'too_many_requests' | 'max_uses_exceeded' | 'unavailable', required
            - `type` 'web_fetch_tool_result_error', required
          - BetaResponseWebFetchResultBlock
            - `content` BetaResponseDocumentBlock, 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
      - BetaResponseAdvisorToolResultBlock
        - `content` union, required
          - BetaResponseAdvisorToolResultError
            - `error_code` 'max_uses_exceeded' | 'prompt_too_long' | 'too_many_requests' | 'overloaded' | 'unavailable' | 'execution_time_exceeded' | 'model_not_found', required
            - `type` 'advisor_tool_result_error', required
          - BetaResponseAdvisorResultBlock
            - `stop_reason` string, nullable, required — The advisor sub-inference's stop reason (same values as the top-level message `stop_reason`). `max_tokens` indicates the advisor's output was truncated at the tool's `max_tokens` value or the advisor model's policy cap.
            - `text` string, required
            - `type` 'advisor_result', required
          - BetaResponseAdvisorRedactedResultBlock
            - `encrypted_content` string, required — Opaque blob containing the advisor's output. Round-trip verbatim; do not inspect or modify.
            - `stop_reason` string, nullable, required — The advisor sub-inference's stop reason (same values as the top-level message `stop_reason`).
            - `type` 'advisor_redacted_result', required
        - `tool_use_id` string, required
        - `type` 'advisor_tool_result', required
      - BetaResponseCodeExecutionToolResultBlock
        - `content` union, required
          - BetaResponseCodeExecutionToolResultError
            - `error_code` 'invalid_tool_input' | 'unavailable' | 'too_many_requests' | 'execution_time_exceeded', required
            - `type` 'code_execution_tool_result_error', required
          - BetaResponseCodeExecutionResultBlock
            - `content` BetaResponseCodeExecutionOutputBlock[], required
              - …
            - `return_code` integer, required
            - `stderr` string, required
            - `stdout` string, required
            - `type` 'code_execution_result', required
          - BetaResponseEncryptedCodeExecutionResultBlock — Code execution result with encrypted stdout for PFC + web_search results.
            - `content` BetaResponseCodeExecutionOutputBlock[], 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
      - BetaResponseBashCodeExecutionToolResultBlock
        - `content` union, required
          - BetaResponseBashCodeExecutionToolResultError
            - `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
          - BetaResponseBashCodeExecutionResultBlock
            - `content` BetaResponseBashCodeExecutionOutputBlock[], 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
      - BetaResponseTextEditorCodeExecutionToolResultBlock
        - `content` union, required
          - BetaResponseTextEditorCodeExecutionToolResultError
            - `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
          - BetaResponseTextEditorCodeExecutionViewResultBlock
            - `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
          - BetaResponseTextEditorCodeExecutionCreateResultBlock
            - `is_file_update` boolean, required
            - `type` 'text_editor_code_execution_create_result', required
          - BetaResponseTextEditorCodeExecutionStrReplaceResultBlock
            - `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
      - BetaResponseToolSearchToolResultBlock
        - `content` union, required
          - BetaResponseToolSearchToolResultError
            - `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
          - BetaResponseToolSearchToolSearchResultBlock
            - `tool_references` BetaResponseToolReferenceBlock[], required
              - …
            - `type` 'tool_search_tool_search_result', required
        - `tool_use_id` string, required
        - `type` 'tool_search_tool_result', required
      - BetaResponseMCPToolUseBlock
        - `id` string, required
        - `input` object, required
        - `name` string, required — The name of the MCP tool
        - `server_name` string, required — The name of the MCP server
        - `type` 'mcp_tool_use', required
      - BetaResponseMCPToolResultBlock
        - `content` union, required
          - string
          - BetaResponseTextBlock[]
            - `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`.
              - …
            - `text` string, required
            - `type` 'text', required
        - `is_error` boolean, required
        - `tool_use_id` string, required
        - `type` 'mcp_tool_result', required
      - BetaResponseContainerUploadBlock — Response model for a file uploaded to the container.
        - `file_id` string, required
        - `type` 'container_upload', required
      - BetaResponseCompactionBlock — A compaction block returned when autocompact is triggered. When content is None, it indicates the compaction failed to produce a valid summary (e.g., malformed output from the model). Clients may round-trip compaction blocks with null content; the server treats them as no-ops.
        - `content` string, nullable, required — Summary of compacted content, or null if compaction failed
        - `encrypted_content` string, nullable, required — Opaque metadata from prior compaction, to be round-tripped verbatim
        - `type` 'compaction', required
      - BetaResponseFallbackBlock — Marks the point in `content` where one model's output gives way to the next. One block appears per hop where a preceding model actually ran this turn and declined. A turn where no preceding model ran and declined has no such boundary and carries no block — the signal for whether a fallback model served the response is the presence of a `fallback_message` entry in `usage.iterations`, not this block. The block is treated like a server-tool content block for streaming: it arrives via the standard `content_block_start` / `content_block_stop` pair and carries no deltas.
        - `from` BetaResponseFallbackHopInfo, required — Identifies one hop of a fallback transition.
          - `model` union, required — The model that will complete your prompt. See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.
            - string
            - 'claude-sonnet-5' — High-performance model for coding and agents
            - 'claude-fable-5' — Next generation of intelligence for the hardest knowledge work and coding problems
            - 'claude-mythos-5' — Most capable model for cybersecurity and biology research
            - 'claude-opus-5' — Powerful intelligence for long-running agents and coding
            - 'claude-opus-4-8' — Powerful intelligence for long-running agents and coding
            - 'claude-opus-4-7' — Powerful intelligence for long-running agents and coding
            - 'claude-mythos-preview' — New class of intelligence, strongest in coding and cybersecurity
            - 'claude-opus-4-6' — Powerful intelligence for long-running 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' — Powerful intelligence for long-running agents and coding
            - 'claude-opus-4-5-20251101' — Powerful intelligence for long-running agents and coding
            - 'claude-sonnet-4-5' — High-performance model for agents and coding
            - 'claude-sonnet-4-5-20250929' — High-performance model for agents and coding
        - `to` BetaResponseFallbackHopInfo, required — Identifies one hop of a fallback transition.
          - `model` union, required — The model that will complete your prompt. See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.
            - string
            - 'claude-sonnet-5' — High-performance model for coding and agents
            - 'claude-fable-5' — Next generation of intelligence for the hardest knowledge work and coding problems
            - 'claude-mythos-5' — Most capable model for cybersecurity and biology research
            - 'claude-opus-5' — Powerful intelligence for long-running agents and coding
            - 'claude-opus-4-8' — Powerful intelligence for long-running agents and coding
            - 'claude-opus-4-7' — Powerful intelligence for long-running agents and coding
            - 'claude-mythos-preview' — New class of intelligence, strongest in coding and cybersecurity
            - 'claude-opus-4-6' — Powerful intelligence for long-running 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' — Powerful intelligence for long-running agents and coding
            - 'claude-opus-4-5-20251101' — Powerful intelligence for long-running agents and coding
            - 'claude-sonnet-4-5' — High-performance model for agents and coding
            - 'claude-sonnet-4-5-20250929' — High-performance model for agents and coding
        - `trigger` BetaFallbackRefusalTrigger, required — The `from` model declined for policy reasons.
          - `category` 'cyber' | 'bio' | 'frontier_llm' | 'reasoning_extraction' | 'general_harms', nullable, required — The policy category that triggered a refusal.
          - `type` 'refusal', required
        - `type` 'fallback', required
  - `model` union, required — The model that will complete your prompt. See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.
    - string
    - 'claude-sonnet-5' — High-performance model for coding and agents
    - 'claude-fable-5' — Next generation of intelligence for the hardest knowledge work and coding problems
    - 'claude-mythos-5' — Most capable model for cybersecurity and biology research
    - 'claude-opus-5' — Powerful intelligence for long-running agents and coding
    - 'claude-opus-4-8' — Powerful intelligence for long-running agents and coding
    - 'claude-opus-4-7' — Powerful intelligence for long-running agents and coding
    - 'claude-mythos-preview' — New class of intelligence, strongest in coding and cybersecurity
    - 'claude-opus-4-6' — Powerful intelligence for long-running 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' — Powerful intelligence for long-running agents and coding
    - 'claude-opus-4-5-20251101' — Powerful intelligence for long-running agents and coding
    - 'claude-sonnet-4-5' — High-performance model for agents and coding
    - 'claude-sonnet-4-5-20250929' — High-performance model for agents and coding
  - `stop_reason` 'end_turn' | 'max_tokens' | 'stop_sequence' | 'tool_use' | 'pause_turn' | 'compaction' | 'refusal' | 'model_context_window_exceeded', 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.
  - `stop_details` BetaRefusalStopDetails, required — Structured information about a refusal.
    - `category` 'cyber' | 'bio' | 'frontier_llm' | 'reasoning_extraction' | 'general_harms', required — The policy category that triggered a refusal.
    - `explanation` string, nullable, required — Human-readable explanation of the refusal. This text is not guaranteed to be stable. `null` when no explanation is available for the category.
    - `fallback_credit_token` string, nullable, required — Opaque code that refunds the cache-miss cost when retrying this refused request on the fallback model. Pass it as `fallback_credit_token` on the retry request. Expires 5 minutes after the refusal. The retry is sent either with the same request body (`system`, `messages`, `tools`, and other render-shaping fields), or with the same body plus one appended `assistant` message whose content is the partial text (with any trailing whitespace stripped from the final text block) and paired server-tool blocks from this refusal — which also authorizes that appended turn as an assistant-prefill continuation on models that otherwise disallow prefill. A token minted mid-server-tool-loop whose partial content was continuable may only be redeemed the second way — if a same-body retry is rejected with a 400 saying the token must be redeemed by continuing the partial response, retry the second way instead. Either way: same workspace, same platform; a mismatch is a 400. Resending a token for an already-warm prefix is permitted but yields no additional credit. `null` when the refused model isn't eligible for a fallback credit.
    - `fallback_has_prefill_claim` boolean, nullable, required — Whether the accompanying `fallback_credit_token` may be redeemed with the appended-assistant retry form. Only set when `fallback_credit_token` is present. `true`: retry by resending the same request body plus one appended `assistant` message whose content is this response's `content` with any trailing whitespace stripped from the final text block and unpaired `tool_use` blocks omitted (the same appended-turn shape described on `fallback_credit_token`), with the token attached. `false`: retry by resending the original request body unchanged, with the token attached — the appended-assistant form is not available for this refusal (no continuable partial content, or the request uses `output_format` or a `tool_choice` that forces tool use). One exception: when the request used `output_format` or a forced `tool_choice` and the refusal arrived after server tools (including MCP connector tools) had already executed, the token may not be redeemable by either retry form; if the exact-body retry is then rejected with a 400 saying the token must be redeemed by continuing the partial response, discard the token and retry without it. Advisory: if an appended-assistant retry is rejected with a 400 despite `true`, fall back to resending the original request body with the token.
    - `recommended_model` string, nullable, required — The server's suggested retry target for this refusal. Populated when a fallback attempt could not be made (the fallback model's rate limit was exhausted, or it was overloaded); names the fallback model the caller can retry directly. Null otherwise.
    - `type` 'refusal', required
  - `usage` BetaUsage, required
    - `cache_creation` BetaCacheCreation, 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.
    - `fallback_credit` BetaFallbackCreditUsage, required — Outcome of the ``fallback_credit_token`` presented on this request.
      - `status` union, required — Whether the fallback-credit reprice was applied to this response's billing. A union discriminated on `type`. `redeemed`: the retry is billed as if the conversation had been on the retry model all along — including when the resulting shift is zero because there was nothing to move. `not_applied`: no reprice was applied; the arm's `reason` says why.
        - BetaFallbackCreditRedeemed — The reprice was applied: the retry is billed as if the conversation had been on the retry model all along.
          - `type` 'redeemed', required
        - BetaFallbackCreditNotApplied — No reprice was applied; ``reason`` says why.
          - `reason` 'body_mismatch' | 'continuation_excluded' | 'continuation_only' | 'expired' | 'invalid_target_model' | 'not_enabled' | 'reprice_unavailable' | 'temporarily_unavailable' | 'variant_fields_present' | 'wrong_organization' | 'wrong_platform' | 'wrong_workspace', required — Why the reprice was not applied. A closed enum; additions to the redemption-check vocabulary arrive as deliberate schema updates.
          - `remove_to_redeem` string[], nullable — Request fields to remove before retrying, so the retry can redeem this token. Present exactly when `reason` is `variant_fields_present` — never null, never an empty array; absent otherwise. Fields are named only from your own request, and only after the sealed variant hash matched. A served best-effort retry has already been billed at normal price; nothing redeems retroactively, but a corrected re-send inside the token's five-minute window can still redeem.
          - `type` 'not_applied', required
    - `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.
    - `iterations` union[], nullable, required — Per-iteration token usage breakdown. Each entry represents one sampling iteration, with its own input/output token counts and cache statistics. This allows you to: - Determine which iterations exceeded long context thresholds (>=200k tokens) - Calculate the true context window size from the last iteration - Understand token accumulation across server-side tool use loops
      - union
        - object — Token usage for a sampling iteration.
          - `cache_creation` BetaCacheCreation, 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, required — The number of input tokens used to create the cache entry.
          - `cache_read_input_tokens` integer, required — The number of input tokens read from the cache.
          - `input_tokens` integer, required — The number of input tokens which were used.
          - `model` union, required — The model that will complete your prompt. See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.
            - string
            - 'claude-sonnet-5' — High-performance model for coding and agents
            - 'claude-fable-5' — Next generation of intelligence for the hardest knowledge work and coding problems
            - 'claude-mythos-5' — Most capable model for cybersecurity and biology research
            - 'claude-opus-5' — Powerful intelligence for long-running agents and coding
            - 'claude-opus-4-8' — Powerful intelligence for long-running agents and coding
            - 'claude-opus-4-7' — Powerful intelligence for long-running agents and coding
            - 'claude-mythos-preview' — New class of intelligence, strongest in coding and cybersecurity
            - 'claude-opus-4-6' — Powerful intelligence for long-running 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' — Powerful intelligence for long-running agents and coding
            - 'claude-opus-4-5-20251101' — Powerful intelligence for long-running agents and coding
            - 'claude-sonnet-4-5' — High-performance model for agents and coding
            - 'claude-sonnet-4-5-20250929' — High-performance model for agents and coding
          - `output_tokens` integer, required — The number of output tokens which were used.
          - `type` 'message', required — Usage for a sampling iteration
        - object — Token usage for a compaction iteration.
          - `cache_creation` BetaCacheCreation, 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, required — The number of input tokens used to create the cache entry.
          - `cache_read_input_tokens` integer, required — The number of input tokens read from the cache.
          - `input_tokens` integer, required — The number of input tokens which were used.
          - `output_tokens` integer, required — The number of output tokens which were used.
          - `type` 'compaction', required — Usage for a compaction iteration
        - object — Token usage for an advisor sub-inference iteration.
          - `cache_creation` BetaCacheCreation, 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, required — The number of input tokens used to create the cache entry.
          - `cache_read_input_tokens` integer, required — The number of input tokens read from the cache.
          - `input_tokens` integer, required — The number of input tokens which were used.
          - `model` union, required — The model that will complete your prompt. See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.
            - string
            - 'claude-sonnet-5' — High-performance model for coding and agents
            - 'claude-fable-5' — Next generation of intelligence for the hardest knowledge work and coding problems
            - 'claude-mythos-5' — Most capable model for cybersecurity and biology research
            - 'claude-opus-5' — Powerful intelligence for long-running agents and coding
            - 'claude-opus-4-8' — Powerful intelligence for long-running agents and coding
            - 'claude-opus-4-7' — Powerful intelligence for long-running agents and coding
            - 'claude-mythos-preview' — New class of intelligence, strongest in coding and cybersecurity
            - 'claude-opus-4-6' — Powerful intelligence for long-running 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' — Powerful intelligence for long-running agents and coding
            - 'claude-opus-4-5-20251101' — Powerful intelligence for long-running agents and coding
            - 'claude-sonnet-4-5' — High-performance model for agents and coding
            - 'claude-sonnet-4-5-20250929' — High-performance model for agents and coding
          - `output_tokens` integer, required — The number of output tokens which were used.
          - `type` 'advisor_message', required — Usage for an advisor sub-inference iteration
        - object — Token usage for the fallback-model attempt of a server-side fallback request. Produced in place of a `message` entry for whichever hop served the response. A declined hop produces the existing `message` entry. Whether a fallback model served the response is signalled by the presence of this entry in `usage.iterations`.
          - `cache_creation` BetaCacheCreation, 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, required — The number of input tokens used to create the cache entry.
          - `cache_read_input_tokens` integer, required — The number of input tokens read from the cache.
          - `input_tokens` integer, required — The number of input tokens which were used.
          - `model` union, required — The model that will complete your prompt. See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.
            - string
            - 'claude-sonnet-5' — High-performance model for coding and agents
            - 'claude-fable-5' — Next generation of intelligence for the hardest knowledge work and coding problems
            - 'claude-mythos-5' — Most capable model for cybersecurity and biology research
            - 'claude-opus-5' — Powerful intelligence for long-running agents and coding
            - 'claude-opus-4-8' — Powerful intelligence for long-running agents and coding
            - 'claude-opus-4-7' — Powerful intelligence for long-running agents and coding
            - 'claude-mythos-preview' — New class of intelligence, strongest in coding and cybersecurity
            - 'claude-opus-4-6' — Powerful intelligence for long-running 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' — Powerful intelligence for long-running agents and coding
            - 'claude-opus-4-5-20251101' — Powerful intelligence for long-running agents and coding
            - 'claude-sonnet-4-5' — High-performance model for agents and coding
            - 'claude-sonnet-4-5-20250929' — High-performance model for agents and coding
          - `output_tokens` integer, required — The number of output tokens which were used.
          - `type` 'fallback_message', required — Usage for the fallback-model attempt that served the response
    - `output_tokens` integer, required — The number of output tokens which were used.
    - `output_tokens_details` BetaOutputTokensDetails, required
      - `thinking_tokens` integer, required — Number of output tokens the model generated as internal reasoning, including the thinking-block delimiter tokens. Reflects the raw reasoning the model produced, not the (possibly shorter) summarized thinking text returned in the response body. Computed by re-tokenizing the raw reasoning text, so it may differ from the model's exact generation count by a small number of tokens. Always ≤ `output_tokens`; `output_tokens - thinking_tokens` approximates the non-reasoning output.
    - `server_tool_use` BetaServerToolUsage, 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.
    - `speed` 'standard' | 'fast', required — Inference speed mode. `fast` provides significantly faster output token generation at premium pricing. Not all models support `fast`; invalid combinations are rejected at create time.
  - `diagnostics` BetaDiagnostics, required — Response envelope for request-level diagnostics. Present (possibly null) whenever the caller supplied `diagnostics` on the request.
    - `cache_miss_reason` union, required — Explains why the prompt cache could not fully reuse the prefix from the request identified by `diagnostics.previous_message_id`. `null` means diagnosis is still pending — the response was serialized before the background comparison completed.
      - BetaCacheMissModelChanged
        - `cache_missed_input_tokens` integer, required — Approximate number of input tokens that would have been read from cache had the prefix matched the previous request.
        - `type` 'model_changed', required
      - BetaCacheMissSystemChanged
        - `cache_missed_input_tokens` integer, required — Approximate number of input tokens that would have been read from cache had the prefix matched the previous request.
        - `type` 'system_changed', required
      - BetaCacheMissToolsChanged
        - `cache_missed_input_tokens` integer, required — Approximate number of input tokens that would have been read from cache had the prefix matched the previous request.
        - `type` 'tools_changed', required
      - BetaCacheMissMessagesChanged
        - `cache_missed_input_tokens` integer, required — Approximate number of input tokens that would have been read from cache had the prefix matched the previous request.
        - `type` 'messages_changed', required
      - BetaCacheMissPreviousMessageNotFound
        - `type` 'previous_message_not_found', required
      - BetaCacheMissUnavailable
        - `type` 'unavailable', required
  - `context_management` BetaResponseContextManagement, required
    - `applied_edits` union[], required — List of context management edits that were applied.
      - union
        - BetaResponseClearToolUses20250919Edit
          - `cleared_input_tokens` integer, required — Number of input tokens cleared by this edit.
          - `cleared_tool_uses` integer, required — Number of tool uses that were cleared.
          - `type` 'clear_tool_uses_20250919', required — The type of context management edit applied.
        - BetaResponseClearThinking20251015Edit
          - `cleared_input_tokens` integer, required — Number of input tokens cleared by this edit.
          - `cleared_thinking_turns` integer, required — Number of thinking turns that were cleared.
          - `type` 'clear_thinking_20251015', required — The type of context management edit applied.
  - `container` BetaContainer, 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
    - `skills` BetaSkill[], nullable, required — Skills loaded in the container
      - `skill_id` string, required — Skill ID
      - `type` 'anthropic' | 'custom', required — Type of skill - either 'anthropic' (built-in) or 'custom' (user-defined)
      - `version` string, required — Skill version or 'latest' for most recent version

## Other responses

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

---

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