Skip to content

Anthropic Models ​

http
POST /v1/messages

Send a structured list of input messages with text and/or image content, and the model will generate the next message in the conversation. The Messages API can be used for either single queries or stateless multi-turn conversations.

Parameters ​

Request Body ​

ParameterTypeRequiredDefaultDescription
max_tokensintYes-Maximum number of tokens to generate (including thinking and response content), the hard limit for total output. Models may stop before reaching this value. Set to 0 to pre-warm the prompt cache without generating a response. Different models have different maximum values. This parameter is required for Anthropic (can be omitted with this platform's API Key; the platform fills in a default value, but you can also set it freely)
messagesarrayYes-Input messages, each with a role (user/assistant) and content. Consecutive same-role messages are combined into a single turn; if the final message is assistant, the response continues from it (prefill)
modelstringYes-The model that will complete your prompt
cache_controlobjectNo-Top-level cache control automatically applies a cache_control marker to the last cacheable block in the request
containerobject or stringNo-Container identifier for reuse across requests (code execution tool)
context_managementobjectNo-Context management configuration, controls how the model manages context across requests (e.g. whether to clear tool results)
diagnosticsobjectNo-Request-level diagnostics, currently carries the previous response id for prompt-cache divergence reporting
fallback_credit_tokenstring or objectNo-The token from a prior refusal's stop_details. Pass it when retrying a refused request to have the prefix's cache-creation tokens billed at the cache-read rate. Requires the same organization and workspace, same request body, an eligible fallback model, the same platform, and redemption within 5 minutes of the refusal
fallbacksarray or "default"No-Opt-in server-side retry on one or more substitute models when the requested model declines for policy reasons. Tried in order. The string "default" requests the model's server-defined default fallback configuration
inference_geostringNo-Specifies the geographic region for inference processing; defaults to the workspace's default_inference_geo
mcp_serversarrayNo-MCP servers (URL definitions) to be utilized in this request, max 20
metadataobjectNo-Request metadata, can include a user_id field to identify the end-user (for abuse monitoring and tracking), e.g. {"user_id": "user-123"}
output_configobjectNo-Configuration options for the model's output, such as the output format
output_formatobjectNo-Deprecated: Use output_config.format instead. A schema to specify the output format in responses; will be removed in a future release
service_tierstringNoautoService tier: auto (use priority capacity if available) / standard_only (standard capacity only)
speedstringNo-Inference speed mode: standard / fast. fast provides significantly faster output token generation at premium pricing; not all models support it, invalid combinations are rejected at create time
stop_sequencesarrayNo-Custom stop sequences. Generation stops immediately when any sequence is generated; stop_reason becomes stop_sequence and the response stop_sequence field contains the matched sequence
streamboolNofalseWhether to enable SSE streaming output, see Streaming Response
systemstring or arrayNo-System prompt for setting the assistant's behavior, role, context, and constraints. Can be a string or an array of text blocks (for more complex instructions), effective throughout the conversation
thinkingobjectNo-Extended thinking configuration for enabling reasoning capabilities (requires model support), see Thinking Parameters
tool_choiceobjectNoautoControls tool use, see tool_choice Parameters
toolsarrayNo-Tool definitions, see tools Fields and Tool Use Example
temperaturefloatNo1.0Deprecated: Models released after Opus 4.6 do not support setting temperature. Only 1.0 is accepted for backwards compatibility; other values return 400
top_kintNo-Deprecated: Models released after Opus 4.6 do not accept top_k; any value returns 400
top_pfloatNo-Deprecated: Models released after Opus 4.6 do not support top_p. Only values >= 0.99 are accepted for backwards compatibility; other values return 400

Request Headers ​

ParameterTypeRequiredDescription
betaarrayNoOptional header to specify the beta version(s) you want to use
user_profile_idstringNoThe user profile ID to attribute this request to (when acting on behalf of a party other than your organization). Requires the user-profiles beta header
workspace_idstringNoSelects the Workspace for this request (e.g. wrkspc_011CZkZaBF1tNoB5wlCeusgy). Only needed for credentials that can act on more than one Workspace; a credential belonging to a specific Workspace may omit it, and if sent it must match that Workspace

Thinking Parameters ​

ParameterTypeRequiredDescription
typestringYesadaptive (recommended, the model decides when and how deeply to think) / enabled (specify a thinking budget, supported by older models, deprecated) / disabled (disable thinking)
budget_tokensintNoThinking token budget when type is enabled, minimum 1024, counts towards max_tokens

Differences in thinking configuration across models:

  • cl-op-4.7 and higher (including cl-op-4.8), cl-so-5, and other newer models: only support adaptive thinking "thinking": {"type": "adaptive"}. Using the old "type": "enabled", "budget_tokens": N format returns a 400 error.
  • cl-op-4.6 / cl-so-4.6 and other older models: can still use "thinking": {"type": "enabled", "budget_tokens": N} (where budget_tokens must be less than max_tokens), but this format is deprecated. It's recommended to switch to adaptive thinking.

tool_choice Parameters ​

type ValueFieldsDescription
auto-The model decides whether to use tools (default)
any-Must use at least one tool
toolnameForce use of a specific tool; name is the tool name
none-Do not use any tools

tools Fields ​

FieldTypeRequiredDescription
namestringYesName of the tool
descriptionstringNoOptional but strongly recommended description of the tool
input_schemaobjectYesJSON Schema for the tool input shape that the model will produce in tool_use output content blocks

Tool Use Example ​

After defining tools in the request, the model may return tool_use content blocks representing tool invocations. After you run the tool, return the result to the model as a tool_result content block to continue the conversation.

bash
curl --location --request POST 'https://neolink.com/api/v1/messages' \
     --header 'Content-Type: application/json' \
     --header 'Authorization: Bearer <API Key>' \
     --data-raw '{
         "model": "<Model ID>",
         "max_tokens": 1024,
         "tools": [
             {
                 "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"]
                 }
             }
         ],
         "messages": [
             {"role": "user", "content": "What is the S&P 500 at today?"}
         ]
     }'

