Create a Message
/anthropic/v1/messages● SupportedRequest body
modelstringrequired◐ Partially supportedBody param: The model that will complete your prompt.
See models for additional details and options.
deepseek-v4-pro, glm-5.3-flash, qwen3.8-flash and claude-opus-5 can be called; deepseek-v4-flash returns 400 on this face.
max_tokensnumberrequiredBody param: 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
0to populate the prompt cache without generating a response.Different models have different maximum values for this parameter. See models for details.
Limits output tokens, including reasoning.
messagesarrayrequired◐ Partially supportedBody param: Input messages.
Our models are trained to operate on alternating
userandassistantconversational turns. When creating a newMessage, you specify the prior conversational turns with themessagesparameter, and the model then generates the nextMessagein the conversation. Consecutiveuserorassistantturns in your request will be combined into a single turn.Each input message must be an object with a
roleandcontent. You can specify a singleuser-role message, or you can include multipleuserandassistantmessages.If the final message uses the
assistantrole, 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
usermessage:[{ "role": "user", "content": "Hello, Claude" }]Example with multiple conversational turns:
[ { "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:
[ { "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
contentmay be either a singlestringor an array of content blocks, where each block has a specifictype. Using astringforcontentis shorthand for an array of one content block of type"text". The following input messages are equivalent:{ "role": "user", "content": "Hello, Claude" }{ "role": "user", "content": [{ "type": "text", "text": "Hello, Claude" }] }See input examples.
Note that if you want to include a system prompt, you can use the top-level
systemparameter — there is no"system"role for input messages in the Messages API.There is a limit of 100,000 messages in a single request.
Text and tool round trips work. Managed document file_id returns 400; qwen3.8-flash can read inline PDFs. Images have model-specific size limits.
Expand sub-fields (2)
contentstring | arrayrequiredMessage content: a plain string (shorthand for one text block) or an array of content blocks such as text, image, document, tool_use and tool_result.
rolestringrequiredWho produced the message. Use user for your turns and assistant to replay earlier model turns; system-role messages are accepted by the shape but system instructions normally go in the top-level system field.
streambooleanoptional◐ Partially supportedBody param: Whether to incrementally stream the response using server-sent events.
See streaming for details.
Content and tool streaming work; extra message_delta events may precede content and message_start usage is zero.
systemstring | arrayoptionalBody param: 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.
Verified to take effect.
temperaturenumberoptionaltop_pnumberoptionaltop_knumberoptionalstop_sequencesarrayoptional◐ Partially supportedBody param: 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_reasonof"end_turn".If you want the model to stop generating when it encounters custom strings of text, you can use the
stop_sequencesparameter. If the model encounters one of the custom sequences, the responsestop_reasonvalue will be"stop_sequence"and the responsestop_sequencevalue will contain the matched stop sequence.Works on deepseek-v4-pro and qwen3.8-flash; glm-5.3-flash truncates text but does not report accurate stop_reason/stop_sequence.
toolsarrayoptionalBody param: Definitions of tools that the model may use.
If you include
toolsin your API request, the model may returntool_usecontent 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 usingtool_resultcontent blocks.There are two types of tools: client tools and server tools. The behavior described below applies to client tools. For server tools, see their individual documentation as each has its own behavior (e.g., the 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 for the toolinputshape that the model will produce intool_useoutput content blocks.
For example, if you defined
toolsas:[ { "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_usecontent blocks in the response like this:[ { "type": "tool_use", "id": "toolu_01D7FLrfh4GYq7yT1ULFeyMV", "name": "get_stock_price", "input": { "ticker": "^GSPC" } } ]You might then run your
get_stock_pricetool with{"ticker": "^GSPC"}as an input, and return the following back to the model in a subsequentusermessage:[ { "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 for more details.
Verified to take effect.
More parameters (16)
tool_choiceobjectoptional◐ Partially supportedBody 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.
All four modes work on qwen3.8-flash; deepseek-v4-pro ignores any/tool/none and glm-5.3-flash ignores none.
Expand sub-fields (3)
typestringrequireddisable_parallel_tool_usebooleanoptional○ Currently ignoredWhether to disable parallel tool use.
Defaults to
false. If set totrue, the model will output at most one tool use. Whether to disable parallel tool use.Defaults to
false. If set totrue, the model will output exactly one tool use. Not used when type is none.Accepted but currently has no effect. true may still return multiple tool calls.
namestringoptionalThe name of the tool to use. Required when type is tool. Not used when type is auto, any, none.
metadataobjectoptional◐ Partially supportedBody param: An object describing metadata about the request.
Accepts metadata; metadata.user_id is carried on same-protocol lines without promising an upstream echo.
Expand sub-fields (1)
user_idstringoptionalAn 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.
cache_controlobjectoptional◐ Partially supportedBody param: Top-level cache control automatically applies a cache_control marker to the last cacheable block in the request.
Implicit cache hits occur on deepseek-v4-pro, qwen3.8-flash and glm-5.3-flash, but do not establish that the marker controls caching. No hits were observed on claude-opus-5, and ttl=1h had no observed effect.
Expand sub-fields (2)
typestringrequiredAlways
ephemeral. Discriminator that marks this object as a CacheControlEphemeral in atype-tagged union.ttlstringoptionalThe time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to
5m. See prompt caching pricing for details.
containerstring | objectoptional○ Currently ignoredAccepted and ignored; the platform does not implement container.
Expand sub-fields (2)
idstringoptionalContainer id
skillsarrayoptionalList of skills to load in the container
inference_geostringoptional○ Currently ignoredAccepted and ignored; the platform does not implement inference_geo.
output_configobjectoptionalBody param: Configuration options for the model's output, such as the output format.
Expand sub-fields (2)
effortstringoptional◐ Partially supportedAll possible effort levels.
Only high/xhigh work on deepseek-v4-pro; other levels return 400. All levels return 400 on qwen3.8-flash. glm-5.3-flash accepts levels but usage is not monotonic.
formatobjectoptional◐ Partially supportedA schema to specify Claude's output format in responses. See structured outputs
json_schema works on deepseek-v4-pro and qwen3.8-flash; glm-5.3-flash returns 400 when combined with thinking.
service_tierstringoptional○ Currently ignoredAccepted and ignored; the platform does not implement service_tier.
thinkingobjectoptional◐ Partially supportedBody param: Configuration for enabling Claude's extended thinking.
When enabled, responses include
thinkingcontent blocks showing Claude's thinking process before the final answer. Requires a minimum budget of 1,024 tokens and counts towards yourmax_tokenslimit.See extended thinking for details.
disabled works on deepseek-v4-pro and qwen3.8-flash; any thinking parameter returns 400 on glm-5.3-flash. adaptive also returns 400 on tested deepseek-v4-pro and qwen3.8-flash.
Expand sub-fields (3)
budget_tokensnumberoptional◐ Partially supportedDetermines 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 for details. Required when type is enabled. Not used when type is disabled, adaptive.
Accepted on deepseek-v4-pro and qwen3.8-flash but is not a reliable upper bound; glm-5.3-flash returns 400.
typestringrequireddisplaystringoptional○ Currently ignoredControls how thinking content appears in the response. When set to
summarized, thinking is returned normally. When set toomitted, thinking content is redacted but a signature is returned for multi-turn continuity. Defaults tosummarized. Not used when type is disabled.Accepted but currently has no effect. omitted still returns the full thinking content.
context_managementobjectoptional○ Currently ignoredAccepted and ignored; the platform does not implement context_management.
diagnosticsobjectoptional○ Currently ignoredAccepted and ignored; the platform does not implement diagnostics.
mcp_serversarrayoptional○ Currently ignoredAccepted and ignored; the platform does not implement mcp_servers.
speedstringoptional○ Currently ignoredAccepted and ignored; the platform does not implement speed.
output_formatobjectoptional○ Currently ignoredAccepted and ignored legacy field; use output_config.format for structured output.
compactionobjectoptional○ UnsupportedRecognized compaction; not implemented, and returns 400 explicitly stating that the parameter is not supported.
fallback_credit_tokenstringoptional○ UnsupportedRecognized fallback_credit_token; not implemented, and returns 400 explicitly stating that the parameter is not supported.
fallbacksstringoptional○ UnsupportedRecognized fallbacks; not implemented, and returns 400 explicitly stating that the parameter is not supported.
Returns
200
With stream=true the reply streams as server-sent events (text/event-stream).
Preserves top-level cache_control, top_k, metadata.user_id, output_config.format, thinking.display and anthropic-user-profile-id. Native-only options restrict routing; requests fail when no provider can preserve them. Nonempty anthropic-workspace-id returns 400. container, inference_geo and service_tier are accepted and ignored; see field support for other extensions. Unknown top-level fields are forwarded unchanged to same-protocol upstream providers, which decide whether to accept them. Declared fields still undergo type and range validation; invalid values return 400 naming the field.
Errors follow the Anthropic format — see error codes
Request
curl
curl https://api.deepraxis.com/anthropic/v1/messages \
-H "x-api-key: $PRAXIS_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{"model":"deepseek-flash","max_tokens":1024,"messages":[{"role":"user","content":"你好"}]}'Python
from anthropic import Anthropic
client = Anthropic(
base_url="https://api.deepraxis.com/anthropic",
api_key="$PRAXIS_API_KEY",
)
resp = client.messages.create(
model="deepseek-flash",
max_tokens=1024,
messages=[{"role": "user", "content": "你好"}],
)TypeScript
import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({
baseURL: "https://api.deepraxis.com/anthropic",
apiKey: "$PRAXIS_API_KEY",
});
const resp = await client.messages.create({
model: "deepseek-flash",
max_tokens: 1024,
messages: [{ role: "user", content: "你好" }],
});Response 200
{
"id": "msg_61427fb1-be8c-421e-8e7a-156815f9ded3",
"type": "message",
"role": "assistant",
"model": "deepseek-flash",
"content": [
{
"type": "thinking",
"thinking": "The user simply said \"你好\" (Hello) in Chinese. I should respond warmly in Chinese and offer assistance. Keep it brief and friendly.",
"signature": "62d86872-4f3a-456f-a67d-62719a3cd20b"
},
{
"type": "text",
"text": "你好!很高兴见到你 😊\n\n有什么我可以帮你的吗?无论是聊天、解答问题、写作、翻译,还是其他任何需要,都可以告诉我。",
"citations": null
}
],
"stop_reason": "end_turn",
"stop_sequence": null,
"usage": {
"input_tokens": 31,
"cache_creation_input_tokens": 0,
"cache_read_input_tokens": 0,
"output_tokens": 62,
"service_tier": "standard",
"cache_creation": null,
"inference_geo": null,
"output_tokens_details": null,
"server_tool_use": null
},
"container": null,
"stop_details": null
}Response
HTTP 200
Message created
application/json
| Name | Type | Description |
|---|---|---|
| id | string | Unique object identifier. The format and length of IDs may change over time. |
| container | null | object | Information about the container used in the request (for the code execution tool) |
| container.id | string | Identifier for the container used in this request |
| container.expires_at | string | The time at which the container will expire. |
| container.skills | null | array<object> | Skills loaded in the container |
| content | array<object> | 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 inputmessagesended with anassistantturn, then the responsecontentwill continue directly from that last turn. You can use this to constrain the model's output. For example, if the inputmessageswere: `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 responsecontentmight be: `json [{ "type": "text", "text": "B)" }] `` |
| content[].citations | null | array<object> | 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. |
| content[].text | string | The text generated by the model. |
| content[].type | string | Always text. Discriminator that marks this object as a TextBlock in a type-tagged union. / Always thinking. Discriminator that marks this object as a ThinkingBlock in a type-tagged union. / Always redacted_thinking. Discriminator that marks this object as a RedactedThinkingBlock in a type-tagged union. / Always tool_use. Discriminator that marks this object as a ToolUseBlock in a type-tagged union. / Always server_tool_use. Discriminator that marks this object as a ServerToolUseBlock in a type-tagged union. / Always web_search_tool_result. Discriminator that marks this object as a WebSearchToolResultBlock in a type-tagged union. / Always web_fetch_tool_result. Discriminator that marks this object as a WebFetchToolResultBlock in a type-tagged union. / Always code_execution_tool_result. Discriminator that marks this object as a CodeExecutionToolResultBlock in a type-tagged union. / Always bash_code_execution_tool_result. Discriminator that marks this object as a BashCodeExecutionToolResultBlock in a type-tagged union. / Always text_editor_code_execution_tool_result. Discriminator that marks this object as a TextEditorCodeExecutionToolResultBlock in a type-tagged union. / Always tool_search_tool_result. Discriminator that marks this object as a ToolSearchToolResultBlock in a type-tagged union. / Always container_upload. Discriminator that marks this object as a ContainerUploadBlock in a type-tagged union. |
| content[].signature | string | 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 for details. |
| content[].thinking | string | The text of Claude's thinking process for this block. |
| content[].data | string | 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 for details. |
| content[].id | string | Id of the tool call; send it back as tool_use_id in the tool_result block that answers it. / Id of the server tool call; the matching result block repeats it as tool_use_id. |
| content[].caller | object | Which party invoked the tool: the model directly or a code execution tool. / Which party invoked the server tool: the model directly or a code execution tool. / Which party invoked the search: the model directly or a code execution tool. / Which party invoked the fetch: the model directly or a code execution tool. |
| content[].input | any | Arguments the model chose, as a JSON object that follows the tool's input_schema. / Arguments the model passed to the server tool, as a JSON object. |
| content[].name | string | Name of the tool the model wants to call. / Name of the server tool the model called, such as web_search, web_fetch or code_execution. |
| content[].toolset_name | null | string | For a toolset member tool_use, the toolset family. |
| content[].content | object | array<object> | object | object | object | object | object | Search results (array of web_search_result blocks) or an error object. / The fetched document or an error object. / Result of the code execution: a result block, an encrypted result block, or an error object. / Result of the bash command: a result block or an error object. / Result of the text editor command: a view, create or str_replace result block, or an error object. / Result of the tool search: a search result block that lists tool references, or an error object. |
| content[].tool_use_id | string | Id of the web_search server tool call this result belongs to. / Id of the web_fetch server tool call this result belongs to. / Id of the code_execution server tool call this result belongs to. / Id of the bash_code_execution server tool call this result belongs to. / Id of the text_editor_code_execution server tool call this result belongs to. / Id of the tool search server tool call this result belongs to. |
| content[].file_id | string | Id of the file that was uploaded into the code execution container. |
| model | string | The model that will complete your prompt. See models for additional details and options. |
| role | string | Conversational role of the generated message. This will always be "assistant". |
| stop_details | null | object | Structured information about a refusal. |
| stop_details.category | null | string | The policy category that triggered a refusal. - cyber - The request could enable cyber harm, such as malware or exploit development. Benign cybersecurity work can also trigger this category. - bio - The request could enable biological harm, such as dangerous lab methods. Beneficial life sciences work can also trigger this category. - frontier_llm - The request could assist the development of competing AI models, which is restricted under Anthropic's commercial terms. Benign machine learning work can also trigger this category. - reasoning_extraction - 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. - general_harms - The request could be related to an area that was determined as harmful. Benign work might sometimes trigger this category. |
| stop_details.explanation | null | string | Human-readable explanation of the refusal. This text is not guaranteed to be stable. null when no explanation is available for the category. |
| stop_details.type | string | Always refusal. Discriminator that marks this object as a RefusalStopDetails in a type-tagged union. |
| stop_reason | null | string | The reason that we stopped. This may be one the following values: - "end_turn": the model reached a natural stopping point - "max_tokens": we exceeded the requested max_tokens or the model's maximum - "stop_sequence": one of your provided custom stop_sequences was generated - "tool_use": the model invoked one or more tools - "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. - "refusal": when streaming classifiers intervene to handle potential policy violations - "model_context_window_exceeded": we exceeded the model's context window 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. |
| stop_sequence | null | string | 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. |
| type | string | Object type. For Messages, this is always "message". |
| usage | object | Billing and rate-limit usage. Anthropic's API bills and rate-limits by token counts, as tokens represent the underlying cost to our systems. 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. For example, output_tokens will be non-zero, even for an empty string response from Claude. Total input tokens in a request is the summation of input_tokens, cache_creation_input_tokens, and cache_read_input_tokens. |
| usage.cache_creation | null | object | Breakdown of cached tokens by TTL |
| usage.cache_creation_input_tokens | null | number | The number of input tokens used to create the cache entry. |
| usage.cache_read_input_tokens | null | number | The number of input tokens read from the cache. |
| usage.inference_geo | null | string | The geographic region where inference was performed for this request. |
| usage.input_tokens | number | The number of input tokens which were used. |
| usage.output_tokens | number | The number of output tokens which were used. |
| usage.output_tokens_details | null | object | Breakdown of output tokens by category. output_tokens remains the inclusive, authoritative total used for billing. This object provides a read-only decomposition for observability — for example, how many of the billed output tokens were spent on internal reasoning that may have been summarized before being returned to you. |
| usage.server_tool_use | null | object | The number of server tool requests. |
| usage.service_tier | null | string | If the request used the priority, standard, or batch tier. |
text/event-stream — chunk / event object
| Name | Type | Description |
|---|---|---|
| delta | object | Final fields of the message sent with message_delta: why generation stopped and the container. / The incremental change to the content block at index. |
| delta.container | null | object | Information about the container used in the request (for the code execution tool) |
| delta.stop_details | null | object | Structured information about a refusal. |
| delta.stop_reason | null | string | Why the model stopped; null while the message is still generating. |
| delta.stop_sequence | null | string | The custom stop sequence that was matched; null unless stop_reason is stop_sequence. |
| delta.text | string | Text fragment to append to the text block. |
| delta.type | string | Always text_delta. Discriminator that marks this object as a TextDelta in a type-tagged union. / Always input_json_delta. Discriminator that marks this object as a InputJSONDelta in a type-tagged union. / Always citations_delta. Discriminator that marks this object as a CitationsDelta in a type-tagged union. / Always thinking_delta. Discriminator that marks this object as a ThinkingDelta in a type-tagged union. / Always signature_delta. Discriminator that marks this object as a SignatureDelta in a type-tagged union. |
| delta.partial_json | string | Fragment of the tool input JSON string; concatenate all fragments of a block and parse the result when the block stops. |
| delta.citation | object | The citation to attach to the text block being streamed. |
| delta.thinking | string | 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. |
| delta.signature | string | 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. |
| type | string | Always message_delta. Discriminator that marks this object as a RawMessageDeltaEvent in a type-tagged union. / Always content_block_delta. Discriminator that marks this object as a RawContentBlockDeltaEvent in a type-tagged union. / Always message_start. Discriminator that marks this object as a RawMessageStartEvent in a type-tagged union. / Always message_stop. Discriminator that marks this object as a RawMessageStopEvent in a type-tagged union. / Always content_block_start. Discriminator that marks this object as a RawContentBlockStartEvent in a type-tagged union. / Always content_block_stop. Discriminator that marks this object as a RawContentBlockStopEvent in a type-tagged union. |
| usage | object | Billing and rate-limit usage. Anthropic's API bills and rate-limits by token counts, as tokens represent the underlying cost to our systems. 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. For example, output_tokens will be non-zero, even for an empty string response from Claude. Total input tokens in a request is the summation of input_tokens, cache_creation_input_tokens, and cache_read_input_tokens. |
| usage.cache_creation_input_tokens | null | number | The cumulative number of input tokens used to create the cache entry. |
| usage.cache_read_input_tokens | null | number | The cumulative number of input tokens read from the cache. |
| usage.input_tokens | null | number | The cumulative number of input tokens which were used. |
| usage.output_tokens | number | The cumulative number of output tokens which were used. |
| usage.output_tokens_details | null | object | Breakdown of output tokens by category. output_tokens remains the inclusive, authoritative total used for billing. This object provides a read-only decomposition for observability — for example, how many of the billed output tokens were spent on internal reasoning that may have been summarized before being returned to you. |
| usage.server_tool_use | null | object | The number of server tool requests. |
| index | number | Zero-based index of the content block this delta applies to. / Zero-based index of the content block that starts. / Zero-based index of the content block that ends. |
| message | object | The complete Message object being started; its content is empty at message_start and filled by the following content_block events. |
| message.id | string | Unique object identifier. The format and length of IDs may change over time. |
| message.container | null | object | Information about the container used in the request (for the code execution tool) |
| message.content | array<object> | 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 inputmessagesended with anassistantturn, then the responsecontentwill continue directly from that last turn. You can use this to constrain the model's output. For example, if the inputmessageswere: `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 responsecontentmight be: `json [{ "type": "text", "text": "B)" }] `` |
| message.model | string | The model that will complete your prompt. See models for additional details and options. |
| message.role | string | Conversational role of the generated message. This will always be "assistant". |
| message.stop_details | null | object | Structured information about a refusal. |
| message.stop_reason | null | string | The reason that we stopped. This may be one the following values: - "end_turn": the model reached a natural stopping point - "max_tokens": we exceeded the requested max_tokens or the model's maximum - "stop_sequence": one of your provided custom stop_sequences was generated - "tool_use": the model invoked one or more tools - "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. - "refusal": when streaming classifiers intervene to handle potential policy violations - "model_context_window_exceeded": we exceeded the model's context window 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. |
| message.stop_sequence | null | string | 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. |
| message.type | string | Object type. For Messages, this is always "message". |
| message.usage | object | Billing and rate-limit usage. Anthropic's API bills and rate-limits by token counts, as tokens represent the underlying cost to our systems. 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. For example, output_tokens will be non-zero, even for an empty string response from Claude. Total input tokens in a request is the summation of input_tokens, cache_creation_input_tokens, and cache_read_input_tokens. |
| content_block | object | The content block as it starts, with empty text or input to be filled by deltas. |
| content_block.citations | null | array<object> | 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. |
| content_block.text | string | The text generated by the model. |
| content_block.type | string | Always text. Discriminator that marks this object as a TextBlock in a type-tagged union. / Always thinking. Discriminator that marks this object as a ThinkingBlock in a type-tagged union. / Always redacted_thinking. Discriminator that marks this object as a RedactedThinkingBlock in a type-tagged union. / Always tool_use. Discriminator that marks this object as a ToolUseBlock in a type-tagged union. / Always server_tool_use. Discriminator that marks this object as a ServerToolUseBlock in a type-tagged union. / Always web_search_tool_result. Discriminator that marks this object as a WebSearchToolResultBlock in a type-tagged union. / Always web_fetch_tool_result. Discriminator that marks this object as a WebFetchToolResultBlock in a type-tagged union. / Always code_execution_tool_result. Discriminator that marks this object as a CodeExecutionToolResultBlock in a type-tagged union. / Always bash_code_execution_tool_result. Discriminator that marks this object as a BashCodeExecutionToolResultBlock in a type-tagged union. / Always text_editor_code_execution_tool_result. Discriminator that marks this object as a TextEditorCodeExecutionToolResultBlock in a type-tagged union. / Always tool_search_tool_result. Discriminator that marks this object as a ToolSearchToolResultBlock in a type-tagged union. / Always container_upload. Discriminator that marks this object as a ContainerUploadBlock in a type-tagged union. |
| content_block.signature | string | 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 for details. |
| content_block.thinking | string | The text of Claude's thinking process for this block. |
| content_block.data | string | 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 for details. |
| content_block.id | string | Id of the tool call; send it back as tool_use_id in the tool_result block that answers it. / Id of the server tool call; the matching result block repeats it as tool_use_id. |
| content_block.caller | object | Which party invoked the tool: the model directly or a code execution tool. / Which party invoked the server tool: the model directly or a code execution tool. / Which party invoked the search: the model directly or a code execution tool. / Which party invoked the fetch: the model directly or a code execution tool. |
| content_block.input | any | Arguments the model chose, as a JSON object that follows the tool's input_schema. / Arguments the model passed to the server tool, as a JSON object. |
| content_block.name | string | Name of the tool the model wants to call. / Name of the server tool the model called, such as web_search, web_fetch or code_execution. |
| content_block.toolset_name | null | string | For a toolset member tool_use, the toolset family. |
| content_block.content | object | array<object> | object | object | object | object | object | Search results (array of web_search_result blocks) or an error object. / The fetched document or an error object. / Result of the code execution: a result block, an encrypted result block, or an error object. / Result of the bash command: a result block or an error object. / Result of the text editor command: a view, create or str_replace result block, or an error object. / Result of the tool search: a search result block that lists tool references, or an error object. |
| content_block.tool_use_id | string | Id of the web_search server tool call this result belongs to. / Id of the web_fetch server tool call this result belongs to. / Id of the code_execution server tool call this result belongs to. / Id of the bash_code_execution server tool call this result belongs to. / Id of the text_editor_code_execution server tool call this result belongs to. / Id of the tool search server tool call this result belongs to. |
| content_block.file_id | string | Id of the file that was uploaded into the code execution container. |