Messages
Count tokens in a Message
ModelsExpand Collapse
type Base64ImageSource struct{…}
MediaType Base64ImageSourceMediaType
Type Base64
type Base64PDFSource struct{…}
MediaType ApplicationPDF
Type Base64
type CacheControlEphemeral struct{…}
Type Ephemeral
TTL CacheControlEphemeralTTLoptionalThe time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
type CacheCreation struct{…}
The number of input tokens used to create the 1 hour cache entry.
The number of input tokens used to create the 5 minute cache entry.
type CitationCharLocation struct{…}
Type CharLocation
type CitationCharLocationParamResp struct{…}
Type CharLocation
type CitationContentBlockLocation struct{…}
Type ContentBlockLocation
type CitationContentBlockLocationParamResp struct{…}
Type ContentBlockLocation
type CitationPageLocation struct{…}
Type PageLocation
type CitationPageLocationParamResp struct{…}
Type PageLocation
type CitationSearchResultLocationParamResp struct{…}
Type SearchResultLocation
type CitationWebSearchResultLocationParamResp struct{…}
Type WebSearchResultLocation
type CitationsConfigParamResp struct{…}
type CitationsDelta struct{…}
Citation CitationsDeltaCitationUnion
type CitationCharLocation struct{…}
Type CharLocation
type CitationPageLocation struct{…}
Type PageLocation
type CitationContentBlockLocation struct{…}
Type ContentBlockLocation
type CitationsWebSearchResultLocation struct{…}
Type WebSearchResultLocation
type CitationsSearchResultLocation struct{…}
Type SearchResultLocation
Type CitationsDelta
type CitationsSearchResultLocation struct{…}
Type SearchResultLocation
type CitationsWebSearchResultLocation struct{…}
Type WebSearchResultLocation
type ContentBlockUnion interface{…}
type TextBlock struct{…}
Citations []TextCitationUnionCitations 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.
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.
type CitationCharLocation struct{…}
Type CharLocation
type CitationPageLocation struct{…}
Type PageLocation
type CitationContentBlockLocation struct{…}
Type ContentBlockLocation
type CitationsWebSearchResultLocation struct{…}
Type WebSearchResultLocation
type CitationsSearchResultLocation struct{…}
Type SearchResultLocation
Type Text
type ThinkingBlock struct{…}
Type Thinking
type RedactedThinkingBlock struct{…}
Type RedactedThinking
type ToolUseBlock struct{…}
Type ToolUse
type ServerToolUseBlock struct{…}
Name WebSearch
Type ServerToolUse
type WebSearchToolResultBlock struct{…}
type WebSearchToolResultError struct{…}
ErrorCode WebSearchToolResultErrorErrorCode
Type WebSearchToolResultError
Type WebSearchResult
Type WebSearchToolResult
type ContentBlockParamUnionResp interface{…}Regular text content.
Regular text content.
type TextBlockParamResp struct{…}
Type Text
Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
Type Ephemeral
TTL CacheControlEphemeralTTLoptionalThe time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
type CitationCharLocationParamResp struct{…}
Type CharLocation
type CitationPageLocationParamResp struct{…}
Type PageLocation
type CitationContentBlockLocationParamResp struct{…}
Type ContentBlockLocation
type CitationWebSearchResultLocationParamResp struct{…}
Type WebSearchResultLocation
type CitationSearchResultLocationParamResp struct{…}
Type SearchResultLocation
type ImageBlockParamResp struct{…}
Source ImageBlockParamSourceUnionResp
type Base64ImageSource struct{…}
MediaType Base64ImageSourceMediaType
Type Base64
type URLImageSource struct{…}
Type URL
Type Image
Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
Type Ephemeral
TTL CacheControlEphemeralTTLoptionalThe time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
type DocumentBlockParamResp struct{…}
Source DocumentBlockParamSourceUnionResp
type Base64PDFSource struct{…}
MediaType ApplicationPDF
Type Base64
type PlainTextSource struct{…}
MediaType TextPlain
Type Text
type ContentBlockSource struct{…}
Content ContentBlockSourceContentUnion
type TextBlockParamResp struct{…}
Type Text
Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
Type Ephemeral
TTL CacheControlEphemeralTTLoptionalThe time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
type CitationCharLocationParamResp struct{…}
Type CharLocation
type CitationPageLocationParamResp struct{…}
Type PageLocation
type CitationContentBlockLocationParamResp struct{…}
Type ContentBlockLocation
type CitationWebSearchResultLocationParamResp struct{…}
Type WebSearchResultLocation
type CitationSearchResultLocationParamResp struct{…}
Type SearchResultLocation
type ImageBlockParamResp struct{…}
Source ImageBlockParamSourceUnionResp
type Base64ImageSource struct{…}
MediaType Base64ImageSourceMediaType
Type Base64
type URLImageSource struct{…}
Type URL
Type Image
Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
Type Ephemeral
TTL CacheControlEphemeralTTLoptionalThe time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
Type Content
type URLPDFSource struct{…}
Type URL
Type Document
Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
Type Ephemeral
TTL CacheControlEphemeralTTLoptionalThe time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
type SearchResultBlockParamResp struct{…}
Content []TextBlockParamResp
Type Text
Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
Type Ephemeral
TTL CacheControlEphemeralTTLoptionalThe time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
type CitationCharLocationParamResp struct{…}
Type CharLocation
type CitationPageLocationParamResp struct{…}
Type PageLocation
type CitationContentBlockLocationParamResp struct{…}
Type ContentBlockLocation
type CitationWebSearchResultLocationParamResp struct{…}
Type WebSearchResultLocation
type CitationSearchResultLocationParamResp struct{…}
Type SearchResultLocation
Type SearchResult
Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
Type Ephemeral
TTL CacheControlEphemeralTTLoptionalThe time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
type ThinkingBlockParamResp struct{…}
Type Thinking
type RedactedThinkingBlockParamResp struct{…}
Type RedactedThinking
type ToolUseBlockParamResp struct{…}
Type ToolUse
Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
Type Ephemeral
TTL CacheControlEphemeralTTLoptionalThe time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
type ToolResultBlockParamResp struct{…}
Type ToolResult
Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
Type Ephemeral
TTL CacheControlEphemeralTTLoptionalThe time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
Content []ToolResultBlockParamContentUnionRespoptional
[]ToolResultBlockParamContentUnionResp
type TextBlockParamResp struct{…}
Type Text
Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
Type Ephemeral
TTL CacheControlEphemeralTTLoptionalThe time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
type CitationCharLocationParamResp struct{…}
Type CharLocation
type CitationPageLocationParamResp struct{…}
Type PageLocation
type CitationContentBlockLocationParamResp struct{…}
Type ContentBlockLocation
type CitationWebSearchResultLocationParamResp struct{…}
Type WebSearchResultLocation
type CitationSearchResultLocationParamResp struct{…}
Type SearchResultLocation
type ImageBlockParamResp struct{…}
Source ImageBlockParamSourceUnionResp
type Base64ImageSource struct{…}
MediaType Base64ImageSourceMediaType
Type Base64
type URLImageSource struct{…}
Type URL
Type Image
Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
Type Ephemeral
TTL CacheControlEphemeralTTLoptionalThe time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
type SearchResultBlockParamResp struct{…}
Content []TextBlockParamResp
Type Text
Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
Type Ephemeral
TTL CacheControlEphemeralTTLoptionalThe time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
type CitationCharLocationParamResp struct{…}
Type CharLocation
type CitationPageLocationParamResp struct{…}
Type PageLocation
type CitationContentBlockLocationParamResp struct{…}
Type ContentBlockLocation
type CitationWebSearchResultLocationParamResp struct{…}
Type WebSearchResultLocation
type CitationSearchResultLocationParamResp struct{…}
Type SearchResultLocation
Type SearchResult
Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
Type Ephemeral
TTL CacheControlEphemeralTTLoptionalThe time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
type DocumentBlockParamResp struct{…}
Source DocumentBlockParamSourceUnionResp
type Base64PDFSource struct{…}
MediaType ApplicationPDF
Type Base64
type PlainTextSource struct{…}
MediaType TextPlain
Type Text
type ContentBlockSource struct{…}
Content ContentBlockSourceContentUnion
type TextBlockParamResp struct{…}
Type Text
Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
Type Ephemeral
TTL CacheControlEphemeralTTLoptionalThe time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
type CitationCharLocationParamResp struct{…}
Type CharLocation
type CitationPageLocationParamResp struct{…}
Type PageLocation
type CitationContentBlockLocationParamResp struct{…}
Type ContentBlockLocation
type CitationWebSearchResultLocationParamResp struct{…}
Type WebSearchResultLocation
type CitationSearchResultLocationParamResp struct{…}
Type SearchResultLocation
type ImageBlockParamResp struct{…}
Source ImageBlockParamSourceUnionResp
type Base64ImageSource struct{…}
MediaType Base64ImageSourceMediaType
Type Base64
type URLImageSource struct{…}
Type URL
Type Image
Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
Type Ephemeral
TTL CacheControlEphemeralTTLoptionalThe time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
Type Content
type URLPDFSource struct{…}
Type URL
Type Document
Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
Type Ephemeral
TTL CacheControlEphemeralTTLoptionalThe time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
type ServerToolUseBlockParamResp struct{…}
Name WebSearch
Type ServerToolUse
Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
Type Ephemeral
TTL CacheControlEphemeralTTLoptionalThe time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
type WebSearchToolResultBlockParamResp struct{…}
Type WebSearchResult
type WebSearchToolRequestError struct{…}
ErrorCode WebSearchToolRequestErrorErrorCode
Type WebSearchToolResultError
Type WebSearchToolResult
Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
Type Ephemeral
TTL CacheControlEphemeralTTLoptionalThe time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
type ContentBlockSource struct{…}
Content ContentBlockSourceContentUnion
type TextBlockParamResp struct{…}
Type Text
Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
Type Ephemeral
TTL CacheControlEphemeralTTLoptionalThe time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
type CitationCharLocationParamResp struct{…}
Type CharLocation
type CitationPageLocationParamResp struct{…}
Type PageLocation
type CitationContentBlockLocationParamResp struct{…}
Type ContentBlockLocation
type CitationWebSearchResultLocationParamResp struct{…}
Type WebSearchResultLocation
type CitationSearchResultLocationParamResp struct{…}
Type SearchResultLocation
type ImageBlockParamResp struct{…}
Source ImageBlockParamSourceUnionResp
type Base64ImageSource struct{…}
MediaType Base64ImageSourceMediaType
Type Base64
type URLImageSource struct{…}
Type URL
Type Image
Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
Type Ephemeral
TTL CacheControlEphemeralTTLoptionalThe time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
Type Content
type ContentBlockSourceContentItemUnion interface{…}
type TextBlockParamResp struct{…}
Type Text
Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
Type Ephemeral
TTL CacheControlEphemeralTTLoptionalThe time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
type CitationCharLocationParamResp struct{…}
Type CharLocation
type CitationPageLocationParamResp struct{…}
Type PageLocation
type CitationContentBlockLocationParamResp struct{…}
Type ContentBlockLocation
type CitationWebSearchResultLocationParamResp struct{…}
Type WebSearchResultLocation
type CitationSearchResultLocationParamResp struct{…}
Type SearchResultLocation
type ImageBlockParamResp struct{…}
Source ImageBlockParamSourceUnionResp
type Base64ImageSource struct{…}
MediaType Base64ImageSourceMediaType
Type Base64
type URLImageSource struct{…}
Type URL
Type Image
Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
Type Ephemeral
TTL CacheControlEphemeralTTLoptionalThe time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
type DocumentBlockParamResp struct{…}
Source DocumentBlockParamSourceUnionResp
type Base64PDFSource struct{…}
MediaType ApplicationPDF
Type Base64
type PlainTextSource struct{…}
MediaType TextPlain
Type Text
type ContentBlockSource struct{…}
Content ContentBlockSourceContentUnion
type TextBlockParamResp struct{…}
Type Text
Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
Type Ephemeral
TTL CacheControlEphemeralTTLoptionalThe time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
type CitationCharLocationParamResp struct{…}
Type CharLocation
type CitationPageLocationParamResp struct{…}
Type PageLocation
type CitationContentBlockLocationParamResp struct{…}
Type ContentBlockLocation
type CitationWebSearchResultLocationParamResp struct{…}
Type WebSearchResultLocation
type CitationSearchResultLocationParamResp struct{…}
Type SearchResultLocation
type ImageBlockParamResp struct{…}
Source ImageBlockParamSourceUnionResp
type Base64ImageSource struct{…}
MediaType Base64ImageSourceMediaType
Type Base64
type URLImageSource struct{…}
Type URL
Type Image
Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
Type Ephemeral
TTL CacheControlEphemeralTTLoptionalThe time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
Type Content
type URLPDFSource struct{…}
Type URL
Type Document
Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
Type Ephemeral
TTL CacheControlEphemeralTTLoptionalThe time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
type ImageBlockParamResp struct{…}
Source ImageBlockParamSourceUnionResp
type Base64ImageSource struct{…}
MediaType Base64ImageSourceMediaType
Type Base64
type URLImageSource struct{…}
Type URL
Type Image
Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
Type Ephemeral
TTL CacheControlEphemeralTTLoptionalThe time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
type InputJSONDelta struct{…}
Type InputJSONDelta
type Message struct{…}
Unique object identifier.
The format and length of IDs may change over time.
Content []ContentBlockUnionContent generated by the model.
This is an array of content blocks, each of which has a type that determines its shape.
Example:
[{"type": "text", "text": "Hi, I'm Claude."}]
If the request input messages ended with an assistant turn, then the response content will continue directly from that last turn. You can use this to constrain the model's output.
For example, if the input messages were:
[
{"role": "user", "content": "What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun"},
{"role": "assistant", "content": "The best answer is ("}
]
Then the response content might be:
[{"type": "text", "text": "B)"}]
Content generated by the model.
This is an array of content blocks, each of which has a type that determines its shape.
Example:
[{"type": "text", "text": "Hi, I'm Claude."}]
If the request input messages ended with an assistant turn, then the response content will continue directly from that last turn. You can use this to constrain the model's output.
For example, if the input messages were:
[
{"role": "user", "content": "What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun"},
{"role": "assistant", "content": "The best answer is ("}
]
Then the response content might be:
[{"type": "text", "text": "B)"}]
type TextBlock struct{…}
Citations []TextCitationUnionCitations 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.
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.
type CitationCharLocation struct{…}
Type CharLocation
type CitationPageLocation struct{…}
Type PageLocation
type CitationContentBlockLocation struct{…}
Type ContentBlockLocation
type CitationsWebSearchResultLocation struct{…}
Type WebSearchResultLocation
type CitationsSearchResultLocation struct{…}
Type SearchResultLocation
Type Text
type ThinkingBlock struct{…}
Type Thinking
type RedactedThinkingBlock struct{…}
Type RedactedThinking
type ToolUseBlock struct{…}
Type ToolUse
type ServerToolUseBlock struct{…}
Name WebSearch
Type ServerToolUse
type WebSearchToolResultBlock struct{…}
type WebSearchToolResultError struct{…}
ErrorCode WebSearchToolResultErrorErrorCode
Type WebSearchToolResultError
Type WebSearchResult
Type WebSearchToolResult
Model ModelThe model that will complete your prompt.
See models for additional details and options.
The model that will complete your prompt.
See models for additional details and options.
type Model stringThe model that will complete your prompt.
See models for additional details and options.
The model that will complete your prompt.
See models for additional details and options.
High-performance model with early extended thinking
High-performance model with early extended thinking
Fastest and most compact model for near-instant responsiveness
Our fastest model
Hybrid model, capable of near-instant responses and extended thinking
Hybrid model, capable of near-instant responses and extended thinking
High-performance model with extended thinking
High-performance model with extended thinking
High-performance model with extended thinking
Our best model for real-world agents and coding
Our best model for real-world agents and coding
Our most capable model
Our most capable model
Our most capable model
Our most capable model
Excels at writing and complex tasks
Excels at writing and complex tasks
Our previous most fast and cost-effective
Role AssistantConversational role of the generated message.
This will always be "assistant".
Conversational role of the generated message.
This will always be "assistant".
StopReason StopReasonThe 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
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.
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 requestedmax_tokensor the model's maximum"stop_sequence": one of your provided customstop_sequenceswas 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
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.
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 MessageObject type.
For Messages, this is always "message".
Object type.
For Messages, this is always "message".
Usage UsageBilling 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.
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.
CacheCreation CacheCreationBreakdown of cached tokens by TTL
Breakdown of cached tokens by TTL
The number of input tokens used to create the 1 hour cache entry.
The number of input tokens used to create the 5 minute cache entry.
The number of input tokens used to create the cache entry.
The number of input tokens read from the cache.
The number of input tokens which were used.
The number of output tokens which were used.
ServerToolUse ServerToolUsageThe number of server tool requests.
The number of server tool requests.
The number of web search tool requests.
ServiceTier UsageServiceTierIf the request used the priority, standard, or batch tier.
If the request used the priority, standard, or batch tier.
type MessageCountTokensToolUnion interface{…}
type Tool struct{…}
InputSchema ToolInputSchemaJSON schema for this tool's input.
This defines the shape of the input that your tool accepts and that the model will produce.
JSON schema for this tool's input.
This defines the shape of the input that your tool accepts and that the model will produce.
Type Object
Name of the tool.
This is how the tool will be called by the model and in tool_use blocks.
Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
Type Ephemeral
TTL CacheControlEphemeralTTLoptionalThe time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
Description of what this tool does.
Tool descriptions should be as detailed as possible. The more information that the model has about what the tool is and how to use it, the better it will perform. You can use natural language descriptions to reinforce important aspects of the tool input JSON schema.
Type ToolTypeoptional
type ToolBash20250124 struct{…}
Name BashName of the tool.
This is how the tool will be called by the model and in tool_use blocks.
Name of the tool.
This is how the tool will be called by the model and in tool_use blocks.
Type Bash20250124
Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
Type Ephemeral
TTL CacheControlEphemeralTTLoptionalThe time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
type ToolTextEditor20250124 struct{…}
Name StrReplaceEditorName of the tool.
This is how the tool will be called by the model and in tool_use blocks.
Name of the tool.
This is how the tool will be called by the model and in tool_use blocks.
Type TextEditor20250124
Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
Type Ephemeral
TTL CacheControlEphemeralTTLoptionalThe time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
type ToolTextEditor20250429 struct{…}
Name StrReplaceBasedEditToolName of the tool.
This is how the tool will be called by the model and in tool_use blocks.
Name of the tool.
This is how the tool will be called by the model and in tool_use blocks.
Type TextEditor20250429
Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
Type Ephemeral
TTL CacheControlEphemeralTTLoptionalThe time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
type ToolTextEditor20250728 struct{…}
Name StrReplaceBasedEditToolName of the tool.
This is how the tool will be called by the model and in tool_use blocks.
Name of the tool.
This is how the tool will be called by the model and in tool_use blocks.
Type TextEditor20250728
Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
Type Ephemeral
TTL CacheControlEphemeralTTLoptionalThe time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
Maximum number of characters to display when viewing a file. If not specified, defaults to displaying the full file.
type WebSearchTool20250305 struct{…}
Name WebSearchName of the tool.
This is how the tool will be called by the model and in tool_use blocks.
Name of the tool.
This is how the tool will be called by the model and in tool_use blocks.
Type WebSearch20250305
If provided, only these domains will be included in results. Cannot be used alongside blocked_domains.
If provided, these domains will never appear in results. Cannot be used alongside allowed_domains.
Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
Type Ephemeral
TTL CacheControlEphemeralTTLoptionalThe time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
Maximum number of times the tool can be used in the API request.
UserLocation WebSearchTool20250305UserLocationoptionalParameters for the user's location. Used to provide more relevant search results.
Parameters for the user's location. Used to provide more relevant search results.
Type Approximate
The city of the user.
The region of the user.
type MessageDeltaUsage struct{…}
The cumulative number of input tokens used to create the cache entry.
The cumulative number of input tokens read from the cache.
The cumulative number of input tokens which were used.
The cumulative number of output tokens which were used.
ServerToolUse ServerToolUsageThe number of server tool requests.
The number of server tool requests.
The number of web search tool requests.
type MessageParamResp struct{…}
Content []ContentBlockParamUnionResp
type TextBlockParamResp struct{…}
Type Text
Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
Type Ephemeral
TTL CacheControlEphemeralTTLoptionalThe time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
type CitationCharLocationParamResp struct{…}
Type CharLocation
type CitationPageLocationParamResp struct{…}
Type PageLocation
type CitationContentBlockLocationParamResp struct{…}
Type ContentBlockLocation
type CitationWebSearchResultLocationParamResp struct{…}
Type WebSearchResultLocation
type CitationSearchResultLocationParamResp struct{…}
Type SearchResultLocation
type ImageBlockParamResp struct{…}
Source ImageBlockParamSourceUnionResp
type Base64ImageSource struct{…}
MediaType Base64ImageSourceMediaType
Type Base64
type URLImageSource struct{…}
Type URL
Type Image
Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
Type Ephemeral
TTL CacheControlEphemeralTTLoptionalThe time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
type DocumentBlockParamResp struct{…}
Source DocumentBlockParamSourceUnionResp
type Base64PDFSource struct{…}
MediaType ApplicationPDF
Type Base64
type PlainTextSource struct{…}
MediaType TextPlain
Type Text
type ContentBlockSource struct{…}
Content ContentBlockSourceContentUnion
type TextBlockParamResp struct{…}
Type Text
Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
Type Ephemeral
TTL CacheControlEphemeralTTLoptionalThe time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
type CitationCharLocationParamResp struct{…}
Type CharLocation
type CitationPageLocationParamResp struct{…}
Type PageLocation
type CitationContentBlockLocationParamResp struct{…}
Type ContentBlockLocation
type CitationWebSearchResultLocationParamResp struct{…}
Type WebSearchResultLocation
type CitationSearchResultLocationParamResp struct{…}
Type SearchResultLocation
type ImageBlockParamResp struct{…}
Source ImageBlockParamSourceUnionResp
type Base64ImageSource struct{…}
MediaType Base64ImageSourceMediaType
Type Base64
type URLImageSource struct{…}
Type URL
Type Image
Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
Type Ephemeral
TTL CacheControlEphemeralTTLoptionalThe time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
Type Content
type URLPDFSource struct{…}
Type URL
Type Document
Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
Type Ephemeral
TTL CacheControlEphemeralTTLoptionalThe time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
type SearchResultBlockParamResp struct{…}
Content []TextBlockParamResp
Type Text
Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
Type Ephemeral
TTL CacheControlEphemeralTTLoptionalThe time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
type CitationCharLocationParamResp struct{…}
Type CharLocation
type CitationPageLocationParamResp struct{…}
Type PageLocation
type CitationContentBlockLocationParamResp struct{…}
Type ContentBlockLocation
type CitationWebSearchResultLocationParamResp struct{…}
Type WebSearchResultLocation
type CitationSearchResultLocationParamResp struct{…}
Type SearchResultLocation
Type SearchResult
Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
Type Ephemeral
TTL CacheControlEphemeralTTLoptionalThe time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
type ThinkingBlockParamResp struct{…}
Type Thinking
type RedactedThinkingBlockParamResp struct{…}
Type RedactedThinking
type ToolUseBlockParamResp struct{…}
Type ToolUse
Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
Type Ephemeral
TTL CacheControlEphemeralTTLoptionalThe time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
type ToolResultBlockParamResp struct{…}
Type ToolResult
Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
Type Ephemeral
TTL CacheControlEphemeralTTLoptionalThe time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
Content []ToolResultBlockParamContentUnionRespoptional
[]ToolResultBlockParamContentUnionResp
type TextBlockParamResp struct{…}
Type Text
Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
Type Ephemeral
TTL CacheControlEphemeralTTLoptionalThe time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
type CitationCharLocationParamResp struct{…}
Type CharLocation
type CitationPageLocationParamResp struct{…}
Type PageLocation
type CitationContentBlockLocationParamResp struct{…}
Type ContentBlockLocation
type CitationWebSearchResultLocationParamResp struct{…}
Type WebSearchResultLocation
type CitationSearchResultLocationParamResp struct{…}
Type SearchResultLocation
type ImageBlockParamResp struct{…}
Source ImageBlockParamSourceUnionResp
type Base64ImageSource struct{…}
MediaType Base64ImageSourceMediaType
Type Base64
type URLImageSource struct{…}
Type URL
Type Image
Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
Type Ephemeral
TTL CacheControlEphemeralTTLoptionalThe time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
type SearchResultBlockParamResp struct{…}
Content []TextBlockParamResp
Type Text
Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
Type Ephemeral
TTL CacheControlEphemeralTTLoptionalThe time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
type CitationCharLocationParamResp struct{…}
Type CharLocation
type CitationPageLocationParamResp struct{…}
Type PageLocation
type CitationContentBlockLocationParamResp struct{…}
Type ContentBlockLocation
type CitationWebSearchResultLocationParamResp struct{…}
Type WebSearchResultLocation
type CitationSearchResultLocationParamResp struct{…}
Type SearchResultLocation
Type SearchResult
Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
Type Ephemeral
TTL CacheControlEphemeralTTLoptionalThe time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
type DocumentBlockParamResp struct{…}
Source DocumentBlockParamSourceUnionResp
type Base64PDFSource struct{…}
MediaType ApplicationPDF
Type Base64
type PlainTextSource struct{…}
MediaType TextPlain
Type Text
type ContentBlockSource struct{…}
Content ContentBlockSourceContentUnion
type TextBlockParamResp struct{…}
Type Text
Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
Type Ephemeral
TTL CacheControlEphemeralTTLoptionalThe time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
type CitationCharLocationParamResp struct{…}
Type CharLocation
type CitationPageLocationParamResp struct{…}
Type PageLocation
type CitationContentBlockLocationParamResp struct{…}
Type ContentBlockLocation
type CitationWebSearchResultLocationParamResp struct{…}
Type WebSearchResultLocation
type CitationSearchResultLocationParamResp struct{…}
Type SearchResultLocation
type ImageBlockParamResp struct{…}
Source ImageBlockParamSourceUnionResp
type Base64ImageSource struct{…}
MediaType Base64ImageSourceMediaType
Type Base64
type URLImageSource struct{…}
Type URL
Type Image
Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
Type Ephemeral
TTL CacheControlEphemeralTTLoptionalThe time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
Type Content
type URLPDFSource struct{…}
Type URL
Type Document
Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
Type Ephemeral
TTL CacheControlEphemeralTTLoptionalThe time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
type ServerToolUseBlockParamResp struct{…}
Name WebSearch
Type ServerToolUse
Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
Type Ephemeral
TTL CacheControlEphemeralTTLoptionalThe time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
type WebSearchToolResultBlockParamResp struct{…}
Type WebSearchResult
type WebSearchToolRequestError struct{…}
ErrorCode WebSearchToolRequestErrorErrorCode
Type WebSearchToolResultError
Type WebSearchToolResult
Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
Type Ephemeral
TTL CacheControlEphemeralTTLoptionalThe time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
Role MessageParamRole
type MessageTokensCount struct{…}
The total number of tokens across the provided list of messages, system prompt, and tools.
type Metadata struct{…}
An external identifier for the user who is associated with the request.
This should be a uuid, hash value, or other opaque identifier. Anthropic may use this id to help detect abuse. Do not include any identifying information such as name, email address, or phone number.
type Model interface{…}The model that will complete your prompt.
See models for additional details and options.
The model that will complete your prompt.
See models for additional details and options.
type Model stringThe model that will complete your prompt.
See models for additional details and options.
The model that will complete your prompt.
See models for additional details and options.
High-performance model with early extended thinking
High-performance model with early extended thinking
Fastest and most compact model for near-instant responsiveness
Our fastest model
Hybrid model, capable of near-instant responses and extended thinking
Hybrid model, capable of near-instant responses and extended thinking
High-performance model with extended thinking
High-performance model with extended thinking
High-performance model with extended thinking
Our best model for real-world agents and coding
Our best model for real-world agents and coding
Our most capable model
Our most capable model
Our most capable model
Our most capable model
Excels at writing and complex tasks
Excels at writing and complex tasks
Our previous most fast and cost-effective
type PlainTextSource struct{…}
MediaType TextPlain
Type Text
type RawContentBlockDeltaUnion interface{…}
type TextDelta struct{…}
Type TextDelta
type InputJSONDelta struct{…}
Type InputJSONDelta
type CitationsDelta struct{…}
Citation CitationsDeltaCitationUnion
type CitationCharLocation struct{…}
Type CharLocation
type CitationPageLocation struct{…}
Type PageLocation
type CitationContentBlockLocation struct{…}
Type ContentBlockLocation
type CitationsWebSearchResultLocation struct{…}
Type WebSearchResultLocation
type CitationsSearchResultLocation struct{…}
Type SearchResultLocation
Type CitationsDelta
type ThinkingDelta struct{…}
Type ThinkingDelta
type SignatureDelta struct{…}
Type SignatureDelta
type ContentBlockDeltaEvent struct{…}
type TextDelta struct{…}
Type TextDelta
type InputJSONDelta struct{…}
Type InputJSONDelta
type CitationsDelta struct{…}
Citation CitationsDeltaCitationUnion
type CitationCharLocation struct{…}
Type CharLocation
type CitationPageLocation struct{…}
Type PageLocation
type CitationContentBlockLocation struct{…}
Type ContentBlockLocation
type CitationsWebSearchResultLocation struct{…}
Type WebSearchResultLocation
type CitationsSearchResultLocation struct{…}
Type SearchResultLocation
Type CitationsDelta
type ThinkingDelta struct{…}
Type ThinkingDelta
type SignatureDelta struct{…}
Type SignatureDelta
Type ContentBlockDelta
type ContentBlockStartEvent struct{…}
ContentBlock ContentBlockStartEventContentBlockUnion
type TextBlock struct{…}
Citations []TextCitationUnionCitations 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.
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.
type CitationCharLocation struct{…}
Type CharLocation
type CitationPageLocation struct{…}
Type PageLocation
type CitationContentBlockLocation struct{…}
Type ContentBlockLocation
type CitationsWebSearchResultLocation struct{…}
Type WebSearchResultLocation
type CitationsSearchResultLocation struct{…}
Type SearchResultLocation
Type Text
type ThinkingBlock struct{…}
Type Thinking
type RedactedThinkingBlock struct{…}
Type RedactedThinking
type ToolUseBlock struct{…}
Type ToolUse
type ServerToolUseBlock struct{…}
Name WebSearch
Type ServerToolUse
type WebSearchToolResultBlock struct{…}
type WebSearchToolResultError struct{…}
ErrorCode WebSearchToolResultErrorErrorCode
Type WebSearchToolResultError
Type WebSearchResult
Type WebSearchToolResult
Type ContentBlockStart
type ContentBlockStopEvent struct{…}
Type ContentBlockStop
type MessageDeltaEvent struct{…}
Delta MessageDeltaEventDelta
StopReason StopReason
Type MessageDelta
Usage MessageDeltaUsageBilling 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.
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.
The cumulative number of input tokens used to create the cache entry.
The cumulative number of input tokens read from the cache.
The cumulative number of input tokens which were used.
The cumulative number of output tokens which were used.
ServerToolUse ServerToolUsageThe number of server tool requests.
The number of server tool requests.
The number of web search tool requests.
type MessageStartEvent struct{…}
Message Message
Unique object identifier.
The format and length of IDs may change over time.
Content []ContentBlockUnionContent generated by the model.
This is an array of content blocks, each of which has a type that determines its shape.
Example:
[{"type": "text", "text": "Hi, I'm Claude."}]
If the request input messages ended with an assistant turn, then the response content will continue directly from that last turn. You can use this to constrain the model's output.
For example, if the input messages were:
[
{"role": "user", "content": "What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun"},
{"role": "assistant", "content": "The best answer is ("}
]
Then the response content might be:
[{"type": "text", "text": "B)"}]
Content generated by the model.
This is an array of content blocks, each of which has a type that determines its shape.
Example:
[{"type": "text", "text": "Hi, I'm Claude."}]
If the request input messages ended with an assistant turn, then the response content will continue directly from that last turn. You can use this to constrain the model's output.
For example, if the input messages were:
[
{"role": "user", "content": "What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun"},
{"role": "assistant", "content": "The best answer is ("}
]
Then the response content might be:
[{"type": "text", "text": "B)"}]
type TextBlock struct{…}
Citations []TextCitationUnionCitations 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.
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.
type CitationCharLocation struct{…}
Type CharLocation
type CitationPageLocation struct{…}
Type PageLocation
type CitationContentBlockLocation struct{…}
Type ContentBlockLocation
type CitationsWebSearchResultLocation struct{…}
Type WebSearchResultLocation
type CitationsSearchResultLocation struct{…}
Type SearchResultLocation
Type Text
type ThinkingBlock struct{…}
Type Thinking
type RedactedThinkingBlock struct{…}
Type RedactedThinking
type ToolUseBlock struct{…}
Type ToolUse
type ServerToolUseBlock struct{…}
Name WebSearch
Type ServerToolUse
type WebSearchToolResultBlock struct{…}
type WebSearchToolResultError struct{…}
ErrorCode WebSearchToolResultErrorErrorCode
Type WebSearchToolResultError
Type WebSearchResult
Type WebSearchToolResult
Model ModelThe model that will complete your prompt.
See models for additional details and options.
The model that will complete your prompt.
See models for additional details and options.
type Model stringThe model that will complete your prompt.
See models for additional details and options.
The model that will complete your prompt.
See models for additional details and options.
High-performance model with early extended thinking
High-performance model with early extended thinking
Fastest and most compact model for near-instant responsiveness
Our fastest model
Hybrid model, capable of near-instant responses and extended thinking
Hybrid model, capable of near-instant responses and extended thinking
High-performance model with extended thinking
High-performance model with extended thinking
High-performance model with extended thinking
Our best model for real-world agents and coding
Our best model for real-world agents and coding
Our most capable model
Our most capable model
Our most capable model
Our most capable model
Excels at writing and complex tasks
Excels at writing and complex tasks
Our previous most fast and cost-effective
Role AssistantConversational role of the generated message.
This will always be "assistant".
Conversational role of the generated message.
This will always be "assistant".
StopReason StopReasonThe 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
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.
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 requestedmax_tokensor the model's maximum"stop_sequence": one of your provided customstop_sequenceswas 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
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.
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 MessageObject type.
For Messages, this is always "message".
Object type.
For Messages, this is always "message".
Usage UsageBilling 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.
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.
CacheCreation CacheCreationBreakdown of cached tokens by TTL
Breakdown of cached tokens by TTL
The number of input tokens used to create the 1 hour cache entry.
The number of input tokens used to create the 5 minute cache entry.
The number of input tokens used to create the cache entry.
The number of input tokens read from the cache.
The number of input tokens which were used.
The number of output tokens which were used.
ServerToolUse ServerToolUsageThe number of server tool requests.
The number of server tool requests.
The number of web search tool requests.
ServiceTier UsageServiceTierIf the request used the priority, standard, or batch tier.
If the request used the priority, standard, or batch tier.
Type MessageStart
type MessageStopEvent struct{…}
Type MessageStop
type MessageStreamEventUnion interface{…}
type MessageStartEvent struct{…}
Message Message
Unique object identifier.
The format and length of IDs may change over time.
Content []ContentBlockUnionContent generated by the model.
This is an array of content blocks, each of which has a type that determines its shape.
Example:
[{"type": "text", "text": "Hi, I'm Claude."}]
If the request input messages ended with an assistant turn, then the response content will continue directly from that last turn. You can use this to constrain the model's output.
For example, if the input messages were:
[
{"role": "user", "content": "What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun"},
{"role": "assistant", "content": "The best answer is ("}
]
Then the response content might be:
[{"type": "text", "text": "B)"}]
Content generated by the model.
This is an array of content blocks, each of which has a type that determines its shape.
Example:
[{"type": "text", "text": "Hi, I'm Claude."}]
If the request input messages ended with an assistant turn, then the response content will continue directly from that last turn. You can use this to constrain the model's output.
For example, if the input messages were:
[
{"role": "user", "content": "What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun"},
{"role": "assistant", "content": "The best answer is ("}
]
Then the response content might be:
[{"type": "text", "text": "B)"}]
type TextBlock struct{…}
Citations []TextCitationUnionCitations 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.
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.
type CitationCharLocation struct{…}
Type CharLocation
type CitationPageLocation struct{…}
Type PageLocation
type CitationContentBlockLocation struct{…}
Type ContentBlockLocation
type CitationsWebSearchResultLocation struct{…}
Type WebSearchResultLocation
type CitationsSearchResultLocation struct{…}
Type SearchResultLocation
Type Text
type ThinkingBlock struct{…}
Type Thinking
type RedactedThinkingBlock struct{…}
Type RedactedThinking
type ToolUseBlock struct{…}
Type ToolUse
type ServerToolUseBlock struct{…}
Name WebSearch
Type ServerToolUse
type WebSearchToolResultBlock struct{…}
type WebSearchToolResultError struct{…}
ErrorCode WebSearchToolResultErrorErrorCode
Type WebSearchToolResultError
Type WebSearchResult
Type WebSearchToolResult
Model ModelThe model that will complete your prompt.
See models for additional details and options.
The model that will complete your prompt.
See models for additional details and options.
type Model stringThe model that will complete your prompt.
See models for additional details and options.
The model that will complete your prompt.
See models for additional details and options.
High-performance model with early extended thinking
High-performance model with early extended thinking
Fastest and most compact model for near-instant responsiveness
Our fastest model
Hybrid model, capable of near-instant responses and extended thinking
Hybrid model, capable of near-instant responses and extended thinking
High-performance model with extended thinking
High-performance model with extended thinking
High-performance model with extended thinking
Our best model for real-world agents and coding
Our best model for real-world agents and coding
Our most capable model
Our most capable model
Our most capable model
Our most capable model
Excels at writing and complex tasks
Excels at writing and complex tasks
Our previous most fast and cost-effective
Role AssistantConversational role of the generated message.
This will always be "assistant".
Conversational role of the generated message.
This will always be "assistant".
StopReason StopReasonThe 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
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.
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 requestedmax_tokensor the model's maximum"stop_sequence": one of your provided customstop_sequenceswas 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
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.
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 MessageObject type.
For Messages, this is always "message".
Object type.
For Messages, this is always "message".
Usage UsageBilling 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.
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.
CacheCreation CacheCreationBreakdown of cached tokens by TTL
Breakdown of cached tokens by TTL
The number of input tokens used to create the 1 hour cache entry.
The number of input tokens used to create the 5 minute cache entry.
The number of input tokens used to create the cache entry.
The number of input tokens read from the cache.
The number of input tokens which were used.
The number of output tokens which were used.
ServerToolUse ServerToolUsageThe number of server tool requests.
The number of server tool requests.
The number of web search tool requests.
ServiceTier UsageServiceTierIf the request used the priority, standard, or batch tier.
If the request used the priority, standard, or batch tier.
Type MessageStart
type MessageDeltaEvent struct{…}
Delta MessageDeltaEventDelta
StopReason StopReason
Type MessageDelta
Usage MessageDeltaUsageBilling 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.
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.
The cumulative number of input tokens used to create the cache entry.
The cumulative number of input tokens read from the cache.
The cumulative number of input tokens which were used.
The cumulative number of output tokens which were used.
ServerToolUse ServerToolUsageThe number of server tool requests.
The number of server tool requests.
The number of web search tool requests.
type MessageStopEvent struct{…}
Type MessageStop
type ContentBlockStartEvent struct{…}
ContentBlock ContentBlockStartEventContentBlockUnion
type TextBlock struct{…}
Citations []TextCitationUnionCitations 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.
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.
type CitationCharLocation struct{…}
Type CharLocation
type CitationPageLocation struct{…}
Type PageLocation
type CitationContentBlockLocation struct{…}
Type ContentBlockLocation
type CitationsWebSearchResultLocation struct{…}
Type WebSearchResultLocation
type CitationsSearchResultLocation struct{…}
Type SearchResultLocation
Type Text
type ThinkingBlock struct{…}
Type Thinking
type RedactedThinkingBlock struct{…}
Type RedactedThinking
type ToolUseBlock struct{…}
Type ToolUse
type ServerToolUseBlock struct{…}
Name WebSearch
Type ServerToolUse
type WebSearchToolResultBlock struct{…}
type WebSearchToolResultError struct{…}
ErrorCode WebSearchToolResultErrorErrorCode
Type WebSearchToolResultError
Type WebSearchResult
Type WebSearchToolResult
Type ContentBlockStart
type ContentBlockDeltaEvent struct{…}
type TextDelta struct{…}
Type TextDelta
type InputJSONDelta struct{…}
Type InputJSONDelta
type CitationsDelta struct{…}
Citation CitationsDeltaCitationUnion
type CitationCharLocation struct{…}
Type CharLocation
type CitationPageLocation struct{…}
Type PageLocation
type CitationContentBlockLocation struct{…}
Type ContentBlockLocation
type CitationsWebSearchResultLocation struct{…}
Type WebSearchResultLocation
type CitationsSearchResultLocation struct{…}
Type SearchResultLocation
Type CitationsDelta
type ThinkingDelta struct{…}
Type ThinkingDelta
type SignatureDelta struct{…}
Type SignatureDelta
Type ContentBlockDelta
type ContentBlockStopEvent struct{…}
Type ContentBlockStop
type RedactedThinkingBlock struct{…}
Type RedactedThinking
type RedactedThinkingBlockParamResp struct{…}
Type RedactedThinking
type SearchResultBlockParamResp struct{…}
Content []TextBlockParamResp
Type Text
Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
Type Ephemeral
TTL CacheControlEphemeralTTLoptionalThe time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
type CitationCharLocationParamResp struct{…}
Type CharLocation
type CitationPageLocationParamResp struct{…}
Type PageLocation
type CitationContentBlockLocationParamResp struct{…}
Type ContentBlockLocation
type CitationWebSearchResultLocationParamResp struct{…}
Type WebSearchResultLocation
type CitationSearchResultLocationParamResp struct{…}
Type SearchResultLocation
Type SearchResult
Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
Type Ephemeral
TTL CacheControlEphemeralTTLoptionalThe time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
type ServerToolUsage struct{…}
The number of web search tool requests.
type ServerToolUseBlock struct{…}
Name WebSearch
Type ServerToolUse
type ServerToolUseBlockParamResp struct{…}
Name WebSearch
Type ServerToolUse
Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
Type Ephemeral
TTL CacheControlEphemeralTTLoptionalThe time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
type SignatureDelta struct{…}
Type SignatureDelta
type StopReason string
type TextBlock struct{…}
Citations []TextCitationUnionCitations 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.
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.
type CitationCharLocation struct{…}
Type CharLocation
type CitationPageLocation struct{…}
Type PageLocation
type CitationContentBlockLocation struct{…}
Type ContentBlockLocation
type CitationsWebSearchResultLocation struct{…}
Type WebSearchResultLocation
type CitationsSearchResultLocation struct{…}
Type SearchResultLocation
Type Text
type TextBlockParamResp struct{…}
Type Text
Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
Type Ephemeral
TTL CacheControlEphemeralTTLoptionalThe time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
type CitationCharLocationParamResp struct{…}
Type CharLocation
type CitationPageLocationParamResp struct{…}
Type PageLocation
type CitationContentBlockLocationParamResp struct{…}
Type ContentBlockLocation
type CitationWebSearchResultLocationParamResp struct{…}
Type WebSearchResultLocation
type CitationSearchResultLocationParamResp struct{…}
Type SearchResultLocation
type TextCitationUnion interface{…}
type CitationCharLocation struct{…}
Type CharLocation
type CitationPageLocation struct{…}
Type PageLocation
type CitationContentBlockLocation struct{…}
Type ContentBlockLocation
type CitationsWebSearchResultLocation struct{…}
Type WebSearchResultLocation
type CitationsSearchResultLocation struct{…}
Type SearchResultLocation
type TextCitationParamUnionResp interface{…}
type CitationCharLocationParamResp struct{…}
Type CharLocation
type CitationPageLocationParamResp struct{…}
Type PageLocation
type CitationContentBlockLocationParamResp struct{…}
Type ContentBlockLocation
type CitationWebSearchResultLocationParamResp struct{…}
Type WebSearchResultLocation
type CitationSearchResultLocationParamResp struct{…}
Type SearchResultLocation
type TextDelta struct{…}
Type TextDelta
type ThinkingBlock struct{…}
Type Thinking
type ThinkingBlockParamResp struct{…}
Type Thinking
type ThinkingConfigDisabled struct{…}
Type Disabled
type ThinkingConfigEnabled struct{…}
Determines how many tokens Claude can use for its internal reasoning process. Larger budgets can enable more thorough analysis for complex problems, improving response quality.
Must be ≥1024 and less than max_tokens.
See extended thinking for details.
Type Enabled
type ThinkingConfigParamUnionResp interface{…}Configuration for enabling Claude's extended thinking.
When enabled, responses include thinking content blocks showing Claude's thinking process before the final answer. Requires a minimum budget of 1,024 tokens and counts towards your max_tokens limit.
See extended thinking for details.
Configuration for enabling Claude's extended thinking.
When enabled, responses include thinking content blocks showing Claude's thinking process before the final answer. Requires a minimum budget of 1,024 tokens and counts towards your max_tokens limit.
See extended thinking for details.
type ThinkingConfigEnabled struct{…}
Determines how many tokens Claude can use for its internal reasoning process. Larger budgets can enable more thorough analysis for complex problems, improving response quality.
Must be ≥1024 and less than max_tokens.
See extended thinking for details.
Type Enabled
type ThinkingConfigDisabled struct{…}
Type Disabled
type ThinkingDelta struct{…}
Type ThinkingDelta
type Tool struct{…}
InputSchema ToolInputSchemaJSON schema for this tool's input.
This defines the shape of the input that your tool accepts and that the model will produce.
JSON schema for this tool's input.
This defines the shape of the input that your tool accepts and that the model will produce.
Type Object
Name of the tool.
This is how the tool will be called by the model and in tool_use blocks.
Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
Type Ephemeral
TTL CacheControlEphemeralTTLoptionalThe time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
Description of what this tool does.
Tool descriptions should be as detailed as possible. The more information that the model has about what the tool is and how to use it, the better it will perform. You can use natural language descriptions to reinforce important aspects of the tool input JSON schema.
Type ToolTypeoptional
type ToolBash20250124 struct{…}
Name BashName of the tool.
This is how the tool will be called by the model and in tool_use blocks.
Name of the tool.
This is how the tool will be called by the model and in tool_use blocks.
Type Bash20250124
Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
Type Ephemeral
TTL CacheControlEphemeralTTLoptionalThe time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
type ToolChoiceUnion interface{…}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.
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.
type ToolChoiceAuto struct{…}The model will automatically decide whether to use tools.
The model will automatically decide whether to use tools.
Type Auto
Whether to disable parallel tool use.
Defaults to false. If set to true, the model will output at most one tool use.
type ToolChoiceAny struct{…}The model will use any available tools.
The model will use any available tools.
Type Any
Whether to disable parallel tool use.
Defaults to false. If set to true, the model will output exactly one tool use.
type ToolChoiceTool struct{…}The model will use the specified tool with tool_choice.name.
The model will use the specified tool with tool_choice.name.
The name of the tool to use.
Type Tool
Whether to disable parallel tool use.
Defaults to false. If set to true, the model will output exactly one tool use.
type ToolChoiceNone struct{…}The model will not be allowed to use tools.
The model will not be allowed to use tools.
Type None
type ToolChoiceAny struct{…}The model will use any available tools.
The model will use any available tools.
Type Any
Whether to disable parallel tool use.
Defaults to false. If set to true, the model will output exactly one tool use.
type ToolChoiceAuto struct{…}The model will automatically decide whether to use tools.
The model will automatically decide whether to use tools.
Type Auto
Whether to disable parallel tool use.
Defaults to false. If set to true, the model will output at most one tool use.
type ToolChoiceNone struct{…}The model will not be allowed to use tools.
The model will not be allowed to use tools.
Type None
type ToolChoiceTool struct{…}The model will use the specified tool with tool_choice.name.
The model will use the specified tool with tool_choice.name.
The name of the tool to use.
Type Tool
Whether to disable parallel tool use.
Defaults to false. If set to true, the model will output exactly one tool use.
type ToolResultBlockParamResp struct{…}
Type ToolResult
Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
Type Ephemeral
TTL CacheControlEphemeralTTLoptionalThe time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
Content []ToolResultBlockParamContentUnionRespoptional
[]ToolResultBlockParamContentUnionResp
type TextBlockParamResp struct{…}
Type Text
Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
Type Ephemeral
TTL CacheControlEphemeralTTLoptionalThe time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
type CitationCharLocationParamResp struct{…}
Type CharLocation
type CitationPageLocationParamResp struct{…}
Type PageLocation
type CitationContentBlockLocationParamResp struct{…}
Type ContentBlockLocation
type CitationWebSearchResultLocationParamResp struct{…}
Type WebSearchResultLocation
type CitationSearchResultLocationParamResp struct{…}
Type SearchResultLocation
type ImageBlockParamResp struct{…}
Source ImageBlockParamSourceUnionResp
type Base64ImageSource struct{…}
MediaType Base64ImageSourceMediaType
Type Base64
type URLImageSource struct{…}
Type URL
Type Image
Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
Type Ephemeral
TTL CacheControlEphemeralTTLoptionalThe time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
type SearchResultBlockParamResp struct{…}
Content []TextBlockParamResp
Type Text
Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
Type Ephemeral
TTL CacheControlEphemeralTTLoptionalThe time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
type CitationCharLocationParamResp struct{…}
Type CharLocation
type CitationPageLocationParamResp struct{…}
Type PageLocation
type CitationContentBlockLocationParamResp struct{…}
Type ContentBlockLocation
type CitationWebSearchResultLocationParamResp struct{…}
Type WebSearchResultLocation
type CitationSearchResultLocationParamResp struct{…}
Type SearchResultLocation
Type SearchResult
Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
Type Ephemeral
TTL CacheControlEphemeralTTLoptionalThe time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
type DocumentBlockParamResp struct{…}
Source DocumentBlockParamSourceUnionResp
type Base64PDFSource struct{…}
MediaType ApplicationPDF
Type Base64
type PlainTextSource struct{…}
MediaType TextPlain
Type Text
type ContentBlockSource struct{…}
Content ContentBlockSourceContentUnion
type TextBlockParamResp struct{…}
Type Text
Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
Type Ephemeral
TTL CacheControlEphemeralTTLoptionalThe time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
type CitationCharLocationParamResp struct{…}
Type CharLocation
type CitationPageLocationParamResp struct{…}
Type PageLocation
type CitationContentBlockLocationParamResp struct{…}
Type ContentBlockLocation
type CitationWebSearchResultLocationParamResp struct{…}
Type WebSearchResultLocation
type CitationSearchResultLocationParamResp struct{…}
Type SearchResultLocation
type ImageBlockParamResp struct{…}
Source ImageBlockParamSourceUnionResp
type Base64ImageSource struct{…}
MediaType Base64ImageSourceMediaType
Type Base64
type URLImageSource struct{…}
Type URL
Type Image
Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
Type Ephemeral
TTL CacheControlEphemeralTTLoptionalThe time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
Type Content
type URLPDFSource struct{…}
Type URL
Type Document
Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
Type Ephemeral
TTL CacheControlEphemeralTTLoptionalThe time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
type ToolTextEditor20250124 struct{…}
Name StrReplaceEditorName of the tool.
This is how the tool will be called by the model and in tool_use blocks.
Name of the tool.
This is how the tool will be called by the model and in tool_use blocks.
Type TextEditor20250124
Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
Type Ephemeral
TTL CacheControlEphemeralTTLoptionalThe time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
type ToolTextEditor20250429 struct{…}
Name StrReplaceBasedEditToolName of the tool.
This is how the tool will be called by the model and in tool_use blocks.
Name of the tool.
This is how the tool will be called by the model and in tool_use blocks.
Type TextEditor20250429
Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
Type Ephemeral
TTL CacheControlEphemeralTTLoptionalThe time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
type ToolTextEditor20250728 struct{…}
Name StrReplaceBasedEditToolName of the tool.
This is how the tool will be called by the model and in tool_use blocks.
Name of the tool.
This is how the tool will be called by the model and in tool_use blocks.
Type TextEditor20250728
Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
Type Ephemeral
TTL CacheControlEphemeralTTLoptionalThe time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
Maximum number of characters to display when viewing a file. If not specified, defaults to displaying the full file.
type ToolUnion interface{…}
type Tool struct{…}
InputSchema ToolInputSchemaJSON schema for this tool's input.
This defines the shape of the input that your tool accepts and that the model will produce.
JSON schema for this tool's input.
This defines the shape of the input that your tool accepts and that the model will produce.
Type Object
Name of the tool.
This is how the tool will be called by the model and in tool_use blocks.
Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
Type Ephemeral
TTL CacheControlEphemeralTTLoptionalThe time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
Description of what this tool does.
Tool descriptions should be as detailed as possible. The more information that the model has about what the tool is and how to use it, the better it will perform. You can use natural language descriptions to reinforce important aspects of the tool input JSON schema.
Type ToolTypeoptional
type ToolBash20250124 struct{…}
Name BashName of the tool.
This is how the tool will be called by the model and in tool_use blocks.
Name of the tool.
This is how the tool will be called by the model and in tool_use blocks.
Type Bash20250124
Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
Type Ephemeral
TTL CacheControlEphemeralTTLoptionalThe time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
type ToolTextEditor20250124 struct{…}
Name StrReplaceEditorName of the tool.
This is how the tool will be called by the model and in tool_use blocks.
Name of the tool.
This is how the tool will be called by the model and in tool_use blocks.
Type TextEditor20250124
Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
Type Ephemeral
TTL CacheControlEphemeralTTLoptionalThe time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
type ToolTextEditor20250429 struct{…}
Name StrReplaceBasedEditToolName of the tool.
This is how the tool will be called by the model and in tool_use blocks.
Name of the tool.
This is how the tool will be called by the model and in tool_use blocks.
Type TextEditor20250429
Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
Type Ephemeral
TTL CacheControlEphemeralTTLoptionalThe time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
type ToolTextEditor20250728 struct{…}
Name StrReplaceBasedEditToolName of the tool.
This is how the tool will be called by the model and in tool_use blocks.
Name of the tool.
This is how the tool will be called by the model and in tool_use blocks.
Type TextEditor20250728
Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
Type Ephemeral
TTL CacheControlEphemeralTTLoptionalThe time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
Maximum number of characters to display when viewing a file. If not specified, defaults to displaying the full file.
type WebSearchTool20250305 struct{…}
Name WebSearchName of the tool.
This is how the tool will be called by the model and in tool_use blocks.
Name of the tool.
This is how the tool will be called by the model and in tool_use blocks.
Type WebSearch20250305
If provided, only these domains will be included in results. Cannot be used alongside blocked_domains.
If provided, these domains will never appear in results. Cannot be used alongside allowed_domains.
Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
Type Ephemeral
TTL CacheControlEphemeralTTLoptionalThe time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
Maximum number of times the tool can be used in the API request.
UserLocation WebSearchTool20250305UserLocationoptionalParameters for the user's location. Used to provide more relevant search results.
Parameters for the user's location. Used to provide more relevant search results.
Type Approximate
The city of the user.
The region of the user.
type ToolUseBlock struct{…}
Type ToolUse
type ToolUseBlockParamResp struct{…}
Type ToolUse
Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
Type Ephemeral
TTL CacheControlEphemeralTTLoptionalThe time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
type URLImageSource struct{…}
Type URL
type URLPDFSource struct{…}
Type URL
type Usage struct{…}
CacheCreation CacheCreationBreakdown of cached tokens by TTL
Breakdown of cached tokens by TTL
The number of input tokens used to create the 1 hour cache entry.
The number of input tokens used to create the 5 minute cache entry.
The number of input tokens used to create the cache entry.
The number of input tokens read from the cache.
The number of input tokens which were used.
The number of output tokens which were used.
ServerToolUse ServerToolUsageThe number of server tool requests.
The number of server tool requests.
The number of web search tool requests.
ServiceTier UsageServiceTierIf the request used the priority, standard, or batch tier.
If the request used the priority, standard, or batch tier.
type WebSearchResultBlock struct{…}
Type WebSearchResult
type WebSearchResultBlockParamResp struct{…}
Type WebSearchResult
type WebSearchTool20250305 struct{…}
Name WebSearchName of the tool.
This is how the tool will be called by the model and in tool_use blocks.
Name of the tool.
This is how the tool will be called by the model and in tool_use blocks.
Type WebSearch20250305
If provided, only these domains will be included in results. Cannot be used alongside blocked_domains.
If provided, these domains will never appear in results. Cannot be used alongside allowed_domains.
Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
Type Ephemeral
TTL CacheControlEphemeralTTLoptionalThe time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
Maximum number of times the tool can be used in the API request.
UserLocation WebSearchTool20250305UserLocationoptionalParameters for the user's location. Used to provide more relevant search results.
Parameters for the user's location. Used to provide more relevant search results.
Type Approximate
The city of the user.
The region of the user.
type WebSearchToolRequestError struct{…}
ErrorCode WebSearchToolRequestErrorErrorCode
Type WebSearchToolResultError
type WebSearchToolResultBlock struct{…}
type WebSearchToolResultError struct{…}
ErrorCode WebSearchToolResultErrorErrorCode
Type WebSearchToolResultError
Type WebSearchResult
Type WebSearchToolResult
type WebSearchToolResultBlockContentUnion interface{…}
type WebSearchToolResultError struct{…}
ErrorCode WebSearchToolResultErrorErrorCode
Type WebSearchToolResultError
Type WebSearchResult
type WebSearchToolResultBlockParamResp struct{…}
Type WebSearchResult
type WebSearchToolRequestError struct{…}
ErrorCode WebSearchToolRequestErrorErrorCode
Type WebSearchToolResultError
Type WebSearchToolResult
Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
Type Ephemeral
TTL CacheControlEphemeralTTLoptionalThe time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
type WebSearchToolResultBlockParamContentUnionResp interface{…}
Type WebSearchResult
type WebSearchToolRequestError struct{…}
ErrorCode WebSearchToolRequestErrorErrorCode
Type WebSearchToolResultError
type WebSearchToolResultError struct{…}
ErrorCode WebSearchToolResultErrorErrorCode
Type WebSearchToolResultError
MessagesBatches
Cancel a Message Batch
Create a Message Batch
Delete a Message Batch
List Message Batches
Retrieve Message Batch results
Retrieve a Message Batch
ModelsExpand Collapse
type DeletedMessageBatch struct{…}
ID of the Message Batch.
Type MessageBatchDeletedDeleted object type.
For Message Batches, this is always "message_batch_deleted".
Deleted object type.
For Message Batches, this is always "message_batch_deleted".
type MessageBatch struct{…}
Unique object identifier.
The format and length of IDs may change over time.
RFC 3339 datetime string representing the time at which the Message Batch was archived and its results became unavailable.
RFC 3339 datetime string representing the time at which cancellation was initiated for the Message Batch. Specified only if cancellation was initiated.
RFC 3339 datetime string representing the time at which the Message Batch was created.
RFC 3339 datetime string representing the time at which processing for the Message Batch ended. Specified only once processing ends.
Processing ends when every request in a Message Batch has either succeeded, errored, canceled, or expired.
RFC 3339 datetime string representing the time at which the Message Batch will expire and end processing, which is 24 hours after creation.
ProcessingStatus MessageBatchProcessingStatusProcessing status of the Message Batch.
Processing status of the Message Batch.
RequestCounts MessageBatchRequestCountsTallies requests within the Message Batch, categorized by their status.
Requests start as processing and move to one of the other statuses only once processing of the entire batch ends. The sum of all values always matches the total number of requests in the batch.
Tallies requests within the Message Batch, categorized by their status.
Requests start as processing and move to one of the other statuses only once processing of the entire batch ends. The sum of all values always matches the total number of requests in the batch.
Number of requests in the Message Batch that have been canceled.
This is zero until processing of the entire Message Batch has ended.
Number of requests in the Message Batch that encountered an error.
This is zero until processing of the entire Message Batch has ended.
Number of requests in the Message Batch that have expired.
This is zero until processing of the entire Message Batch has ended.
Number of requests in the Message Batch that are processing.
Number of requests in the Message Batch that have completed successfully.
This is zero until processing of the entire Message Batch has ended.
URL to a .jsonl file containing the results of the Message Batch requests. Specified only once processing ends.
Results in the file are not guaranteed to be in the same order as requests. Use the custom_id field to match results to requests.
Type MessageBatchObject type.
For Message Batches, this is always "message_batch".
Object type.
For Message Batches, this is always "message_batch".
type MessageBatchCanceledResult struct{…}
Type Canceled
type MessageBatchErroredResult struct{…}
Error ErrorResponse
Error ErrorObjectUnion
type InvalidRequestError struct{…}
Type InvalidRequestError
type AuthenticationError struct{…}
Type AuthenticationError
type BillingError struct{…}
Type BillingError
type PermissionError struct{…}
Type PermissionError
type NotFoundError struct{…}
Type NotFoundError
type RateLimitError struct{…}
Type RateLimitError
type GatewayTimeoutError struct{…}
Type TimeoutError
type APIErrorObject struct{…}
Type APIError
type OverloadedError struct{…}
Type OverloadedError
Type Error
Type Errored
type MessageBatchExpiredResult struct{…}
Type Expired
type MessageBatchIndividualResponse struct{…}This is a single line in the response .jsonl file and does not represent the response as a whole.
This is a single line in the response .jsonl file and does not represent the response as a whole.
Developer-provided ID created for each request in a Message Batch. Useful for matching results to requests, as results may be given out of request order.
Must be unique for each request within the Message Batch.
Result MessageBatchResultUnionProcessing result for this request.
Contains a Message output if processing was successful, an error response if processing failed, or the reason why processing was not attempted, such as cancellation or expiration.
Processing result for this request.
Contains a Message output if processing was successful, an error response if processing failed, or the reason why processing was not attempted, such as cancellation or expiration.
type MessageBatchSucceededResult struct{…}
Message Message
Unique object identifier.
The format and length of IDs may change over time.
Content []ContentBlockUnionContent generated by the model.
This is an array of content blocks, each of which has a type that determines its shape.
Example:
[{"type": "text", "text": "Hi, I'm Claude."}]
If the request input messages ended with an assistant turn, then the response content will continue directly from that last turn. You can use this to constrain the model's output.
For example, if the input messages were:
[
{"role": "user", "content": "What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun"},
{"role": "assistant", "content": "The best answer is ("}
]
Then the response content might be:
[{"type": "text", "text": "B)"}]
Content generated by the model.
This is an array of content blocks, each of which has a type that determines its shape.
Example:
[{"type": "text", "text": "Hi, I'm Claude."}]
If the request input messages ended with an assistant turn, then the response content will continue directly from that last turn. You can use this to constrain the model's output.
For example, if the input messages were:
[
{"role": "user", "content": "What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun"},
{"role": "assistant", "content": "The best answer is ("}
]
Then the response content might be:
[{"type": "text", "text": "B)"}]
type TextBlock struct{…}
Citations []TextCitationUnionCitations 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.
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.
type CitationCharLocation struct{…}
Type CharLocation
type CitationPageLocation struct{…}
Type PageLocation
type CitationContentBlockLocation struct{…}
Type ContentBlockLocation
type CitationsWebSearchResultLocation struct{…}
Type WebSearchResultLocation
type CitationsSearchResultLocation struct{…}
Type SearchResultLocation
Type Text
type ThinkingBlock struct{…}
Type Thinking
type RedactedThinkingBlock struct{…}
Type RedactedThinking
type ToolUseBlock struct{…}
Type ToolUse
type ServerToolUseBlock struct{…}
Name WebSearch
Type ServerToolUse
type WebSearchToolResultBlock struct{…}
type WebSearchToolResultError struct{…}
ErrorCode WebSearchToolResultErrorErrorCode
Type WebSearchToolResultError
Type WebSearchResult
Type WebSearchToolResult
Model ModelThe model that will complete your prompt.
See models for additional details and options.
The model that will complete your prompt.
See models for additional details and options.
type Model stringThe model that will complete your prompt.
See models for additional details and options.
The model that will complete your prompt.
See models for additional details and options.
High-performance model with early extended thinking
High-performance model with early extended thinking
Fastest and most compact model for near-instant responsiveness
Our fastest model
Hybrid model, capable of near-instant responses and extended thinking
Hybrid model, capable of near-instant responses and extended thinking
High-performance model with extended thinking
High-performance model with extended thinking
High-performance model with extended thinking
Our best model for real-world agents and coding
Our best model for real-world agents and coding
Our most capable model
Our most capable model
Our most capable model
Our most capable model
Excels at writing and complex tasks
Excels at writing and complex tasks
Our previous most fast and cost-effective
Role AssistantConversational role of the generated message.
This will always be "assistant".
Conversational role of the generated message.
This will always be "assistant".
StopReason StopReasonThe 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
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.
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 requestedmax_tokensor the model's maximum"stop_sequence": one of your provided customstop_sequenceswas 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
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.
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 MessageObject type.
For Messages, this is always "message".
Object type.
For Messages, this is always "message".
Usage UsageBilling 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.
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.
CacheCreation CacheCreationBreakdown of cached tokens by TTL
Breakdown of cached tokens by TTL
The number of input tokens used to create the 1 hour cache entry.
The number of input tokens used to create the 5 minute cache entry.
The number of input tokens used to create the cache entry.
The number of input tokens read from the cache.
The number of input tokens which were used.
The number of output tokens which were used.
ServerToolUse ServerToolUsageThe number of server tool requests.
The number of server tool requests.
The number of web search tool requests.
ServiceTier UsageServiceTierIf the request used the priority, standard, or batch tier.
If the request used the priority, standard, or batch tier.
Type Succeeded
type MessageBatchErroredResult struct{…}
Error ErrorResponse
Error ErrorObjectUnion
type InvalidRequestError struct{…}
Type InvalidRequestError
type AuthenticationError struct{…}
Type AuthenticationError
type BillingError struct{…}
Type BillingError
type PermissionError struct{…}
Type PermissionError
type NotFoundError struct{…}
Type NotFoundError
type RateLimitError struct{…}
Type RateLimitError
type GatewayTimeoutError struct{…}
Type TimeoutError
type APIErrorObject struct{…}
Type APIError
type OverloadedError struct{…}
Type OverloadedError
Type Error
Type Errored
type MessageBatchCanceledResult struct{…}
Type Canceled
type MessageBatchExpiredResult struct{…}
Type Expired
type MessageBatchRequestCounts struct{…}
Number of requests in the Message Batch that have been canceled.
This is zero until processing of the entire Message Batch has ended.
Number of requests in the Message Batch that encountered an error.
This is zero until processing of the entire Message Batch has ended.
Number of requests in the Message Batch that have expired.
This is zero until processing of the entire Message Batch has ended.
Number of requests in the Message Batch that are processing.
Number of requests in the Message Batch that have completed successfully.
This is zero until processing of the entire Message Batch has ended.
type MessageBatchResultUnion interface{…}Processing result for this request.
Contains a Message output if processing was successful, an error response if processing failed, or the reason why processing was not attempted, such as cancellation or expiration.
Processing result for this request.
Contains a Message output if processing was successful, an error response if processing failed, or the reason why processing was not attempted, such as cancellation or expiration.
type MessageBatchSucceededResult struct{…}
Message Message
Unique object identifier.
The format and length of IDs may change over time.
Content []ContentBlockUnionContent generated by the model.
This is an array of content blocks, each of which has a type that determines its shape.
Example:
[{"type": "text", "text": "Hi, I'm Claude."}]
If the request input messages ended with an assistant turn, then the response content will continue directly from that last turn. You can use this to constrain the model's output.
For example, if the input messages were:
[
{"role": "user", "content": "What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun"},
{"role": "assistant", "content": "The best answer is ("}
]
Then the response content might be:
[{"type": "text", "text": "B)"}]
Content generated by the model.
This is an array of content blocks, each of which has a type that determines its shape.
Example:
[{"type": "text", "text": "Hi, I'm Claude."}]
If the request input messages ended with an assistant turn, then the response content will continue directly from that last turn. You can use this to constrain the model's output.
For example, if the input messages were:
[
{"role": "user", "content": "What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun"},
{"role": "assistant", "content": "The best answer is ("}
]
Then the response content might be:
[{"type": "text", "text": "B)"}]
type TextBlock struct{…}
Citations []TextCitationUnionCitations 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.
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.
type CitationCharLocation struct{…}
Type CharLocation
type CitationPageLocation struct{…}
Type PageLocation
type CitationContentBlockLocation struct{…}
Type ContentBlockLocation
type CitationsWebSearchResultLocation struct{…}
Type WebSearchResultLocation
type CitationsSearchResultLocation struct{…}
Type SearchResultLocation
Type Text
type ThinkingBlock struct{…}
Type Thinking
type RedactedThinkingBlock struct{…}
Type RedactedThinking
type ToolUseBlock struct{…}
Type ToolUse
type ServerToolUseBlock struct{…}
Name WebSearch
Type ServerToolUse
type WebSearchToolResultBlock struct{…}
type WebSearchToolResultError struct{…}
ErrorCode WebSearchToolResultErrorErrorCode
Type WebSearchToolResultError
Type WebSearchResult
Type WebSearchToolResult
Model ModelThe model that will complete your prompt.
See models for additional details and options.
The model that will complete your prompt.
See models for additional details and options.
type Model stringThe model that will complete your prompt.
See models for additional details and options.
The model that will complete your prompt.
See models for additional details and options.
High-performance model with early extended thinking
High-performance model with early extended thinking
Fastest and most compact model for near-instant responsiveness
Our fastest model
Hybrid model, capable of near-instant responses and extended thinking
Hybrid model, capable of near-instant responses and extended thinking
High-performance model with extended thinking
High-performance model with extended thinking
High-performance model with extended thinking
Our best model for real-world agents and coding
Our best model for real-world agents and coding
Our most capable model
Our most capable model
Our most capable model
Our most capable model
Excels at writing and complex tasks
Excels at writing and complex tasks
Our previous most fast and cost-effective
Role AssistantConversational role of the generated message.
This will always be "assistant".
Conversational role of the generated message.
This will always be "assistant".
StopReason StopReasonThe 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
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.
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 requestedmax_tokensor the model's maximum"stop_sequence": one of your provided customstop_sequenceswas 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
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.
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 MessageObject type.
For Messages, this is always "message".
Object type.
For Messages, this is always "message".
Usage UsageBilling 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.
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.
CacheCreation CacheCreationBreakdown of cached tokens by TTL
Breakdown of cached tokens by TTL
The number of input tokens used to create the 1 hour cache entry.
The number of input tokens used to create the 5 minute cache entry.
The number of input tokens used to create the cache entry.
The number of input tokens read from the cache.
The number of input tokens which were used.
The number of output tokens which were used.
ServerToolUse ServerToolUsageThe number of server tool requests.
The number of server tool requests.
The number of web search tool requests.
ServiceTier UsageServiceTierIf the request used the priority, standard, or batch tier.
If the request used the priority, standard, or batch tier.
Type Succeeded
type MessageBatchErroredResult struct{…}
Error ErrorResponse
Error ErrorObjectUnion
type InvalidRequestError struct{…}
Type InvalidRequestError
type AuthenticationError struct{…}
Type AuthenticationError
type BillingError struct{…}
Type BillingError
type PermissionError struct{…}
Type PermissionError
type NotFoundError struct{…}
Type NotFoundError
type RateLimitError struct{…}
Type RateLimitError
type GatewayTimeoutError struct{…}
Type TimeoutError
type APIErrorObject struct{…}
Type APIError
type OverloadedError struct{…}
Type OverloadedError
Type Error
Type Errored
type MessageBatchCanceledResult struct{…}
Type Canceled
type MessageBatchExpiredResult struct{…}
Type Expired
type MessageBatchSucceededResult struct{…}
Message Message
Unique object identifier.
The format and length of IDs may change over time.
Content []ContentBlockUnionContent generated by the model.
This is an array of content blocks, each of which has a type that determines its shape.
Example:
[{"type": "text", "text": "Hi, I'm Claude."}]
If the request input messages ended with an assistant turn, then the response content will continue directly from that last turn. You can use this to constrain the model's output.
For example, if the input messages were:
[
{"role": "user", "content": "What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun"},
{"role": "assistant", "content": "The best answer is ("}
]
Then the response content might be:
[{"type": "text", "text": "B)"}]
Content generated by the model.
This is an array of content blocks, each of which has a type that determines its shape.
Example:
[{"type": "text", "text": "Hi, I'm Claude."}]
If the request input messages ended with an assistant turn, then the response content will continue directly from that last turn. You can use this to constrain the model's output.
For example, if the input messages were:
[
{"role": "user", "content": "What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun"},
{"role": "assistant", "content": "The best answer is ("}
]
Then the response content might be:
[{"type": "text", "text": "B)"}]
type TextBlock struct{…}
Citations []TextCitationUnionCitations 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.
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.
type CitationCharLocation struct{…}
Type CharLocation
type CitationPageLocation struct{…}
Type PageLocation
type CitationContentBlockLocation struct{…}
Type ContentBlockLocation
type CitationsWebSearchResultLocation struct{…}
Type WebSearchResultLocation
type CitationsSearchResultLocation struct{…}
Type SearchResultLocation
Type Text
type ThinkingBlock struct{…}
Type Thinking
type RedactedThinkingBlock struct{…}
Type RedactedThinking
type ToolUseBlock struct{…}
Type ToolUse
type ServerToolUseBlock struct{…}
Name WebSearch
Type ServerToolUse
type WebSearchToolResultBlock struct{…}
type WebSearchToolResultError struct{…}
ErrorCode WebSearchToolResultErrorErrorCode
Type WebSearchToolResultError
Type WebSearchResult
Type WebSearchToolResult
Model ModelThe model that will complete your prompt.
See models for additional details and options.
The model that will complete your prompt.
See models for additional details and options.
type Model stringThe model that will complete your prompt.
See models for additional details and options.
The model that will complete your prompt.
See models for additional details and options.
High-performance model with early extended thinking
High-performance model with early extended thinking
Fastest and most compact model for near-instant responsiveness
Our fastest model
Hybrid model, capable of near-instant responses and extended thinking
Hybrid model, capable of near-instant responses and extended thinking
High-performance model with extended thinking
High-performance model with extended thinking
High-performance model with extended thinking
Our best model for real-world agents and coding
Our best model for real-world agents and coding
Our most capable model
Our most capable model
Our most capable model
Our most capable model
Excels at writing and complex tasks
Excels at writing and complex tasks
Our previous most fast and cost-effective
Role AssistantConversational role of the generated message.
This will always be "assistant".
Conversational role of the generated message.
This will always be "assistant".
StopReason StopReasonThe 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
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.
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 requestedmax_tokensor the model's maximum"stop_sequence": one of your provided customstop_sequenceswas 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
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.
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 MessageObject type.
For Messages, this is always "message".
Object type.
For Messages, this is always "message".
Usage UsageBilling 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.
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.
CacheCreation CacheCreationBreakdown of cached tokens by TTL
Breakdown of cached tokens by TTL
The number of input tokens used to create the 1 hour cache entry.
The number of input tokens used to create the 5 minute cache entry.
The number of input tokens used to create the cache entry.
The number of input tokens read from the cache.
The number of input tokens which were used.
The number of output tokens which were used.
ServerToolUse ServerToolUsageThe number of server tool requests.
The number of server tool requests.
The number of web search tool requests.
ServiceTier UsageServiceTierIf the request used the priority, standard, or batch tier.
If the request used the priority, standard, or batch tier.