The model returns a tool_use content block (with stop_reason set to tool_use):

json
[
    {
        "type": "tool_use",
        "id": "toolu_01D7FLrfh4GYq7yT1ULFeyMV",
        "name": "get_stock_price",
        "input": { "ticker": "^GSPC" }
    }
]

After running the tool, return the result in a subsequent user message as a tool_result content block:

bash
curl --location --request POST 'https://neolink.com/api/v1/messages' \
     --header 'Content-Type: application/json' \
     --header 'Authorization: Bearer <API Key>' \
     --data-raw '{
         "model": "<Model ID>",
         "max_tokens": 1024,
         "tools": [
             {
                 "name": "get_stock_price",
                 "description": "Get the current stock price for a given ticker symbol.",
                 "input_schema": {
                     "type": "object",
                     "properties": {
                         "ticker": {"type": "string"}
                     },
                     "required": ["ticker"]
                 }
             }
         ],
         "messages": [
             {"role": "user", "content": "What is the S&P 500 at today?"},
             {"role": "assistant", "content": [
                 {"type": "tool_use", "id": "toolu_01D7FLrfh4GYq7yT1ULFeyMV", "name": "get_stock_price", "input": {"ticker": "^GSPC"}}
             ]},
             {"role": "user", "content": [
                 {"type": "tool_result", "tool_use_id": "toolu_01D7FLrfh4GYq7yT1ULFeyMV", "content": "259.75 USD"}
             ]}
         ]
     }'

Request Example ​

bash
curl --location --request POST 'https://neolink.com/api/v1/messages' \
     --header 'Content-Type: application/json' \
     --header 'Authorization: Bearer <API Key>' \
     --data-raw '{
         "model": "<Model ID>",
         "max_tokens": 1024,
         "messages": [
             {
                 "role": "user",
                 "content": "hello"
             }
         ]
     }'
