Repository Public
1---2title: Create a Message3url: https://platform.claude.com/docs/en/api/cli/messages/create4---56# Create a Message78`$ ant messages create`910**POST** `/v1/messages`1112Send a structured list of input messages with text and/or image content, and the model will generate the next message in the conversation.1314The Messages API can be used for either single queries or stateless multi-turn conversations.1516Learn more about the Messages API in our [user guide](https://platform.claude.com/docs/en/get-started)1718## Parameters1920- `--max-tokens: number`2122 Body param: The maximum number of tokens to generate before stopping.2324 Note that our models may stop _before_ reaching this maximum. This parameter only specifies the absolute maximum number of tokens to generate.2526 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.2728 Different models have different maximum values for this parameter. See [models](https://platform.claude.com/docs/en/about-claude/models/overview) for details.2930 minimum: 03132- `--message: array of MessageParam`3334 Body param: Input messages.3536 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.3738 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.3940 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.4142 Example with a single `user` message:4344 ```json45 [{"role": "user", "content": "Hello, Claude"}]46 ```4748 Example with multiple conversational turns:4950 ```json51 [52 {"role": "user", "content": "Hello there."},53 {"role": "assistant", "content": "Hi, I'm Claude. How can I help you?"},54 {"role": "user", "content": "Can you explain LLMs in plain English?"},55 ]56 ```5758 Example with a partially-filled response from Claude:5960 ```json61 [62 {"role": "user", "content": "What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun"},63 {"role": "assistant", "content": "The best answer is ("},64 ]65 ```6667 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:6869 ```json70 {"role": "user", "content": "Hello, Claude"}71 ```7273 ```json74 {"role": "user", "content": [{"type": "text", "text": "Hello, Claude"}]}75 ```7677 See [input examples](https://platform.claude.com/docs/en/build-with-claude/working-with-messages).7879 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.8081 There is a limit of 100,000 messages in a single request.8283- `--model: "claude-fable-5-1" or "claude-mythos-5-1" or "claude-sonnet-5" or 14 more or string`8485 Body param: The model that will complete your prompt.8687 See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.8889- `--cache-control: optional object`9091 Body param: Top-level cache control automatically applies a cache_control marker to the last cacheable block in the request.9293- `--container: optional ContainerParams or string`9495 Body param: Container identifier for reuse across requests.9697- `--inference-geo: optional string`9899 Body param: Specifies the geographic region for inference processing. If not specified, the workspace's `default_inference_geo` is used.100101- `--metadata: optional object`102103 Body param: An object describing metadata about the request.104105- `--output-config: optional object`106107 Body param: Configuration options for the model's output, such as the output format.108109- `--service-tier: optional "auto" or "standard_only"`110111 Body param: Determines whether to use priority capacity (if available) or standard capacity for this request.112113 Anthropic offers different levels of service for your API requests. See [service-tiers](https://platform.claude.com/docs/en/api/service-tiers) for details.114115- `--stop-sequence: optional array of string`116117 Body param: Custom text sequences that will cause the model to stop generating.118119 Our models will normally stop when they have naturally completed their turn, which will result in a response `stop_reason` of `"end_turn"`.120121 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.122123- `--system: optional string or array of TextBlockParam`124125 Body param: System prompt.126127 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).128129- `--thinking: optional ThinkingConfigEnabled or ThinkingConfigDisabled or ThinkingConfigAdaptive`130131 Body param: Configuration for enabling Claude's extended thinking.132133 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.134135 See [extended thinking](https://platform.claude.com/docs/en/build-with-claude/extended-thinking) for details.136137- `--tool-choice: optional ToolChoiceAuto or ToolChoiceAny or ToolChoiceTool or ToolChoiceNone`138139 Body param: 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.140141- `--tool: optional array of ToolUnion`142143 Body param: Definitions of tools that the model may use.144145 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.146147 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)).148149 Each tool definition includes:150151 * `name`: Name of the tool.152 * `description`: Optional, but strongly-recommended description of the tool.153 * `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.154155 For example, if you defined `tools` as:156157 ```json158 [159 {160 "name": "get_stock_price",161 "description": "Get the current stock price for a given ticker symbol.",162 "input_schema": {163 "type": "object",164 "properties": {165 "ticker": {166 "type": "string",167 "description": "The stock ticker symbol, e.g. AAPL for Apple Inc."168 }169 },170 "required": ["ticker"]171 }172 }173 ]174 ```175176 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:177178 ```json179 [180 {181 "type": "tool_use",182 "id": "toolu_01D7FLrfh4GYq7yT1ULFeyMV",183 "name": "get_stock_price",184 "input": { "ticker": "^GSPC" }185 }186 ]187 ```188189 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:190191 ```json192 [193 {194 "type": "tool_result",195 "tool_use_id": "toolu_01D7FLrfh4GYq7yT1ULFeyMV",196 "content": "259.75 USD"197 }198 ]199 ```200201 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.202203 See our [guide](https://platform.claude.com/docs/en/agents-and-tools/tool-use/overview) for more details.204205- `--user-profile-id: optional string`206207 Header param: 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.208209- `--workspace-id: optional string`210211 Header param: Optional header to select the Workspace for this request. The value is a Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`).212213 Only needed for credentials that can act on more than one Workspace. A credential that belongs to a specific Workspace may omit it; if sent, it must match that Workspace.214215- `--temperature: optional number`216217 **Deprecated**: Deprecated. Models released after Claude Opus 4.6 do not support setting temperature. A value of 1.0 will be accepted for backwards compatibility, all other values will be rejected with a 400 error.218219 Body param: Amount of randomness injected into the response.220221 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.222223 Note that even with `temperature` of `0.0`, the results will not be fully deterministic.224225 maximum: 1, minimum: 0226227- `--top-k: optional number`228229 **Deprecated**: Deprecated. Models released after Claude Opus 4.6 do not accept top_k; any value will be rejected with a 400 error.230231 Body param: Only sample from the top K options for each subsequent token.232233 Used to remove "long tail" low probability responses. [Learn more technical details here](https://towardsdatascience.com/how-to-sample-from-language-models-682bceb97277).234235 Recommended for advanced use cases only.236237 minimum: 0238239- `--top-p: optional number`240241 **Deprecated**: Deprecated. Models released after Claude Opus 4.6 do not support setting top_p. A value >= 0.99 will be accepted for backwards compatibility, all other values will be rejected with a 400 error.242243 Body param: Use nucleus sampling.244245 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`.246247 Recommended for advanced use cases only.248249 maximum: 1, minimum: 0250251## Returns252253- `message: object`254255 - `type: "message"`256257 Object type.258259 For Messages, this is always `"message"`.260261 - `id: string`262263 Unique object identifier.264265 The format and length of IDs may change over time.266267 - `container: object`268269 Information about the container used in the request (for the code execution tool)270271 - `id: string`272273 Identifier for the container used in this request274275 - `expires_at: string`276277 The time at which the container will expire.278279 format: date-time280281 - `skills: array of ContainerSkill`282283 Skills loaded in the container284285 - `type: "anthropic" or "custom"`286287 Type of skill - either 'anthropic' (built-in) or 'custom' (user-defined)288289 - `"anthropic"`290291 - `"custom"`292293 - `skill_id: string`294295 Skill ID296297 maxLength: 64, minLength: 1298299 - `version: string`300301 The resolved version: a skill version ID for custom skills.302303 maxLength: 64, minLength: 1304305 - `content: array of ContentBlock`306307 Content generated by the model.308309 This is an array of content blocks, each of which has a `type` that determines its shape.310311 Example:312313 ```json314 [{"type": "text", "text": "Hi, I'm Claude."}]315 ```316317 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.318319 For example, if the input `messages` were:320321 ```json322 [323 {"role": "user", "content": "What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun"},324 {"role": "assistant", "content": "The best answer is ("}325 ]326 ```327328 Then the response `content` might be:329330 ```json331 [{"type": "text", "text": "B)"}]332 ```333334 - `text_block: object`335336 - `type: "text"`337338 - `citations: array of TextCitation`339340 Citations supporting the text block.341342 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`.343344 - `citation_char_location: object`345346 - `type: "char_location"`347348 - `cited_text: string`349350 - `document_index: number`351352 minimum: 0353354 - `document_title: string`355356 - `end_char_index: number`357358 - `file_id: string`359360 - `start_char_index: number`361362 minimum: 0363364 - `citation_page_location: object`365366 - `type: "page_location"`367368 - `cited_text: string`369370 - `document_index: number`371372 minimum: 0373374 - `document_title: string`375376 - `end_page_number: number`377378 - `file_id: string`379380 - `start_page_number: number`381382 minimum: 1383384 - `citation_content_block_location: object`385386 - `type: "content_block_location"`387388 - `cited_text: string`389390 The full text of the cited block range, concatenated.391392 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.393394 - `document_index: number`395396 minimum: 0397398 - `document_title: string`399400 - `end_block_index: number`401402 Exclusive 0-based end index of the cited block range in the source's `content` array.403404 Always greater than `start_block_index`; a single-block citation has `end_block_index = start_block_index + 1`.405406 - `file_id: string`407408 - `start_block_index: number`409410 0-based index of the first cited block in the source's `content` array.411412 minimum: 0413414 - `citations_web_search_result_location: object`415416 - `type: "web_search_result_location"`417418 - `cited_text: string`419420 - `encrypted_index: string`421422 - `title: string`423424 maxLength: 512425426 - `url: string`427428 - `citations_search_result_location: object`429430 - `type: "search_result_location"`431432 - `cited_text: string`433434 The full text of the cited block range, concatenated.435436 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.437438 - `end_block_index: number`439440 Exclusive 0-based end index of the cited block range in the source's `content` array.441442 Always greater than `start_block_index`; a single-block citation has `end_block_index = start_block_index + 1`.443444 - `search_result_index: number`445446 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.447448 Counted separately from `document_index`; server-side web search results are not included in this count.449450 minimum: 0451452 - `source: string`453454 - `start_block_index: number`455456 0-based index of the first cited block in the source's `content` array.457458 minimum: 0459460 - `title: string`461462 - `text: string`463464 minLength: 0465466 - `thinking_block: object`467468 - `type: "thinking"`469470 - `signature: string`471472 A value used to verify that this thinking block was generated by Claude when it is passed back to the API.473474 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.475476 See [extended thinking](https://platform.claude.com/docs/en/build-with-claude/extended-thinking) for details.477478 - `thinking: string`479480 The text of Claude's thinking process for this block.481482 - `redacted_thinking_block: object`483484 - `type: "redacted_thinking"`485486 - `data: string`487488 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.489490 Pass `redacted_thinking` blocks back to the API unchanged when continuing a multi-turn conversation.491492 See [extended thinking](https://platform.claude.com/docs/en/build-with-claude/extended-thinking#redacted-thinking-blocks) for details.493494 - `tool_use_block: object`495496 - `type: "tool_use"`497498 - `id: string`499500 pattern: ^[a-zA-Z0-9_-]+$501502 - `caller: DirectCaller or ServerToolCaller or ServerToolCaller20260120`503504 - `direct_caller: object`505506 Tool invocation directly from the model.507508 - `type: "direct"`509510 - `server_tool_caller: object`511512 Tool invocation generated by a server-side tool.513514 - `type: "code_execution_20250825"`515516 - `tool_id: string`517518 pattern: ^srvtoolu_[a-zA-Z0-9_]+$519520 - `server_tool_caller_20260120: object`521522 - `type: "code_execution_20260120"`523524 - `tool_id: string`525526 pattern: ^srvtoolu_[a-zA-Z0-9_]+$527528 - `input: map[unknown]`529530 - `name: string`531532 minLength: 1533534 - `toolset_name: optional string`535536 For a toolset member tool_use, the toolset family.537538 maxLength: 64, minLength: 1, pattern: ^[a-zA-Z0-9_-]+$539540 - `server_tool_use_block: object`541542 - `type: "server_tool_use"`543544 - `id: string`545546 pattern: ^srvtoolu_[a-zA-Z0-9_]+$547548 - `caller: DirectCaller or ServerToolCaller or ServerToolCaller20260120`549550 - `direct_caller: object`551552 Tool invocation directly from the model.553554 - `server_tool_caller: object`555556 Tool invocation generated by a server-side tool.557558 - `server_tool_caller_20260120: object`559560 - `input: map[unknown]`561562 - `name: "web_search" or "web_fetch" or "code_execution" or 4 more`563564 - `"web_search"`565566 - `"web_fetch"`567568 - `"code_execution"`569570 - `"bash_code_execution"`571572 - `"text_editor_code_execution"`573574 - `"tool_search_tool_regex"`575576 - `"tool_search_tool_bm25"`577578 - `web_search_tool_result_block: object`579580 - `type: "web_search_tool_result"`581582 - `caller: DirectCaller or ServerToolCaller or ServerToolCaller20260120`583584 - `direct_caller: object`585586 Tool invocation directly from the model.587588 - `server_tool_caller: object`589590 Tool invocation generated by a server-side tool.591592 - `server_tool_caller_20260120: object`593594 - `content: WebSearchToolResultError or array of WebSearchResultBlock`595596 - `web_search_tool_result_error: object`597598 - `type: "web_search_tool_result_error"`599600 - `error_code: "invalid_tool_input" or "unavailable" or "max_uses_exceeded" or 3 more`601602 - `"invalid_tool_input"`603604 - `"unavailable"`605606 - `"max_uses_exceeded"`607608 - `"too_many_requests"`609610 - `"query_too_long"`611612 - `"request_too_large"`613614 - `union_member_1: array of WebSearchResultBlock`615616 - `type: "web_search_result"`617618 - `encrypted_content: string`619620 - `page_age: string`621622 - `title: string`623624 - `url: string`625626 - `tool_use_id: string`627628 pattern: ^srvtoolu_[a-zA-Z0-9_]+$629630 - `web_fetch_tool_result_block: object`631632 - `type: "web_fetch_tool_result"`633634 - `caller: DirectCaller or ServerToolCaller or ServerToolCaller20260120`635636 - `direct_caller: object`637638 Tool invocation directly from the model.639640 - `server_tool_caller: object`641642 Tool invocation generated by a server-side tool.643644 - `server_tool_caller_20260120: object`645646 - `content: WebFetchToolResultErrorBlock or WebFetchBlock`647648 - `web_fetch_tool_result_error_block: object`649650 - `type: "web_fetch_tool_result_error"`651652 - `error_code: "invalid_tool_input" or "url_too_long" or "url_not_allowed" or 7 more`653654 - `"invalid_tool_input"`655656 - `"url_too_long"`657658 - `"url_not_allowed"`659660 - `"url_not_in_prior_context"`661662 - `"url_not_accessible"`663664 - `"unsupported_content_type"`665666 - `"too_many_requests"`667668 - `"max_uses_exceeded"`669670 - `"unavailable"`671672 - `"content_too_large"`673674 - `web_fetch_block: object`675676 - `type: "web_fetch_result"`677678 - `content: object`679680 - `type: "document"`681682 - `citations: object`683684 Citation configuration for the document685686 - `enabled: boolean`687688 - `source: Base64PDFSource or PlainTextSource`689690 - `base64_pdf_source: object`691692 - `type: "base64"`693694 - `data: string`695696 format: byte697698 - `media_type: "application/pdf"`699700 - `plain_text_source: object`701702 - `type: "text"`703704 - `data: string`705706 - `media_type: "text/plain"`707708 - `title: string`709710 The title of the document711712 - `retrieved_at: string`713714 ISO 8601 timestamp when the content was retrieved715716 - `url: string`717718 Fetched content URL719720 - `tool_use_id: string`721722 pattern: ^srvtoolu_[a-zA-Z0-9_]+$723724 - `code_execution_tool_result_block: object`725726 - `type: "code_execution_tool_result"`727728 - `content: CodeExecutionToolResultError or CodeExecutionResultBlock or EncryptedCodeExecutionResultBlock`729730 - `code_execution_tool_result_error: object`731732 - `type: "code_execution_tool_result_error"`733734 - `error_code: "invalid_tool_input" or "unavailable" or "too_many_requests" or "execution_time_exceeded"`735736 - `"invalid_tool_input"`737738 - `"unavailable"`739740 - `"too_many_requests"`741742 - `"execution_time_exceeded"`743744 - `code_execution_result_block: object`745746 - `type: "code_execution_result"`747748 - `content: array of CodeExecutionOutputBlock`749750 - `type: "code_execution_output"`751752 - `file_id: string`753754 - `return_code: number`755756 - `stderr: string`757758 - `stdout: string`759760 - `encrypted_code_execution_result_block: object`761762 Code execution result with encrypted stdout for PFC + web_search results.763764 - `type: "encrypted_code_execution_result"`765766 - `content: array of CodeExecutionOutputBlock`767768 - `type: "code_execution_output"`769770 - `file_id: string`771772 - `encrypted_stdout: string`773774 - `return_code: number`775776 - `stderr: string`777778 - `tool_use_id: string`779780 pattern: ^srvtoolu_[a-zA-Z0-9_]+$781782 - `bash_code_execution_tool_result_block: object`783784 - `type: "bash_code_execution_tool_result"`785786 - `content: BashCodeExecutionToolResultError or BashCodeExecutionResultBlock`787788 - `bash_code_execution_tool_result_error: object`789790 - `type: "bash_code_execution_tool_result_error"`791792 - `error_code: "invalid_tool_input" or "unavailable" or "too_many_requests" or 2 more`793794 - `"invalid_tool_input"`795796 - `"unavailable"`797798 - `"too_many_requests"`799800 - `"execution_time_exceeded"`801802 - `"output_file_too_large"`803804 - `bash_code_execution_result_block: object`805806 - `type: "bash_code_execution_result"`807808 - `content: array of BashCodeExecutionOutputBlock`809810 - `type: "bash_code_execution_output"`811812 - `file_id: string`813814 - `return_code: number`815816 - `stderr: string`817818 - `stdout: string`819820 - `tool_use_id: string`821822 pattern: ^srvtoolu_[a-zA-Z0-9_]+$823824 - `text_editor_code_execution_tool_result_block: object`825826 - `type: "text_editor_code_execution_tool_result"`827828 - `content: TextEditorCodeExecutionToolResultError or TextEditorCodeExecutionViewResultBlock or TextEditorCodeExecutionCreateResultBlock or TextEditorCodeExecutionStrReplaceResultBlock`829830 - `text_editor_code_execution_tool_result_error: object`831832 - `type: "text_editor_code_execution_tool_result_error"`833834 - `error_code: "invalid_tool_input" or "unavailable" or "too_many_requests" or 2 more`835836 - `"invalid_tool_input"`837838 - `"unavailable"`839840 - `"too_many_requests"`841842 - `"execution_time_exceeded"`843844 - `"file_not_found"`845846 - `error_message: string`847848 - `text_editor_code_execution_view_result_block: object`849850 - `type: "text_editor_code_execution_view_result"`851852 - `content: string`853854 - `file_type: "text" or "image" or "pdf"`855856 - `"text"`857858 - `"image"`859860 - `"pdf"`861862 - `num_lines: number`863864 - `start_line: number`865866 - `total_lines: number`867868 - `text_editor_code_execution_create_result_block: object`869870 - `type: "text_editor_code_execution_create_result"`871872 - `is_file_update: boolean`873874 - `text_editor_code_execution_str_replace_result_block: object`875876 - `type: "text_editor_code_execution_str_replace_result"`877878 - `lines: array of string`879880 - `new_lines: number`881882 - `new_start: number`883884 - `old_lines: number`885886 - `old_start: number`887888 - `tool_use_id: string`889890 pattern: ^srvtoolu_[a-zA-Z0-9_]+$891892 - `tool_search_tool_result_block: object`893894 - `type: "tool_search_tool_result"`895896 - `content: ToolSearchToolResultError or ToolSearchToolSearchResultBlock`897898 - `tool_search_tool_result_error: object`899900 - `type: "tool_search_tool_result_error"`901902 - `error_code: "invalid_tool_input" or "unavailable" or "too_many_requests" or "execution_time_exceeded"`903904 - `"invalid_tool_input"`905906 - `"unavailable"`907908 - `"too_many_requests"`909910 - `"execution_time_exceeded"`911912 - `error_message: string`913914 - `tool_search_tool_search_result_block: object`915916 - `type: "tool_search_tool_search_result"`917918 - `tool_references: array of ToolReferenceBlock`919920 - `type: "tool_reference"`921922 - `tool_name: string`923924 maxLength: 256, minLength: 1, pattern: ^[a-zA-Z0-9_-]{1,256}$925926 - `tool_use_id: string`927928 pattern: ^srvtoolu_[a-zA-Z0-9_]+$929930 - `container_upload_block: object`931932 Response model for a file uploaded to the container.933934 - `type: "container_upload"`935936 - `file_id: string`937938 - `model: "claude-fable-5-1" or "claude-mythos-5-1" or "claude-sonnet-5" or 14 more or string`939940 The model that will complete your prompt.941942 See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.943944 - `"claude-fable-5-1"`945946 Frontier intelligence for ambitious tasks across coding, scientific discovery, and enterprise workflows947948 - `"claude-mythos-5-1"`949950 Our most capable model for cybersecurity and biology research, available through trusted access programs951952 - `"claude-sonnet-5"`953954 High-performance model for coding and agents955956 - `"claude-fable-5"`957958 Next generation of intelligence for the hardest knowledge work and coding problems959960 - `"claude-mythos-5"`961962 Most capable model for cybersecurity and biology research963964 - `"claude-opus-5"`965966 Powerful intelligence for long-running agents and coding967968 - `"claude-opus-4-8"`969970 Powerful intelligence for long-running agents and coding971972 - `"claude-opus-4-7"`973974 Powerful intelligence for long-running agents and coding975976 - `"claude-mythos-preview"`977978 New class of intelligence, strongest in coding and cybersecurity979980 - `"claude-opus-4-6"`981982 Powerful intelligence for long-running agents and coding983984 - `"claude-sonnet-4-6"`985986 Best combination of speed and intelligence987988 - `"claude-haiku-4-5"`989990 Fastest model with near-frontier intelligence991992 - `"claude-haiku-4-5-20251001"`993994 Fastest model with near-frontier intelligence995996 - `"claude-opus-4-5"`997998 Powerful intelligence for long-running agents and coding9991000 - `"claude-opus-4-5-20251101"`10011002 Powerful intelligence for long-running agents and coding10031004 - `"claude-sonnet-4-5"`10051006 High-performance model for agents and coding10071008 - `"claude-sonnet-4-5-20250929"`10091010 High-performance model for agents and coding10111012 - `role: "assistant"`10131014 Conversational role of the generated message.10151016 This will always be `"assistant"`.10171018 - `stop_details: object`10191020 Structured information about a refusal.10211022 - `type: "refusal"`10231024 - `category: "cyber" or "bio" or "frontier_llm" or 2 more`10251026 The policy category that triggered a refusal.10271028 - `"cyber"`10291030 The request could enable cyber harm, such as malware or exploit development. Benign cybersecurity work can also trigger this category.10311032 - `"bio"`10331034 The request could enable biological harm, such as dangerous lab methods. Beneficial life sciences work can also trigger this category.10351036 - `"frontier_llm"`10371038 The request could assist the development of competing AI models, which is restricted under [Anthropic's commercial terms](https://www.anthropic.com/legal/commercial-terms). Benign machine learning work can also trigger this category.10391040 - `"reasoning_extraction"`10411042 The request asks the model to reproduce its internal reasoning in the response text. To get reasoning in a structured form instead, use [adaptive thinking](https://platform.claude.com/docs/en/build-with-claude/adaptive-thinking).10431044 - `"general_harms"`10451046 The request could be related to an area that was determined as harmful. Benign work might sometimes trigger this category.10471048 - `explanation: string`10491050 Human-readable explanation of the refusal.10511052 This text is not guaranteed to be stable. `null` when no explanation is available for the category.10531054 - `stop_reason: "end_turn" or "max_tokens" or "stop_sequence" or 4 more`10551056 The reason that we stopped.10571058 This may be one the following values:10591060 * `"end_turn"`: the model reached a natural stopping point1061 * `"max_tokens"`: we exceeded the requested `max_tokens` or the model's maximum1062 * `"stop_sequence"`: one of your provided custom `stop_sequences` was generated1063 * `"tool_use"`: the model invoked one or more tools1064 * `"pause_turn"`: we paused a long-running turn. You may provide the response back as-is in a subsequent request to let the model continue.1065 * `"refusal"`: when streaming classifiers intervene to handle potential policy violations1066 * `"model_context_window_exceeded"`: we exceeded the model's context window10671068 In non-streaming mode this value is always non-null. In streaming mode, it is null in the `message_start` event and non-null otherwise.10691070 - `"end_turn"`10711072 - `"max_tokens"`10731074 - `"stop_sequence"`10751076 - `"tool_use"`10771078 - `"pause_turn"`10791080 - `"refusal"`10811082 - `"model_context_window_exceeded"`10831084 - `stop_sequence: string`10851086 Which custom stop sequence was generated, if any.10871088 This value will be a non-null string if one of your custom stop sequences was generated.10891090 - `usage: object`10911092 Billing and rate-limit usage.10931094 Anthropic's API bills and rate-limits by token counts, as tokens represent the underlying cost to our systems.10951096 Under the hood, the API transforms requests into a format suitable for the model. The model's output then goes through a parsing stage before becoming an API response. As a result, the token counts in `usage` will not match one-to-one with the exact visible content of an API request or response.10971098 For example, `output_tokens` will be non-zero, even for an empty string response from Claude.10991100 Total input tokens in a request is the summation of `input_tokens`, `cache_creation_input_tokens`, and `cache_read_input_tokens`.11011102 - `cache_creation: object`11031104 Breakdown of cached tokens by TTL11051106 - `ephemeral_1h_input_tokens: number`11071108 The number of input tokens used to create the 1 hour cache entry.11091110 minimum: 011111112 - `ephemeral_5m_input_tokens: number`11131114 The number of input tokens used to create the 5 minute cache entry.11151116 minimum: 011171118 - `cache_creation_input_tokens: number`11191120 The number of input tokens used to create the cache entry.11211122 minimum: 011231124 - `cache_read_input_tokens: number`11251126 The number of input tokens read from the cache.11271128 minimum: 011291130 - `inference_geo: string`11311132 The geographic region where inference was performed for this request.11331134 - `input_tokens: number`11351136 The number of input tokens which were used.11371138 minimum: 011391140 - `output_tokens: number`11411142 The number of output tokens which were used.11431144 minimum: 011451146 - `output_tokens_details: object`11471148 Breakdown of output tokens by category.11491150 `output_tokens` remains the inclusive, authoritative total used for billing.1151 This object provides a read-only decomposition for observability — for example,1152 how many of the billed output tokens were spent on internal reasoning that may1153 have been summarized before being returned to you.11541155 - `thinking_tokens: number`11561157 Number of output tokens the model generated as internal reasoning, including1158 the thinking-block delimiter tokens.11591160 Reflects the raw reasoning the model produced, not the (possibly shorter)1161 summarized thinking text returned in the response body. Computed by1162 re-tokenizing the raw reasoning text, so it may differ from the model's exact1163 generation count by a small number of tokens. Always ≤ `output_tokens`;1164 `output_tokens - thinking_tokens` approximates the non-reasoning output.11651166 minimum: 011671168 - `server_tool_use: object`11691170 The number of server tool requests.11711172 - `web_fetch_requests: number`11731174 The number of web fetch tool requests.11751176 minimum: 011771178 - `web_search_requests: number`11791180 The number of web search tool requests.11811182 minimum: 011831184 - `service_tier: "standard" or "priority" or "batch"`11851186 If the request used the priority, standard, or batch tier.11871188 - `"standard"`11891190 - `"priority"`11911192 - `"batch"`11931194- `raw_message_stream_event: RawMessageStartEvent or RawMessageDeltaEvent or RawMessageStopEvent or 3 more`11951196 - `raw_message_start_event: object`11971198 - `type: "message_start"`11991200 - `message: object`12011202 - `type: "message"`12031204 Object type.12051206 For Messages, this is always `"message"`.12071208 - `id: string`12091210 Unique object identifier.12111212 The format and length of IDs may change over time.12131214 - `container: object`12151216 Information about the container used in the request (for the code execution tool)12171218 - `content: array of ContentBlock`12191220 Content generated by the model.12211222 This is an array of content blocks, each of which has a `type` that determines its shape.12231224 Example:12251226 ```json1227 [{"type": "text", "text": "Hi, I'm Claude."}]1228 ```12291230 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.12311232 For example, if the input `messages` were:12331234 ```json1235 [1236 {"role": "user", "content": "What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun"},1237 {"role": "assistant", "content": "The best answer is ("}1238 ]1239 ```12401241 Then the response `content` might be:12421243 ```json1244 [{"type": "text", "text": "B)"}]1245 ```12461247 - `model: "claude-fable-5-1" or "claude-mythos-5-1" or "claude-sonnet-5" or 14 more or string`12481249 The model that will complete your prompt.12501251 See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.12521253 - `role: "assistant"`12541255 Conversational role of the generated message.12561257 This will always be `"assistant"`.12581259 - `stop_details: object`12601261 Structured information about a refusal.12621263 - `stop_reason: "end_turn" or "max_tokens" or "stop_sequence" or 4 more`12641265 The reason that we stopped.12661267 This may be one the following values:12681269 * `"end_turn"`: the model reached a natural stopping point1270 * `"max_tokens"`: we exceeded the requested `max_tokens` or the model's maximum1271 * `"stop_sequence"`: one of your provided custom `stop_sequences` was generated1272 * `"tool_use"`: the model invoked one or more tools1273 * `"pause_turn"`: we paused a long-running turn. You may provide the response back as-is in a subsequent request to let the model continue.1274 * `"refusal"`: when streaming classifiers intervene to handle potential policy violations1275 * `"model_context_window_exceeded"`: we exceeded the model's context window12761277 In non-streaming mode this value is always non-null. In streaming mode, it is null in the `message_start` event and non-null otherwise.12781279 - `stop_sequence: string`12801281 Which custom stop sequence was generated, if any.12821283 This value will be a non-null string if one of your custom stop sequences was generated.12841285 - `usage: object`12861287 Billing and rate-limit usage.12881289 Anthropic's API bills and rate-limits by token counts, as tokens represent the underlying cost to our systems.12901291 Under the hood, the API transforms requests into a format suitable for the model. The model's output then goes through a parsing stage before becoming an API response. As a result, the token counts in `usage` will not match one-to-one with the exact visible content of an API request or response.12921293 For example, `output_tokens` will be non-zero, even for an empty string response from Claude.12941295 Total input tokens in a request is the summation of `input_tokens`, `cache_creation_input_tokens`, and `cache_read_input_tokens`.12961297 - `raw_message_delta_event: object`12981299 - `type: "message_delta"`13001301 - `delta: object`13021303 - `container: object`13041305 Information about the container used in the request (for the code execution tool)13061307 - `id: string`13081309 Identifier for the container used in this request13101311 - `expires_at: string`13121313 The time at which the container will expire.13141315 format: date-time13161317 - `skills: array of ContainerSkill`13181319 Skills loaded in the container13201321 - `stop_details: object`13221323 Structured information about a refusal.13241325 - `type: "refusal"`13261327 - `category: "cyber" or "bio" or "frontier_llm" or 2 more`13281329 The policy category that triggered a refusal.13301331 - `explanation: string`13321333 Human-readable explanation of the refusal.13341335 This text is not guaranteed to be stable. `null` when no explanation is available for the category.13361337 - `stop_reason: "end_turn" or "max_tokens" or "stop_sequence" or 4 more`13381339 - `"end_turn"`13401341 - `"max_tokens"`13421343 - `"stop_sequence"`13441345 - `"tool_use"`13461347 - `"pause_turn"`13481349 - `"refusal"`13501351 - `"model_context_window_exceeded"`13521353 - `stop_sequence: string`13541355 - `usage: object`13561357 Billing and rate-limit usage.13581359 Anthropic's API bills and rate-limits by token counts, as tokens represent the underlying cost to our systems.13601361 Under the hood, the API transforms requests into a format suitable for the model. The model's output then goes through a parsing stage before becoming an API response. As a result, the token counts in `usage` will not match one-to-one with the exact visible content of an API request or response.13621363 For example, `output_tokens` will be non-zero, even for an empty string response from Claude.13641365 Total input tokens in a request is the summation of `input_tokens`, `cache_creation_input_tokens`, and `cache_read_input_tokens`.13661367 - `cache_creation_input_tokens: number`13681369 The cumulative number of input tokens used to create the cache entry.13701371 minimum: 013721373 - `cache_read_input_tokens: number`13741375 The cumulative number of input tokens read from the cache.13761377 minimum: 013781379 - `input_tokens: number`13801381 The cumulative number of input tokens which were used.13821383 minimum: 013841385 - `output_tokens: number`13861387 The cumulative number of output tokens which were used.13881389 - `output_tokens_details: object`13901391 Breakdown of output tokens by category.13921393 `output_tokens` remains the inclusive, authoritative total used for billing.1394 This object provides a read-only decomposition for observability — for example,1395 how many of the billed output tokens were spent on internal reasoning that may1396 have been summarized before being returned to you.13971398 - `thinking_tokens: number`13991400 Number of output tokens the model generated as internal reasoning, including1401 the thinking-block delimiter tokens.14021403 Reflects the raw reasoning the model produced, not the (possibly shorter)1404 summarized thinking text returned in the response body. Computed by1405 re-tokenizing the raw reasoning text, so it may differ from the model's exact1406 generation count by a small number of tokens. Always ≤ `output_tokens`;1407 `output_tokens - thinking_tokens` approximates the non-reasoning output.14081409 minimum: 014101411 - `server_tool_use: object`14121413 The number of server tool requests.14141415 - `web_fetch_requests: number`14161417 The number of web fetch tool requests.14181419 minimum: 014201421 - `web_search_requests: number`14221423 The number of web search tool requests.14241425 minimum: 014261427 - `raw_message_stop_event: object`14281429 - `type: "message_stop"`14301431 - `raw_content_block_start_event: object`14321433 - `type: "content_block_start"`14341435 - `content_block: TextBlock or ThinkingBlock or RedactedThinkingBlock or 9 more`14361437 - `text_block: object`14381439 - `type: "text"`14401441 - `citations: array of TextCitation`14421443 Citations supporting the text block.14441445 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`.14461447 - `text: string`14481449 minLength: 014501451 - `thinking_block: object`14521453 - `type: "thinking"`14541455 - `signature: string`14561457 A value used to verify that this thinking block was generated by Claude when it is passed back to the API.14581459 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.14601461 See [extended thinking](https://platform.claude.com/docs/en/build-with-claude/extended-thinking) for details.14621463 - `thinking: string`14641465 The text of Claude's thinking process for this block.14661467 - `redacted_thinking_block: object`14681469 - `type: "redacted_thinking"`14701471 - `data: string`14721473 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.14741475 Pass `redacted_thinking` blocks back to the API unchanged when continuing a multi-turn conversation.14761477 See [extended thinking](https://platform.claude.com/docs/en/build-with-claude/extended-thinking#redacted-thinking-blocks) for details.14781479 - `tool_use_block: object`14801481 - `type: "tool_use"`14821483 - `id: string`14841485 pattern: ^[a-zA-Z0-9_-]+$14861487 - `caller: DirectCaller or ServerToolCaller or ServerToolCaller20260120`14881489 - `input: map[unknown]`14901491 - `name: string`14921493 minLength: 114941495 - `toolset_name: optional string`14961497 For a toolset member tool_use, the toolset family.14981499 maxLength: 64, minLength: 1, pattern: ^[a-zA-Z0-9_-]+$15001501 - `server_tool_use_block: object`15021503 - `type: "server_tool_use"`15041505 - `id: string`15061507 pattern: ^srvtoolu_[a-zA-Z0-9_]+$15081509 - `caller: DirectCaller or ServerToolCaller or ServerToolCaller20260120`15101511 - `input: map[unknown]`15121513 - `name: "web_search" or "web_fetch" or "code_execution" or 4 more`15141515 - `web_search_tool_result_block: object`15161517 - `type: "web_search_tool_result"`15181519 - `caller: DirectCaller or ServerToolCaller or ServerToolCaller20260120`15201521 - `content: WebSearchToolResultError or array of WebSearchResultBlock`15221523 - `tool_use_id: string`15241525 pattern: ^srvtoolu_[a-zA-Z0-9_]+$15261527 - `web_fetch_tool_result_block: object`15281529 - `type: "web_fetch_tool_result"`15301531 - `caller: DirectCaller or ServerToolCaller or ServerToolCaller20260120`15321533 - `content: WebFetchToolResultErrorBlock or WebFetchBlock`15341535 - `tool_use_id: string`15361537 pattern: ^srvtoolu_[a-zA-Z0-9_]+$15381539 - `code_execution_tool_result_block: object`15401541 - `type: "code_execution_tool_result"`15421543 - `content: CodeExecutionToolResultError or CodeExecutionResultBlock or EncryptedCodeExecutionResultBlock`15441545 - `tool_use_id: string`15461547 pattern: ^srvtoolu_[a-zA-Z0-9_]+$15481549 - `bash_code_execution_tool_result_block: object`15501551 - `type: "bash_code_execution_tool_result"`15521553 - `content: BashCodeExecutionToolResultError or BashCodeExecutionResultBlock`15541555 - `tool_use_id: string`15561557 pattern: ^srvtoolu_[a-zA-Z0-9_]+$15581559 - `text_editor_code_execution_tool_result_block: object`15601561 - `type: "text_editor_code_execution_tool_result"`15621563 - `content: TextEditorCodeExecutionToolResultError or TextEditorCodeExecutionViewResultBlock or TextEditorCodeExecutionCreateResultBlock or TextEditorCodeExecutionStrReplaceResultBlock`15641565 - `tool_use_id: string`15661567 pattern: ^srvtoolu_[a-zA-Z0-9_]+$15681569 - `tool_search_tool_result_block: object`15701571 - `type: "tool_search_tool_result"`15721573 - `content: ToolSearchToolResultError or ToolSearchToolSearchResultBlock`15741575 - `tool_use_id: string`15761577 pattern: ^srvtoolu_[a-zA-Z0-9_]+$15781579 - `container_upload_block: object`15801581 Response model for a file uploaded to the container.15821583 - `type: "container_upload"`15841585 - `file_id: string`15861587 - `index: number`15881589 - `raw_content_block_delta_event: object`15901591 - `type: "content_block_delta"`15921593 - `delta: TextDelta or InputJSONDelta or CitationsDelta or 2 more`15941595 - `text_delta: object`15961597 - `type: "text_delta"`15981599 - `text: string`16001601 - `input_json_delta: object`16021603 - `type: "input_json_delta"`16041605 - `partial_json: string`16061607 - `citations_delta: object`16081609 - `type: "citations_delta"`16101611 - `citation: CitationCharLocation or CitationPageLocation or CitationContentBlockLocation or 2 more`16121613 - `citation_char_location: object`16141615 - `type: "char_location"`16161617 - `cited_text: string`16181619 - `document_index: number`16201621 minimum: 016221623 - `document_title: string`16241625 - `end_char_index: number`16261627 - `file_id: string`16281629 - `start_char_index: number`16301631 minimum: 016321633 - `citation_page_location: object`16341635 - `type: "page_location"`16361637 - `cited_text: string`16381639 - `document_index: number`16401641 minimum: 016421643 - `document_title: string`16441645 - `end_page_number: number`16461647 - `file_id: string`16481649 - `start_page_number: number`16501651 minimum: 116521653 - `citation_content_block_location: object`16541655 - `type: "content_block_location"`16561657 - `cited_text: string`16581659 The full text of the cited block range, concatenated.16601661 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.16621663 - `document_index: number`16641665 minimum: 016661667 - `document_title: string`16681669 - `end_block_index: number`16701671 Exclusive 0-based end index of the cited block range in the source's `content` array.16721673 Always greater than `start_block_index`; a single-block citation has `end_block_index = start_block_index + 1`.16741675 - `file_id: string`16761677 - `start_block_index: number`16781679 0-based index of the first cited block in the source's `content` array.16801681 minimum: 016821683 - `citations_web_search_result_location: object`16841685 - `type: "web_search_result_location"`16861687 - `cited_text: string`16881689 - `encrypted_index: string`16901691 - `title: string`16921693 maxLength: 51216941695 - `url: string`16961697 - `citations_search_result_location: object`16981699 - `type: "search_result_location"`17001701 - `cited_text: string`17021703 The full text of the cited block range, concatenated.17041705 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.17061707 - `end_block_index: number`17081709 Exclusive 0-based end index of the cited block range in the source's `content` array.17101711 Always greater than `start_block_index`; a single-block citation has `end_block_index = start_block_index + 1`.17121713 - `search_result_index: number`17141715 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.17161717 Counted separately from `document_index`; server-side web search results are not included in this count.17181719 minimum: 017201721 - `source: string`17221723 - `start_block_index: number`17241725 0-based index of the first cited block in the source's `content` array.17261727 minimum: 017281729 - `title: string`17301731 - `thinking_delta: object`17321733 - `type: "thinking_delta"`17341735 - `thinking: string`17361737 The incremental `thinking` text for this content block. Concatenate the `thinking` values of successive `thinking_delta` events to assemble the block's full `thinking` value.17381739 - `signature_delta: object`17401741 - `type: "signature_delta"`17421743 - `signature: string`17441745 The `signature` for this thinking block: an opaque value used to verify that the block was generated by Claude when it is passed back to the API. Delivered in a `signature_delta` event just before the block's `content_block_stop` event.17461747 - `index: number`17481749 - `raw_content_block_stop_event: object`17501751 - `type: "content_block_stop"`17521753 - `index: number`17541755## Example17561757```bash1758ant messages create \1759 --api-key my-anthropic-api-key \1760 --max-tokens 1024 \1761 --message '{content: [{text: x, type: text}], role: user}' \1762 --model claude-opus-51763```17641765### Response (200)17661767```json1768{1769 "id": "msg_013Zva2CMHLNnXjNJJKqJ2EF",1770 "container": {1771 "id": "container_011CpZohnwH4vuy7gazohgSP",1772 "expires_at": "2019-12-27T18:11:19.117Z",1773 "skills": [1774 {1775 "skill_id": "pdf",1776 "type": "anthropic",1777 "version": "latest"1778 }1779 ]1780 },1781 "content": [1782 {1783 "citations": [1784 {1785 "cited_text": "The grass is green. The sky is blue.",1786 "document_index": 0,1787 "document_title": "My Document",1788 "end_char_index": 0,1789 "file_id": "file_011CNha8iCJcU1wXNR6q4V8w",1790 "start_char_index": 0,1791 "type": "char_location"1792 }1793 ],1794 "text": "Hi! My name is Claude.",1795 "type": "text"1796 }1797 ],1798 "model": "claude-opus-5",1799 "role": "assistant",1800 "stop_details": {1801 "category": "cyber",1802 "explanation": "This request was declined because it conflicts with Anthropic's Usage Policy.",1803 "type": "refusal"1804 },1805 "stop_reason": "end_turn",1806 "stop_sequence": null,1807 "type": "message",1808 "usage": {1809 "cache_creation": {1810 "ephemeral_1h_input_tokens": 0,1811 "ephemeral_5m_input_tokens": 01812 },1813 "cache_creation_input_tokens": 2051,1814 "cache_read_input_tokens": 2051,1815 "inference_geo": "global",1816 "input_tokens": 2095,1817 "output_tokens": 503,1818 "output_tokens_details": {1819 "thinking_tokens": 01820 },1821 "server_tool_use": {1822 "web_fetch_requests": 2,1823 "web_search_requests": 01824 },1825 "service_tier": "standard"1826 }1827}1828```1829