python
import requests

url = "https://neolink.com/api/v1/messages"

headers = {
    "Authorization": "Bearer <API Key>",
    "Content-Type": "application/json",
}

payload = {
    "model": "<Model ID>",
    "max_tokens": 1024,
    "messages": [
        {
            "role": "user",
            "content": "hello"
        }
    ]
}

resp = requests.post(url, headers=headers, json=payload, timeout=30)
resp.raise_for_status()
data = resp.json()

reply = "".join(
    item["text"]
    for item in data.get("content", [])
    if item.get("type") == "text"
)

print("Assistant reply:")
print(reply)
bash
curl --location --request POST 'https://neolink.com/api/v1/messages' \
     --header 'Content-Type: application/json' \
     --header 'Authorization: Bearer <API Key>' \
     --data-raw '{
         "model": "<Model ID>",
         "max_tokens": 1024,
         "messages": [
             {"role": "user", "content": "Hello, introduce yourself in one sentence."},
             {"role": "assistant", "content": "Hi, I am an AI assistant."},
             {"role": "user", "content": "Can you be more specific?"}
         ]
     }'
bash
curl --location --request POST 'https://neolink.com/api/v1/messages' \
     --header 'Content-Type: application/json' \
     --header 'Authorization: Bearer <API Key>' \
     --data-raw '{
         "model": "<Model ID>",
         "max_tokens": 1024,
         "system": "You are a professional translator. Translate user input into English.",
         "messages": [
             {"role": "user", "content": "The weather is really nice today."}
         ]
     }'
bash
curl --location --request POST 'https://neolink.com/api/v1/messages' \
     --header 'Content-Type: application/json' \
     --header 'Authorization: Bearer <API Key>' \
     --data-raw '{
         "model": "<Model ID>",
         "max_tokens": 1024,
         "messages": [
             {"role": "user", "content": "What is the Greek name for Sun? (A) Sol (B) Helios (C) Sun"},
             {"role": "assistant", "content": "The best answer is ("}
         ]
     }'

Notes:

  • Models are trained to operate on alternating user / assistant turns; consecutive same-role messages are combined into a single turn.
  • If the final message uses the assistant role, the response content continues immediately from that message (assistant prefill), which can constrain part of the output.
  • Each message's content can be a string or an array of content blocks; a string is shorthand for a single text block: {"type": "text", "text": "..."}.
  • There is no system role in the Messages API; pass the system prompt via the top-level system parameter.
  • A single request is limited to 100,000 messages.

Returns ​

Response Body ​

ParameterTypeDescription
typestringObject type, always message
idstringUnique message identifier
containerobjectInformation about the container used in the request (code execution tool), see container Parameters
contentarrayArray of content blocks generated by the model, see Content Block Types
context_managementobjectInformation about context management strategies applied during the request, see context_management Parameters
diagnosticsobjectResponse envelope for request-level diagnostics, see diagnostics Parameters; returned only when diagnostics was supplied on the request
modelstringThe model that completed this request
rolestringConversational role, always assistant
stop_detailsobjectStructured information about a refusal, see stop_details
stop_reasonstringThe reason we stopped, see stop_reason Values
stop_sequencestringWhich custom stop sequence was generated, null if none
usageobjectUsage statistics, see usage Fields
input_transformationsarrayChanges the API made to the request's input before showing it to the model, see input_transformations Parameters; requires the thinking-binding-controls-2026-08-01 beta

container Parameters ​

ParameterTypeDescription
idstringIdentifier for the container used in this request
expires_atstringThe time at which the container will expire, format: date-time
skillsarraySkills loaded in the container
skills[].typestringType of skill: anthropic (built-in) / custom (user-defined)
skills[].skill_idstringSkill ID, length 1~64
skills[].versionstringThe resolved version: a skill version ID for custom skills, length 1~64

Content Block Types ​

typeDescription
textText content, see text Block Fields
thinkingThinking process, see thinking Block Fields
redacted_thinkingSafety-redacted thinking content, see redacted_thinking Block Fields
tool_useTool invocation request, see tool_use Block Fields
server_tool_useServer-side tool invocation, see server_tool_use Block Fields
web_search_tool_resultWeb search tool result, see web_search_tool_result Block Fields
web_fetch_tool_resultWeb fetch tool result, see web_fetch_tool_result Block Fields
advisor_tool_resultAdvisor tool result, see advisor_tool_result Block Fields
code_execution_tool_resultCode execution tool result, see code_execution_tool_result Block Fields
bash_code_execution_tool_resultBash code execution tool result, see bash_code_execution_tool_result Block Fields
text_editor_code_execution_tool_resultText editor code execution tool result, see text_editor_code_execution_tool_result Block Fields
tool_search_tool_resultTool search result, see tool_search_tool_result Block Fields
mcp_tool_useMCP tool invocation, see mcp_tool_use Block Fields
mcp_tool_resultMCP tool result, see mcp_tool_result Block Fields
container_uploadA file uploaded to the container, see container_upload Block Fields
compactionCompaction block returned when autocompact is triggered, see compaction Block Fields
fallbackMarks the point in content where one model's output gives way to the next, see fallback Block Fields

text Block Fields ​

ParameterTypeDescription
typestringAlways text
textstringText content, minimum length 0
citationsarrayCitations supporting the text block, see Citation Types

Citation Types ​

The citation type depends on the cited document type: citing a PDF results in page_location, plain text results in char_location, and content document results in content_block_location.

typeFieldsDescription
char_locationcited_text, document_index, document_title, end_char_index, start_char_index, file_idCharacter location citation for plain text; document_index/start_char_index minimum 0
page_locationcited_text, document_index, document_title, end_page_number, start_page_number, file_idPage location citation for PDFs; start_page_number minimum 1
content_block_locationcited_text, document_index, document_title, end_block_index, start_block_index, file_idContent block location citation; end_block_index is an exclusive end index, a single-block citation has end_block_index = start_block_index + 1; cited_text is not counted toward input/output tokens
web_search_result_locationcited_text, encrypted_index, title, urlWeb search result citation; title max length 512
search_result_locationcited_text, end_block_index, start_block_index, search_result_index, source, titleSearch result content block citation; search_result_index is the 0-based index among all search_result content blocks in the request (counted separately from document_index)

thinking Block Fields ​

ParameterTypeDescription
typestringAlways thinking
thinkingstringThe text of Claude's thinking process for this block
signaturestringA value used to verify that this thinking block was generated by Claude when passed back to the API. Opaque field, should not be interpreted or parsed; pass back exactly as received (required when using tools with extended thinking)

redacted_thinking Block Fields ​

ParameterTypeDescription
typestringAlways redacted_thinking
datastringThe contents of this redacted thinking block, opaque and encrypted with no readable content. Pass back unchanged when continuing a multi-turn conversation

tool_use Block Fields ​

ParameterTypeDescription
typestringAlways tool_use
idstringTool invocation ID, pattern: ^[a-zA-Z0-9_-]+$
namestringTool name, minimum length 1
inputobjectTool input generated by the model
callerobjectOptional. Invocation source: direct (directly from the model) / code_execution_20250825, code_execution_20260120 (generated by a server-side tool, contains tool_id with srvtoolu_ prefix)
toolset_namestringOptional. For a toolset member tool_use, the toolset family, length 1~64

server_tool_use Block Fields ​

ParameterTypeDescription
typestringAlways server_tool_use
idstringInvocation ID, pattern: ^srvtoolu_[a-zA-Z0-9_]+$
namestringServer tool name: advisor / web_search / web_fetch / code_execution / bash_code_execution / text_editor_code_execution / tool_search_tool_regex / tool_search_tool_bm25
inputobjectTool input
callerobjectOptional. Invocation source, same as tool_use block's caller

web_search_tool_result Block Fields ​

ParameterTypeDescription
typestringAlways web_search_tool_result
tool_use_idstringThe corresponding invocation ID, pattern: ^srvtoolu_[a-zA-Z0-9_]+$
contentobject or arrayError object (type is web_search_tool_result_error, error_code such as invalid_tool_input / unavailable / max_uses_exceeded / too_many_requests / query_too_long / request_too_large, etc.), or an array of results
content[].typestringAlways web_search_result
content[].urlstringResult URL
content[].titlestringResult title
content[].page_agestringPage age
content[].encrypted_contentstringEncrypted content snapshot
callerobjectOptional. Invocation source, same as tool_use block's caller

web_fetch_tool_result Block Fields ​

ParameterTypeDescription
typestringAlways web_fetch_tool_result
tool_use_idstringThe corresponding invocation ID, pattern: ^srvtoolu_[a-zA-Z0-9_]+$
contentobjectError object (type is web_fetch_tool_result_error, error_code such as 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 / content_too_large, etc.), or the fetch result
content.typestringAlways web_fetch_result on success
content.urlstringFetched content URL
content.retrieved_atstringISO 8601 timestamp when the content was retrieved
content.contentobjectThe fetched document: type is document, title is the document title, citations.enabled is the citation configuration, source is base64 (media_type: application/pdf) or text (media_type: text/plain)
callerobjectOptional. Invocation source, same as tool_use block's caller

advisor_tool_result Block Fields ​

ParameterTypeDescription
typestringAlways advisor_tool_result
tool_use_idstringThe corresponding invocation ID, pattern: ^srvtoolu_[a-zA-Z0-9_]+$
contentobjectError object (type is advisor_tool_result_error, error_code such as max_uses_exceeded / prompt_too_long / too_many_requests / overloaded / unavailable / execution_time_exceeded / model_not_found, etc.), or a result block
content.typestringadvisor_result (contains text and stop_reason) or advisor_redacted_result (contains encrypted encrypted_content and stop_reason)
content.textstringThe advisor sub-inference's output text
content.stop_reasonstringThe advisor sub-inference's stop reason (same values as the top-level message stop_reason)
content.encrypted_contentstringOpaque encrypted blob containing the advisor's output; round-trip verbatim, do not inspect or modify

code_execution_tool_result Block Fields ​

ParameterTypeDescription
typestringAlways code_execution_tool_result
tool_use_idstringThe corresponding invocation ID, pattern: ^srvtoolu_[a-zA-Z0-9_]+$
contentobjectError object (type is code_execution_tool_result_error, error_code: invalid_tool_input / unavailable / too_many_requests / execution_time_exceeded), or a result block
content.typestringcode_execution_result or encrypted_code_execution_result (encrypted stdout, for PFC + web_search results)
content.contentarrayOutput file list, each with type (code_execution_output) and file_id
content.return_codeintProcess return code
content.stdoutstringStandard output (encrypted_stdout in the encrypted variant)
content.stderrstringStandard error

bash_code_execution_tool_result Block Fields ​

ParameterTypeDescription
typestringAlways bash_code_execution_tool_result
tool_use_idstringThe corresponding invocation ID, pattern: ^srvtoolu_[a-zA-Z0-9_]+$
contentobjectError object (type is bash_code_execution_tool_result_error, error_code such as invalid_tool_input / unavailable / too_many_requests / execution_time_exceeded / output_file_too_large, etc.), or a result block
content.typestringAlways bash_code_execution_result
content.contentarrayOutput file list, each with type (code_execution_output) and file_id
content.return_codeintProcess return code
content.stdoutstringStandard output
content.stderrstringStandard error

text_editor_code_execution_tool_result Block Fields ​

ParameterTypeDescription
typestringAlways text_editor_code_execution_tool_result
tool_use_idstringThe corresponding invocation ID, pattern: ^srvtoolu_[a-zA-Z0-9_]+$
contentobjectError object (type is text_editor_code_execution_tool_result_error, contains error_code such as invalid_tool_input / unavailable / too_many_requests / execution_time_exceeded / file_not_found, etc. and error_message), or one of the following four result blocks
content.typestringtext_editor_code_execution_view_result (view: content, file_type (text/image/pdf), num_lines, start_line, total_lines) / text_editor_code_execution_create_result (create: is_file_update) / text_editor_code_execution_str_replace_result (replace: lines, new_lines, new_start, old_lines, old_start)

tool_search_tool_result Block Fields ​

ParameterTypeDescription
typestringAlways tool_search_tool_result
tool_use_idstringThe corresponding invocation ID, pattern: ^srvtoolu_[a-zA-Z0-9_]+$
contentobjectError object (type is tool_search_tool_result_error, contains error_code and error_message), or the search result block
content.typestringAlways tool_search_tool_search_result
content.tool_referencesarrayMatched tool references, each with type (tool_reference) and tool_name (length 1~256)

mcp_tool_use Block Fields ​

ParameterTypeDescription
typestringAlways mcp_tool_use
idstringInvocation ID, pattern: ^[a-zA-Z0-9_-]+$
namestringThe name of the MCP tool
server_namestringThe name of the MCP server
inputobjectTool input

mcp_tool_result Block Fields ​

ParameterTypeDescription
typestringAlways mcp_tool_result
tool_use_idstringThe corresponding invocation ID, pattern: ^[a-zA-Z0-9_-]+$
contentstring or arrayTool result: a string, or an array of text blocks (each with type (text), text, optional citations)
is_errorboolWhether this is an error result

container_upload Block Fields ​

ParameterTypeDescription
typestringAlways container_upload
file_idstringThe uploaded file's ID

compaction Block Fields ​

ParameterTypeDescription
typestringAlways compaction
contentstringSummary of compacted content, or null if compaction failed (clients may round-trip with null content; the server treats them as no-ops)
encrypted_contentstringOpaque metadata from prior compaction, to be round-tripped verbatim

fallback Block Fields ​

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 and declined; whether a fallback model served the response is signalled by the presence of a fallback_message entry in usage.iterations, not this block. For streaming, the block arrives via the standard content_block_start / content_block_stop pair and carries no deltas.

ParameterTypeDescription
typestringAlways fallback
from.modelstringThe model whose output ends at this point (the model that declined): echoes the top-level model string the caller sent when the declining hop is the requested model; the canonical id when it is a fallback model
to.modelstringThe fallback model producing the content that follows, always the canonical id
trigger.typestringAlways refusal
trigger.categorystringThe policy category that triggered the refusal: cyber (cyber harm) / bio (biological harm) / frontier_llm (competing AI model development) / reasoning_extraction (reproducing internal reasoning) / general_harms (other harmful areas)

context_management Parameters ​

ParameterTypeDescription
applied_editsarrayList of context management edits that were applied, see table below

applied_edits entry types:

typeFieldsDescription
clear_tool_uses_20250919cleared_input_tokens, cleared_tool_usesClear tool uses edit; both int, minimum 0
clear_thinking_20251015cleared_input_tokens, cleared_thinking_turnsClear thinking turns edit; both int, minimum 0

diagnostics Parameters ​

ParameterTypeDescription
cache_miss_reasonobjectExplains 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)

cache_miss_reason types:

typeFieldsDescription
model_changedcache_missed_input_tokensThe model changed, causing prefix mismatch
system_changedcache_missed_input_tokensThe system prompt changed, causing prefix mismatch
tools_changedcache_missed_input_tokensThe tools changed, causing prefix mismatch
messages_changedcache_missed_input_tokensThe messages changed, causing prefix mismatch
previous_message_not_found-The previous message was not found
unavailable-Diagnosis unavailable

cache_missed_input_tokens is the approximate number of input tokens that would have been read from cache had the prefix matched the previous request.

stop_reason Values ​

ValueDescription
end_turnThe model reached a natural stopping point
max_tokensWe exceeded the requested max_tokens or the model's maximum
stop_sequenceOne of your provided custom stop sequences was generated
tool_useThe model invoked one or more tools
pause_turnWe paused a long-running turn; you may provide the response back as-is in a subsequent request to let the model continue
compactionAutocompact was triggered; the long context was replaced with a summary
refusalStreaming classifiers intervened to handle potential policy violations
model_context_window_exceededWe exceeded the model's context window

Always non-null in non-streaming mode; in streaming mode it is null in the message_start event and non-null otherwise.

stop_details ​

ParameterTypeDescription
typestringAlways refusal
categorystringThe policy category that triggered the refusal: cyber / bio / frontier_llm / reasoning_extraction / general_harms
explanationstringHuman-readable explanation of the refusal (not guaranteed to be stable), null when no explanation is available
fallback_credit_tokenstringOpaque code that refunds the cache-miss cost when retrying; pass it as fallback_credit_token on the retry request, expires 5 minutes after the refusal; the retry requires the same workspace and platform, a mismatch is a 400; null when not eligible
fallback_has_prefill_claimboolWhether the accompanying fallback_credit_token may be redeemed with the appended-assistant retry form (true: retry with the same body plus an appended assistant message; false: retry with the original body), only set when fallback_credit_token is present
recommended_modelstringThe server's suggested retry target for this refusal (returned when a fallback attempt could not be made), null otherwise

usage Fields ​

ParameterTypeDescription
input_tokensintThe number of input tokens used, minimum 0
output_tokensintThe number of output tokens used (the authoritative total for billing), minimum 0
cache_creation_input_tokensintThe number of input tokens used to create the cache entry, minimum 0
cache_read_input_tokensintThe number of input tokens read from the cache, minimum 0
cache_creationobjectBreakdown of cached tokens by TTL: ephemeral_5m_input_tokens (5-minute cache) / ephemeral_1h_input_tokens (1-hour cache), both minimum 0
server_tool_useobjectThe number of server tool requests: web_search_requests / web_fetch_requests, both minimum 0
service_tierstringThe tier used for this request: standard / priority / batch
speedstringInference speed mode: standard / fast
inference_geostringThe geographic region where inference was performed
iterationsarrayPer-iteration token usage breakdown, see iterations Parameters
output_tokens_detailsobjectBreakdown of output tokens: thinking_tokens (tokens generated as internal reasoning, including thinking-block delimiter tokens; computed by re-tokenizing the raw reasoning text, always ≤ output_tokens), minimum 0
fallback_creditobjectOutcome of the fallback_credit_token presented on this request, see fallback_credit Parameters

Total input tokens = input_tokens + cache_creation_input_tokens + cache_read_input_tokens.

iterations Parameters ​

One entry per sampling iteration, discriminated by type. message entries allow you to determine which iterations exceeded long context thresholds (>=200k tokens), calculate the context window size from the last message entry, and understand token accumulation across server-side tool use loops.

typeFieldsDescription
messageinput_tokens, output_tokens, cache_creation_input_tokens, cache_read_input_tokens, cache_creation, modelModel sampling iteration (such as the turns of a server-side tool use loop)
compactioninput_tokens, output_tokens, cache_creation_input_tokens, cache_read_input_tokens, cache_creationUsage of the compaction operation itself (NOT the size of the compacted context, can be much smaller; do not derive the context window size from a compaction entry; not included in top-level usage fields). The input-token trigger defaults to 150,000 tokens
advisor_messageinput_tokens, output_tokens, cache_creation_input_tokens, cache_read_input_tokens, cache_creation, modelAdvisor sub-inference iteration
fallback_messageinput_tokens, output_tokens, cache_creation_input_tokens, cache_read_input_tokens, cache_creation, modelThe fallback-model attempt that served the response in a server-side fallback request (produced in place of a message entry; the presence of this entry signals a fallback model served the response)

fallback_credit Parameters ​

ParameterTypeDescription
status.typestringredeemed (the retry is billed as if the conversation had been on the retry model all along) / not_applied (no reprice was applied, see reason)
status.reasonstringThe reason when not_applied: 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
status.remove_to_redeemarrayReturned exactly when reason is variant_fields_present (never null, never an empty array): request fields to remove before retrying; a corrected re-send inside the token's five-minute window can still redeem

input_transformations Parameters ​

Changes the API made to the request's input before showing it to the model: one entry per change, in request order. Today the only entry type is thinking_dropped; more entry types may be added over time, ignore types you do not recognize.

ParameterTypeDescription
typestringAlways thinking_dropped: a thinking / redacted_thinking / connector_text block from the request's messages that was removed because it failed a binding check
pathstringWhere the removed block was in your request, format messages.{i}.content.{j} (i indexes the messages array, j that message's content array)
reasonstringWhich binding check removed the block: model_binding_mismatch (created by a model whose reasoning the requested model may not read) / prefix_binding_mismatch (the conversation before it differs from the conversation it was created in; the rest of that turn's consecutive thinking blocks are removed with it) / organization_binding_mismatch (created under a different organization) / end_user_binding_mismatch (created for a different end user, or removed by the consumer-organization binding). A block failing several checks reports one reason, in this order of precedence: organization_binding_mismatch > end_user_binding_mismatch > model_binding_mismatch > prefix_binding_mismatch

Removed blocks contribute nothing to usage.input_tokens. When streaming, the array is final in message_start; the final message_delta event carries it only when a server-side model fallback happened mid-stream, in which case it holds the serving model's entries and replaces the one in message_start.

Response Example ​

json
{
  "id": "msg_01XFDUDYJgAACzvnptvVoYEL",
  "type": "message",
  "role": "assistant",
  "model": "cl-so-5",
  "content": [
    {
      "type": "text",
      "text": "Hi, I'm Claude."
    }
  ],
  "stop_reason": "end_turn",
  "stop_sequence": null,
  "usage": {
    "input_tokens": 12,
    "output_tokens": 20,
    "cache_creation_input_tokens": 0,
    "cache_read_input_tokens": 0
  }
}

Streaming Response ​

Set "stream": true in the request body and the response is returned progressively as an SSE event stream:

Event TypeDescription
message_startMessage start, contains the initial message object (only input_tokens in usage has a value at this point)
content_block_startContent block start, contains the initial empty content block
content_block_deltaContent block delta, delta.type can be text_delta (text) / input_json_delta (tool input) / thinking_delta (thinking) / signature_delta (signature) / citations_delta (citations)
content_block_stopContent block stop
message_deltaMessage-level delta, contains the final stop_reason and cumulative usage
message_stopMessage stop
pingKeep-alive heartbeat

Streaming Example ​

text
event: message_start
data: {"type":"message_start","message":{"id":"msg_01XFDUDYJgAACzvnptvVoYEL","type":"message","role":"assistant","content":[],"model":"cl-so-5","stop_reason":null,"usage":{"input_tokens":12,"output_tokens":1}}}

event: content_block_start
data: {"type":"content_block_start","index":0,"content_block":{"type":"text","text":""}}

event: content_block_delta
data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"Hi, I'm Claude."}}

event: content_block_stop
data: {"type":"content_block_stop","index":0}

event: message_delta
data: {"type":"message_delta","delta":{"stop_reason":"end_turn","stop_sequence":null},"usage":{"output_tokens":20}}

event: message_stop
data: {"type":"message_stop"}