Beta
ModelsExpand Collapse
AnthropicBeta = Union[str, Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 15 more]]
UnionMember1 = Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 15 more]
class BetaAPIError: …
type: Literal["api_error"]
class BetaAuthenticationError: …
type: Literal["authentication_error"]
class BetaBillingError: …
type: Literal["billing_error"]
class BetaInvalidRequestError: …
type: Literal["invalid_request_error"]
class BetaAuthenticationError: …
type: Literal["authentication_error"]
class BetaBillingError: …
type: Literal["billing_error"]
class BetaPermissionError: …
type: Literal["permission_error"]
class BetaNotFoundError: …
type: Literal["not_found_error"]
class BetaRateLimitError: …
type: Literal["rate_limit_error"]
class BetaGatewayTimeoutError: …
type: Literal["timeout_error"]
class BetaAPIError: …
type: Literal["api_error"]
class BetaOverloadedError: …
type: Literal["overloaded_error"]
class BetaErrorResponse: …
class BetaInvalidRequestError: …
type: Literal["invalid_request_error"]
class BetaAuthenticationError: …
type: Literal["authentication_error"]
class BetaBillingError: …
type: Literal["billing_error"]
class BetaPermissionError: …
type: Literal["permission_error"]
class BetaNotFoundError: …
type: Literal["not_found_error"]
class BetaRateLimitError: …
type: Literal["rate_limit_error"]
class BetaGatewayTimeoutError: …
type: Literal["timeout_error"]
class BetaAPIError: …
type: Literal["api_error"]
class BetaOverloadedError: …
type: Literal["overloaded_error"]
type: Literal["error"]
class BetaGatewayTimeoutError: …
type: Literal["timeout_error"]
class BetaInvalidRequestError: …
type: Literal["invalid_request_error"]
class BetaNotFoundError: …
type: Literal["not_found_error"]
class BetaOverloadedError: …
type: Literal["overloaded_error"]
class BetaPermissionError: …
type: Literal["permission_error"]
class BetaRateLimitError: …
type: Literal["rate_limit_error"]
BetaFiles
Delete File
Download File
Get File Metadata
ModelsExpand Collapse
class DeletedFile: …
ID of the deleted file.
type: Optional[Literal["file_deleted"]]Deleted object type.
For file deletion, this is always "file_deleted".
Deleted object type.
For file deletion, this is always "file_deleted".
class FileMetadata: …
Unique object identifier.
The format and length of IDs may change over time.
RFC 3339 datetime string representing when the file was created.
Original filename of the uploaded file.
MIME type of the file.
Size of the file in bytes.
type: Literal["file"]Object type.
For files, this is always "file".
Object type.
For files, this is always "file".
Whether the file can be downloaded.
BetaMessages
Count tokens in a Message
Create a Message
ModelsExpand Collapse
class BetaAllThinkingTurns: …
type: Literal["all"]
class BetaBase64ImageSource: …
media_type: Literal["image/jpeg", "image/png", "image/gif", "image/webp"]
type: Literal["base64"]
class BetaBase64PDFSource: …
media_type: Literal["application/pdf"]
type: Literal["base64"]
class BetaBashCodeExecutionOutputBlock: …
type: Literal["bash_code_execution_output"]
class BetaBashCodeExecutionOutputBlockParam: …
type: Literal["bash_code_execution_output"]
class BetaBashCodeExecutionResultBlock: …
type: Literal["bash_code_execution_output"]
type: Literal["bash_code_execution_result"]
class BetaBashCodeExecutionResultBlockParam: …
type: Literal["bash_code_execution_output"]
type: Literal["bash_code_execution_result"]
class BetaBashCodeExecutionToolResultBlock: …
content: Content
class BetaBashCodeExecutionToolResultError: …
error_code: Literal["invalid_tool_input", "unavailable", "too_many_requests", 2 more]
type: Literal["bash_code_execution_tool_result_error"]
class BetaBashCodeExecutionResultBlock: …
type: Literal["bash_code_execution_output"]
type: Literal["bash_code_execution_result"]
type: Literal["bash_code_execution_tool_result"]
class BetaBashCodeExecutionToolResultBlockParam: …
content: Content
class BetaBashCodeExecutionToolResultErrorParam: …
error_code: Literal["invalid_tool_input", "unavailable", "too_many_requests", 2 more]
type: Literal["bash_code_execution_tool_result_error"]
class BetaBashCodeExecutionResultBlockParam: …
type: Literal["bash_code_execution_output"]
type: Literal["bash_code_execution_result"]
type: Literal["bash_code_execution_tool_result"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
class BetaBashCodeExecutionToolResultError: …
error_code: Literal["invalid_tool_input", "unavailable", "too_many_requests", 2 more]
type: Literal["bash_code_execution_tool_result_error"]
class BetaBashCodeExecutionToolResultErrorParam: …
error_code: Literal["invalid_tool_input", "unavailable", "too_many_requests", 2 more]
type: Literal["bash_code_execution_tool_result_error"]
class BetaCacheControlEphemeral: …
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
class BetaCacheCreation: …
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.
class BetaCitationCharLocation: …
type: Literal["char_location"]
class BetaCitationCharLocationParam: …
type: Literal["char_location"]
class BetaCitationConfig: …
class BetaCitationContentBlockLocation: …
type: Literal["content_block_location"]
class BetaCitationContentBlockLocationParam: …
type: Literal["content_block_location"]
class BetaCitationPageLocation: …
type: Literal["page_location"]
class BetaCitationPageLocationParam: …
type: Literal["page_location"]
class BetaCitationSearchResultLocation: …
type: Literal["search_result_location"]
class BetaCitationSearchResultLocationParam: …
type: Literal["search_result_location"]
class BetaCitationWebSearchResultLocationParam: …
type: Literal["web_search_result_location"]
class BetaCitationsConfigParam: …
class BetaCitationsDelta: …
citation: Citation
class BetaCitationCharLocation: …
type: Literal["char_location"]
class BetaCitationPageLocation: …
type: Literal["page_location"]
class BetaCitationContentBlockLocation: …
type: Literal["content_block_location"]
class BetaCitationsWebSearchResultLocation: …
type: Literal["web_search_result_location"]
class BetaCitationSearchResultLocation: …
type: Literal["search_result_location"]
type: Literal["citations_delta"]
class BetaCitationsWebSearchResultLocation: …
type: Literal["web_search_result_location"]
class BetaClearThinking20251015Edit: …
type: Literal["clear_thinking_20251015"]
keep: Optional[Keep]Number of most recent assistant turns to keep thinking blocks for. Older turns will have their thinking blocks removed.
Number of most recent assistant turns to keep thinking blocks for. Older turns will have their thinking blocks removed.
class BetaThinkingTurns: …
type: Literal["thinking_turns"]
class BetaAllThinkingTurns: …
type: Literal["all"]
KeepUnionMember2 = Literal["all"]
class BetaClearThinking20251015EditResponse: …
Number of input tokens cleared by this edit.
Number of thinking turns that were cleared.
type: Literal["clear_thinking_20251015"]The type of context management edit applied.
The type of context management edit applied.
class BetaClearToolUses20250919Edit: …
type: Literal["clear_tool_uses_20250919"]
clear_at_least: Optional[BetaInputTokensClearAtLeast]Minimum number of tokens that must be cleared when triggered. Context will only be modified if at least this many tokens can be removed.
Minimum number of tokens that must be cleared when triggered. Context will only be modified if at least this many tokens can be removed.
type: Literal["input_tokens"]
clear_tool_inputs: Optional[Union[bool, List[str], null]]Whether to clear all tool inputs (bool) or specific tool inputs to clear (list)
Whether to clear all tool inputs (bool) or specific tool inputs to clear (list)
Tool names whose uses are preserved from clearing
keep: Optional[BetaToolUsesKeep]Number of tool uses to retain in the conversation
Number of tool uses to retain in the conversation
type: Literal["tool_uses"]
trigger: Optional[Trigger]Condition that triggers the context management strategy
Condition that triggers the context management strategy
class BetaInputTokensTrigger: …
type: Literal["input_tokens"]
class BetaToolUsesTrigger: …
type: Literal["tool_uses"]
class BetaClearToolUses20250919EditResponse: …
Number of input tokens cleared by this edit.
Number of tool uses that were cleared.
type: Literal["clear_tool_uses_20250919"]The type of context management edit applied.
The type of context management edit applied.
class BetaCodeExecutionOutputBlock: …
type: Literal["code_execution_output"]
class BetaCodeExecutionOutputBlockParam: …
type: Literal["code_execution_output"]
class BetaCodeExecutionResultBlock: …
type: Literal["code_execution_output"]
type: Literal["code_execution_result"]
class BetaCodeExecutionResultBlockParam: …
type: Literal["code_execution_output"]
type: Literal["code_execution_result"]
class BetaCodeExecutionTool20250522: …
name: Literal["code_execution"]Name 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: Literal["code_execution_20250522"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
class BetaCodeExecutionTool20250825: …
name: Literal["code_execution"]Name 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: Literal["code_execution_20250825"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
class BetaCodeExecutionToolResultBlock: …
class BetaCodeExecutionToolResultError: …
type: Literal["code_execution_tool_result_error"]
class BetaCodeExecutionResultBlock: …
type: Literal["code_execution_output"]
type: Literal["code_execution_result"]
type: Literal["code_execution_tool_result"]
class BetaCodeExecutionToolResultError: …
type: Literal["code_execution_tool_result_error"]
class BetaCodeExecutionResultBlock: …
type: Literal["code_execution_output"]
type: Literal["code_execution_result"]
class BetaCodeExecutionToolResultBlockParam: …
class BetaCodeExecutionToolResultErrorParam: …
type: Literal["code_execution_tool_result_error"]
class BetaCodeExecutionResultBlockParam: …
type: Literal["code_execution_output"]
type: Literal["code_execution_result"]
type: Literal["code_execution_tool_result"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
class BetaCodeExecutionToolResultErrorParam: …
type: Literal["code_execution_tool_result_error"]
class BetaCodeExecutionResultBlockParam: …
type: Literal["code_execution_output"]
type: Literal["code_execution_result"]
class BetaCodeExecutionToolResultError: …
type: Literal["code_execution_tool_result_error"]
BetaCodeExecutionToolResultErrorCode = Literal["invalid_tool_input", "unavailable", "too_many_requests", "execution_time_exceeded"]
class BetaCodeExecutionToolResultErrorParam: …
type: Literal["code_execution_tool_result_error"]
class BetaContainer: …Information about the container used in the request (for the code execution tool)
Information about the container used in the request (for the code execution tool)
Identifier for the container used in this request
The time at which the container will expire.
Skills loaded in the container
Skills loaded in the container
Skill ID
type: Literal["anthropic", "custom"]Type of skill - either 'anthropic' (built-in) or 'custom' (user-defined)
Type of skill - either 'anthropic' (built-in) or 'custom' (user-defined)
Skill version or 'latest' for most recent version
class BetaContainerParams: …Container parameters with skills to be loaded.
Container parameters with skills to be loaded.
Container id
List of skills to load in the container
List of skills to load in the container
Skill ID
type: Literal["anthropic", "custom"]Type of skill - either 'anthropic' (built-in) or 'custom' (user-defined)
Type of skill - either 'anthropic' (built-in) or 'custom' (user-defined)
Skill version or 'latest' for most recent version
class BetaContainerUploadBlock: …Response model for a file uploaded to the container.
Response model for a file uploaded to the container.
type: Literal["container_upload"]
class BetaContainerUploadBlockParam: …A content block that represents a file to be uploaded to the container
Files uploaded via this block will be available in the container's input directory.
A content block that represents a file to be uploaded to the container Files uploaded via this block will be available in the container's input directory.
type: Literal["container_upload"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
Response model for a file uploaded to the container.
Response model for a file uploaded to the container.
class BetaTextBlock: …
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.
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.
class BetaCitationCharLocation: …
type: Literal["char_location"]
class BetaCitationPageLocation: …
type: Literal["page_location"]
class BetaCitationContentBlockLocation: …
type: Literal["content_block_location"]
class BetaCitationsWebSearchResultLocation: …
type: Literal["web_search_result_location"]
class BetaCitationSearchResultLocation: …
type: Literal["search_result_location"]
type: Literal["text"]
class BetaThinkingBlock: …
type: Literal["thinking"]
class BetaRedactedThinkingBlock: …
type: Literal["redacted_thinking"]
class BetaToolUseBlock: …
type: Literal["tool_use"]
class BetaServerToolUseBlock: …
name: Literal["web_search", "web_fetch", "code_execution", 2 more]
type: Literal["server_tool_use"]
class BetaWebSearchToolResultBlock: …
class BetaWebSearchToolResultError: …
type: Literal["web_search_tool_result_error"]
type: Literal["web_search_result"]
type: Literal["web_search_tool_result"]
class BetaWebFetchToolResultBlock: …
content: Content
class BetaWebFetchToolResultErrorBlock: …
type: Literal["web_fetch_tool_result_error"]
class BetaWebFetchBlock: …
citations: Optional[BetaCitationConfig]Citation configuration for the document
Citation configuration for the document
source: Source
class BetaBase64PDFSource: …
media_type: Literal["application/pdf"]
type: Literal["base64"]
class BetaPlainTextSource: …
media_type: Literal["text/plain"]
type: Literal["text"]
The title of the document
type: Literal["document"]
ISO 8601 timestamp when the content was retrieved
type: Literal["web_fetch_result"]
Fetched content URL
type: Literal["web_fetch_tool_result"]
class BetaCodeExecutionToolResultBlock: …
class BetaCodeExecutionToolResultError: …
type: Literal["code_execution_tool_result_error"]
class BetaCodeExecutionResultBlock: …
type: Literal["code_execution_output"]
type: Literal["code_execution_result"]
type: Literal["code_execution_tool_result"]
class BetaBashCodeExecutionToolResultBlock: …
content: Content
class BetaBashCodeExecutionToolResultError: …
error_code: Literal["invalid_tool_input", "unavailable", "too_many_requests", 2 more]
type: Literal["bash_code_execution_tool_result_error"]
class BetaBashCodeExecutionResultBlock: …
type: Literal["bash_code_execution_output"]
type: Literal["bash_code_execution_result"]
type: Literal["bash_code_execution_tool_result"]
class BetaTextEditorCodeExecutionToolResultBlock: …
content: Content
class BetaTextEditorCodeExecutionToolResultError: …
error_code: Literal["invalid_tool_input", "unavailable", "too_many_requests", 2 more]
type: Literal["text_editor_code_execution_tool_result_error"]
class BetaTextEditorCodeExecutionViewResultBlock: …
file_type: Literal["text", "image", "pdf"]
type: Literal["text_editor_code_execution_view_result"]
class BetaTextEditorCodeExecutionCreateResultBlock: …
type: Literal["text_editor_code_execution_create_result"]
class BetaTextEditorCodeExecutionStrReplaceResultBlock: …
type: Literal["text_editor_code_execution_str_replace_result"]
type: Literal["text_editor_code_execution_tool_result"]
class BetaMCPToolUseBlock: …
The name of the MCP tool
The name of the MCP server
type: Literal["mcp_tool_use"]
class BetaMCPToolResultBlock: …
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.
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.
class BetaCitationCharLocation: …
type: Literal["char_location"]
class BetaCitationPageLocation: …
type: Literal["page_location"]
class BetaCitationContentBlockLocation: …
type: Literal["content_block_location"]
class BetaCitationsWebSearchResultLocation: …
type: Literal["web_search_result_location"]
class BetaCitationSearchResultLocation: …
type: Literal["search_result_location"]
type: Literal["text"]
type: Literal["mcp_tool_result"]
class BetaContainerUploadBlock: …Response model for a file uploaded to the container.
Response model for a file uploaded to the container.
type: Literal["container_upload"]
Regular text content.
Regular text content.
class BetaTextBlockParam: …
type: Literal["text"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
class BetaCitationCharLocationParam: …
type: Literal["char_location"]
class BetaCitationPageLocationParam: …
type: Literal["page_location"]
class BetaCitationContentBlockLocationParam: …
type: Literal["content_block_location"]
class BetaCitationWebSearchResultLocationParam: …
type: Literal["web_search_result_location"]
class BetaCitationSearchResultLocationParam: …
type: Literal["search_result_location"]
class BetaImageBlockParam: …
source: Source
class BetaBase64ImageSource: …
media_type: Literal["image/jpeg", "image/png", "image/gif", "image/webp"]
type: Literal["base64"]
class BetaURLImageSource: …
type: Literal["url"]
class BetaFileImageSource: …
type: Literal["file"]
type: Literal["image"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
class BetaRequestDocumentBlock: …
source: Source
class BetaBase64PDFSource: …
media_type: Literal["application/pdf"]
type: Literal["base64"]
class BetaPlainTextSource: …
media_type: Literal["text/plain"]
type: Literal["text"]
class BetaContentBlockSource: …
class BetaTextBlockParam: …
type: Literal["text"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
class BetaCitationCharLocationParam: …
type: Literal["char_location"]
class BetaCitationPageLocationParam: …
type: Literal["page_location"]
class BetaCitationContentBlockLocationParam: …
type: Literal["content_block_location"]
class BetaCitationWebSearchResultLocationParam: …
type: Literal["web_search_result_location"]
class BetaCitationSearchResultLocationParam: …
type: Literal["search_result_location"]
class BetaImageBlockParam: …
source: Source
class BetaBase64ImageSource: …
media_type: Literal["image/jpeg", "image/png", "image/gif", "image/webp"]
type: Literal["base64"]
class BetaURLImageSource: …
type: Literal["url"]
class BetaFileImageSource: …
type: Literal["file"]
type: Literal["image"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
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: Literal["content"]
class BetaURLPDFSource: …
type: Literal["url"]
class BetaFileDocumentSource: …
type: Literal["file"]
type: Literal["document"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
citations: Optional[BetaCitationsConfigParam]
class BetaSearchResultBlockParam: …
type: Literal["text"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
class BetaCitationCharLocationParam: …
type: Literal["char_location"]
class BetaCitationPageLocationParam: …
type: Literal["page_location"]
class BetaCitationContentBlockLocationParam: …
type: Literal["content_block_location"]
class BetaCitationWebSearchResultLocationParam: …
type: Literal["web_search_result_location"]
class BetaCitationSearchResultLocationParam: …
type: Literal["search_result_location"]
type: Literal["search_result"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
citations: Optional[BetaCitationsConfigParam]
class BetaThinkingBlockParam: …
type: Literal["thinking"]
class BetaRedactedThinkingBlockParam: …
type: Literal["redacted_thinking"]
class BetaToolUseBlockParam: …
type: Literal["tool_use"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
class BetaToolResultBlockParam: …
type: Literal["tool_result"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
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: Optional[Union[str, List[Content], null]]
Content = List[Content]
class BetaTextBlockParam: …
type: Literal["text"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
class BetaCitationCharLocationParam: …
type: Literal["char_location"]
class BetaCitationPageLocationParam: …
type: Literal["page_location"]
class BetaCitationContentBlockLocationParam: …
type: Literal["content_block_location"]
class BetaCitationWebSearchResultLocationParam: …
type: Literal["web_search_result_location"]
class BetaCitationSearchResultLocationParam: …
type: Literal["search_result_location"]
class BetaImageBlockParam: …
source: Source
class BetaBase64ImageSource: …
media_type: Literal["image/jpeg", "image/png", "image/gif", "image/webp"]
type: Literal["base64"]
class BetaURLImageSource: …
type: Literal["url"]
class BetaFileImageSource: …
type: Literal["file"]
type: Literal["image"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
class BetaSearchResultBlockParam: …
type: Literal["text"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
class BetaCitationCharLocationParam: …
type: Literal["char_location"]
class BetaCitationPageLocationParam: …
type: Literal["page_location"]
class BetaCitationContentBlockLocationParam: …
type: Literal["content_block_location"]
class BetaCitationWebSearchResultLocationParam: …
type: Literal["web_search_result_location"]
class BetaCitationSearchResultLocationParam: …
type: Literal["search_result_location"]
type: Literal["search_result"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
citations: Optional[BetaCitationsConfigParam]
class BetaRequestDocumentBlock: …
source: Source
class BetaBase64PDFSource: …
media_type: Literal["application/pdf"]
type: Literal["base64"]
class BetaPlainTextSource: …
media_type: Literal["text/plain"]
type: Literal["text"]
class BetaContentBlockSource: …
class BetaTextBlockParam: …
type: Literal["text"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
class BetaCitationCharLocationParam: …
type: Literal["char_location"]
class BetaCitationPageLocationParam: …
type: Literal["page_location"]
class BetaCitationContentBlockLocationParam: …
type: Literal["content_block_location"]
class BetaCitationWebSearchResultLocationParam: …
type: Literal["web_search_result_location"]
class BetaCitationSearchResultLocationParam: …
type: Literal["search_result_location"]
class BetaImageBlockParam: …
source: Source
class BetaBase64ImageSource: …
media_type: Literal["image/jpeg", "image/png", "image/gif", "image/webp"]
type: Literal["base64"]
class BetaURLImageSource: …
type: Literal["url"]
class BetaFileImageSource: …
type: Literal["file"]
type: Literal["image"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
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: Literal["content"]
class BetaURLPDFSource: …
type: Literal["url"]
class BetaFileDocumentSource: …
type: Literal["file"]
type: Literal["document"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
citations: Optional[BetaCitationsConfigParam]
class BetaServerToolUseBlockParam: …
name: Literal["web_search", "web_fetch", "code_execution", 2 more]
type: Literal["server_tool_use"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
class BetaWebSearchToolResultBlockParam: …
type: Literal["web_search_result"]
class BetaWebSearchToolRequestError: …
type: Literal["web_search_tool_result_error"]
type: Literal["web_search_tool_result"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
class BetaWebFetchToolResultBlockParam: …
content: Content
class BetaWebFetchToolResultErrorBlockParam: …
type: Literal["web_fetch_tool_result_error"]
class BetaWebFetchBlockParam: …
source: Source
class BetaBase64PDFSource: …
media_type: Literal["application/pdf"]
type: Literal["base64"]
class BetaPlainTextSource: …
media_type: Literal["text/plain"]
type: Literal["text"]
class BetaContentBlockSource: …
class BetaTextBlockParam: …
type: Literal["text"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
class BetaCitationCharLocationParam: …
type: Literal["char_location"]
class BetaCitationPageLocationParam: …
type: Literal["page_location"]
class BetaCitationContentBlockLocationParam: …
type: Literal["content_block_location"]
class BetaCitationWebSearchResultLocationParam: …
type: Literal["web_search_result_location"]
class BetaCitationSearchResultLocationParam: …
type: Literal["search_result_location"]
class BetaImageBlockParam: …
source: Source
class BetaBase64ImageSource: …
media_type: Literal["image/jpeg", "image/png", "image/gif", "image/webp"]
type: Literal["base64"]
class BetaURLImageSource: …
type: Literal["url"]
class BetaFileImageSource: …
type: Literal["file"]
type: Literal["image"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
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: Literal["content"]
class BetaURLPDFSource: …
type: Literal["url"]
class BetaFileDocumentSource: …
type: Literal["file"]
type: Literal["document"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
citations: Optional[BetaCitationsConfigParam]
type: Literal["web_fetch_result"]
Fetched content URL
ISO 8601 timestamp when the content was retrieved
type: Literal["web_fetch_tool_result"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
class BetaCodeExecutionToolResultBlockParam: …
class BetaCodeExecutionToolResultErrorParam: …
type: Literal["code_execution_tool_result_error"]
class BetaCodeExecutionResultBlockParam: …
type: Literal["code_execution_output"]
type: Literal["code_execution_result"]
type: Literal["code_execution_tool_result"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
class BetaBashCodeExecutionToolResultBlockParam: …
content: Content
class BetaBashCodeExecutionToolResultErrorParam: …
error_code: Literal["invalid_tool_input", "unavailable", "too_many_requests", 2 more]
type: Literal["bash_code_execution_tool_result_error"]
class BetaBashCodeExecutionResultBlockParam: …
type: Literal["bash_code_execution_output"]
type: Literal["bash_code_execution_result"]
type: Literal["bash_code_execution_tool_result"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
class BetaTextEditorCodeExecutionToolResultBlockParam: …
content: Content
class BetaTextEditorCodeExecutionToolResultErrorParam: …
error_code: Literal["invalid_tool_input", "unavailable", "too_many_requests", 2 more]
type: Literal["text_editor_code_execution_tool_result_error"]
class BetaTextEditorCodeExecutionViewResultBlockParam: …
file_type: Literal["text", "image", "pdf"]
type: Literal["text_editor_code_execution_view_result"]
class BetaTextEditorCodeExecutionCreateResultBlockParam: …
type: Literal["text_editor_code_execution_create_result"]
class BetaTextEditorCodeExecutionStrReplaceResultBlockParam: …
type: Literal["text_editor_code_execution_str_replace_result"]
type: Literal["text_editor_code_execution_tool_result"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
class BetaMCPToolUseBlockParam: …
The name of the MCP server
type: Literal["mcp_tool_use"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
class BetaRequestMCPToolResultBlockParam: …
type: Literal["mcp_tool_result"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
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: Literal["text"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
class BetaCitationCharLocationParam: …
type: Literal["char_location"]
class BetaCitationPageLocationParam: …
type: Literal["page_location"]
class BetaCitationContentBlockLocationParam: …
type: Literal["content_block_location"]
class BetaCitationWebSearchResultLocationParam: …
type: Literal["web_search_result_location"]
class BetaCitationSearchResultLocationParam: …
type: Literal["search_result_location"]
class BetaContainerUploadBlockParam: …A content block that represents a file to be uploaded to the container
Files uploaded via this block will be available in the container's input directory.
A content block that represents a file to be uploaded to the container Files uploaded via this block will be available in the container's input directory.
type: Literal["container_upload"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
class BetaContentBlockSource: …
class BetaTextBlockParam: …
type: Literal["text"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
class BetaCitationCharLocationParam: …
type: Literal["char_location"]
class BetaCitationPageLocationParam: …
type: Literal["page_location"]
class BetaCitationContentBlockLocationParam: …
type: Literal["content_block_location"]
class BetaCitationWebSearchResultLocationParam: …
type: Literal["web_search_result_location"]
class BetaCitationSearchResultLocationParam: …
type: Literal["search_result_location"]
class BetaImageBlockParam: …
source: Source
class BetaBase64ImageSource: …
media_type: Literal["image/jpeg", "image/png", "image/gif", "image/webp"]
type: Literal["base64"]
class BetaURLImageSource: …
type: Literal["url"]
class BetaFileImageSource: …
type: Literal["file"]
type: Literal["image"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
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: Literal["content"]
class BetaTextBlockParam: …
type: Literal["text"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
class BetaCitationCharLocationParam: …
type: Literal["char_location"]
class BetaCitationPageLocationParam: …
type: Literal["page_location"]
class BetaCitationContentBlockLocationParam: …
type: Literal["content_block_location"]
class BetaCitationWebSearchResultLocationParam: …
type: Literal["web_search_result_location"]
class BetaCitationSearchResultLocationParam: …
type: Literal["search_result_location"]
class BetaImageBlockParam: …
source: Source
class BetaBase64ImageSource: …
media_type: Literal["image/jpeg", "image/png", "image/gif", "image/webp"]
type: Literal["base64"]
class BetaURLImageSource: …
type: Literal["url"]
class BetaFileImageSource: …
type: Literal["file"]
type: Literal["image"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
class BetaContextManagementConfig: …
edits: Optional[List[Edit]]List of context management edits to apply
List of context management edits to apply
class BetaClearToolUses20250919Edit: …
type: Literal["clear_tool_uses_20250919"]
clear_at_least: Optional[BetaInputTokensClearAtLeast]Minimum number of tokens that must be cleared when triggered. Context will only be modified if at least this many tokens can be removed.
Minimum number of tokens that must be cleared when triggered. Context will only be modified if at least this many tokens can be removed.
type: Literal["input_tokens"]
clear_tool_inputs: Optional[Union[bool, List[str], null]]Whether to clear all tool inputs (bool) or specific tool inputs to clear (list)
Whether to clear all tool inputs (bool) or specific tool inputs to clear (list)
Tool names whose uses are preserved from clearing
keep: Optional[BetaToolUsesKeep]Number of tool uses to retain in the conversation
Number of tool uses to retain in the conversation
type: Literal["tool_uses"]
trigger: Optional[Trigger]Condition that triggers the context management strategy
Condition that triggers the context management strategy
class BetaInputTokensTrigger: …
type: Literal["input_tokens"]
class BetaToolUsesTrigger: …
type: Literal["tool_uses"]
class BetaClearThinking20251015Edit: …
type: Literal["clear_thinking_20251015"]
keep: Optional[Keep]Number of most recent assistant turns to keep thinking blocks for. Older turns will have their thinking blocks removed.
Number of most recent assistant turns to keep thinking blocks for. Older turns will have their thinking blocks removed.
class BetaThinkingTurns: …
type: Literal["thinking_turns"]
class BetaAllThinkingTurns: …
type: Literal["all"]
KeepUnionMember2 = Literal["all"]
class BetaContextManagementResponse: …
applied_edits: List[AppliedEdit]List of context management edits that were applied.
List of context management edits that were applied.
class BetaClearToolUses20250919EditResponse: …
Number of input tokens cleared by this edit.
Number of tool uses that were cleared.
type: Literal["clear_tool_uses_20250919"]The type of context management edit applied.
The type of context management edit applied.
class BetaClearThinking20251015EditResponse: …
Number of input tokens cleared by this edit.
Number of thinking turns that were cleared.
type: Literal["clear_thinking_20251015"]The type of context management edit applied.
The type of context management edit applied.
class BetaCountTokensContextManagementResponse: …
The original token count before context management was applied
class BetaDocumentBlock: …
citations: Optional[BetaCitationConfig]Citation configuration for the document
Citation configuration for the document
source: Source
class BetaBase64PDFSource: …
media_type: Literal["application/pdf"]
type: Literal["base64"]
class BetaPlainTextSource: …
media_type: Literal["text/plain"]
type: Literal["text"]
The title of the document
type: Literal["document"]
class BetaFileDocumentSource: …
type: Literal["file"]
class BetaFileImageSource: …
type: Literal["file"]
class BetaImageBlockParam: …
source: Source
class BetaBase64ImageSource: …
media_type: Literal["image/jpeg", "image/png", "image/gif", "image/webp"]
type: Literal["base64"]
class BetaURLImageSource: …
type: Literal["url"]
class BetaFileImageSource: …
type: Literal["file"]
type: Literal["image"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
class BetaInputJSONDelta: …
type: Literal["input_json_delta"]
class BetaInputTokensClearAtLeast: …
type: Literal["input_tokens"]
class BetaInputTokensTrigger: …
type: Literal["input_tokens"]
class BetaMCPToolResultBlock: …
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.
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.
class BetaCitationCharLocation: …
type: Literal["char_location"]
class BetaCitationPageLocation: …
type: Literal["page_location"]
class BetaCitationContentBlockLocation: …
type: Literal["content_block_location"]
class BetaCitationsWebSearchResultLocation: …
type: Literal["web_search_result_location"]
class BetaCitationSearchResultLocation: …
type: Literal["search_result_location"]
type: Literal["text"]
type: Literal["mcp_tool_result"]
class BetaMCPToolUseBlock: …
The name of the MCP tool
The name of the MCP server
type: Literal["mcp_tool_use"]
class BetaMCPToolUseBlockParam: …
The name of the MCP server
type: Literal["mcp_tool_use"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
class BetaMemoryTool20250818: …
name: Literal["memory"]Name 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: Literal["memory_20250818"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
class BetaMemoryTool20250818ViewCommand: …
command: Literal["view"]Command type identifier
Command type identifier
Path to directory or file to view
Optional line range for viewing specific lines
class BetaMemoryTool20250818CreateCommand: …
command: Literal["create"]Command type identifier
Command type identifier
Content to write to the file
Path where the file should be created
class BetaMemoryTool20250818StrReplaceCommand: …
command: Literal["str_replace"]Command type identifier
Command type identifier
Text to replace with
Text to search for and replace
Path to the file where text should be replaced
class BetaMemoryTool20250818InsertCommand: …
command: Literal["insert"]Command type identifier
Command type identifier
Line number where text should be inserted
Text to insert at the specified line
Path to the file where text should be inserted
class BetaMemoryTool20250818DeleteCommand: …
command: Literal["delete"]Command type identifier
Command type identifier
Path to the file or directory to delete
class BetaMemoryTool20250818RenameCommand: …
command: Literal["rename"]Command type identifier
Command type identifier
New path for the file or directory
Current path of the file or directory
class BetaMemoryTool20250818CreateCommand: …
command: Literal["create"]Command type identifier
Command type identifier
Content to write to the file
Path where the file should be created
class BetaMemoryTool20250818DeleteCommand: …
command: Literal["delete"]Command type identifier
Command type identifier
Path to the file or directory to delete
class BetaMemoryTool20250818InsertCommand: …
command: Literal["insert"]Command type identifier
Command type identifier
Line number where text should be inserted
Text to insert at the specified line
Path to the file where text should be inserted
class BetaMemoryTool20250818RenameCommand: …
command: Literal["rename"]Command type identifier
Command type identifier
New path for the file or directory
Current path of the file or directory
class BetaMemoryTool20250818StrReplaceCommand: …
command: Literal["str_replace"]Command type identifier
Command type identifier
Text to replace with
Text to search for and replace
Path to the file where text should be replaced
class BetaMemoryTool20250818ViewCommand: …
command: Literal["view"]Command type identifier
Command type identifier
Path to directory or file to view
Optional line range for viewing specific lines
class BetaMessage: …
Unique object identifier.
The format and length of IDs may change over time.
container: Optional[BetaContainer]Information about the container used in the request (for the code execution tool)
Information about the container used in the request (for the code execution tool)
Identifier for the container used in this request
The time at which the container will expire.
Skills loaded in the container
Skills loaded in the container
Skill ID
type: Literal["anthropic", "custom"]Type of skill - either 'anthropic' (built-in) or 'custom' (user-defined)
Type of skill - either 'anthropic' (built-in) or 'custom' (user-defined)
Skill version or 'latest' for most recent version
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)"}]
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)"}]
class BetaTextBlock: …
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.
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.
class BetaCitationCharLocation: …
type: Literal["char_location"]
class BetaCitationPageLocation: …
type: Literal["page_location"]
class BetaCitationContentBlockLocation: …
type: Literal["content_block_location"]
class BetaCitationsWebSearchResultLocation: …
type: Literal["web_search_result_location"]
class BetaCitationSearchResultLocation: …
type: Literal["search_result_location"]
type: Literal["text"]
class BetaThinkingBlock: …
type: Literal["thinking"]
class BetaRedactedThinkingBlock: …
type: Literal["redacted_thinking"]
class BetaToolUseBlock: …
type: Literal["tool_use"]
class BetaServerToolUseBlock: …
name: Literal["web_search", "web_fetch", "code_execution", 2 more]
type: Literal["server_tool_use"]
class BetaWebSearchToolResultBlock: …
class BetaWebSearchToolResultError: …
type: Literal["web_search_tool_result_error"]
type: Literal["web_search_result"]
type: Literal["web_search_tool_result"]
class BetaWebFetchToolResultBlock: …
content: Content
class BetaWebFetchToolResultErrorBlock: …
type: Literal["web_fetch_tool_result_error"]
class BetaWebFetchBlock: …
citations: Optional[BetaCitationConfig]Citation configuration for the document
Citation configuration for the document
source: Source
class BetaBase64PDFSource: …
media_type: Literal["application/pdf"]
type: Literal["base64"]
class BetaPlainTextSource: …
media_type: Literal["text/plain"]
type: Literal["text"]
The title of the document
type: Literal["document"]
ISO 8601 timestamp when the content was retrieved
type: Literal["web_fetch_result"]
Fetched content URL
type: Literal["web_fetch_tool_result"]
class BetaCodeExecutionToolResultBlock: …
class BetaCodeExecutionToolResultError: …
type: Literal["code_execution_tool_result_error"]
class BetaCodeExecutionResultBlock: …
type: Literal["code_execution_output"]
type: Literal["code_execution_result"]
type: Literal["code_execution_tool_result"]
class BetaBashCodeExecutionToolResultBlock: …
content: Content
class BetaBashCodeExecutionToolResultError: …
error_code: Literal["invalid_tool_input", "unavailable", "too_many_requests", 2 more]
type: Literal["bash_code_execution_tool_result_error"]
class BetaBashCodeExecutionResultBlock: …
type: Literal["bash_code_execution_output"]
type: Literal["bash_code_execution_result"]
type: Literal["bash_code_execution_tool_result"]
class BetaTextEditorCodeExecutionToolResultBlock: …
content: Content
class BetaTextEditorCodeExecutionToolResultError: …
error_code: Literal["invalid_tool_input", "unavailable", "too_many_requests", 2 more]
type: Literal["text_editor_code_execution_tool_result_error"]
class BetaTextEditorCodeExecutionViewResultBlock: …
file_type: Literal["text", "image", "pdf"]
type: Literal["text_editor_code_execution_view_result"]
class BetaTextEditorCodeExecutionCreateResultBlock: …
type: Literal["text_editor_code_execution_create_result"]
class BetaTextEditorCodeExecutionStrReplaceResultBlock: …
type: Literal["text_editor_code_execution_str_replace_result"]
type: Literal["text_editor_code_execution_tool_result"]
class BetaMCPToolUseBlock: …
The name of the MCP tool
The name of the MCP server
type: Literal["mcp_tool_use"]
class BetaMCPToolResultBlock: …
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.
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.
class BetaCitationCharLocation: …
type: Literal["char_location"]
class BetaCitationPageLocation: …
type: Literal["page_location"]
class BetaCitationContentBlockLocation: …
type: Literal["content_block_location"]
class BetaCitationsWebSearchResultLocation: …
type: Literal["web_search_result_location"]
class BetaCitationSearchResultLocation: …
type: Literal["search_result_location"]
type: Literal["text"]
type: Literal["mcp_tool_result"]
class BetaContainerUploadBlock: …Response model for a file uploaded to the container.
Response model for a file uploaded to the container.
type: Literal["container_upload"]
context_management: Optional[BetaContextManagementResponse]Context management response.
Information about context management strategies applied during the request.
Context management response.
Information about context management strategies applied during the request.
applied_edits: List[AppliedEdit]List of context management edits that were applied.
List of context management edits that were applied.
class BetaClearToolUses20250919EditResponse: …
Number of input tokens cleared by this edit.
Number of tool uses that were cleared.
type: Literal["clear_tool_uses_20250919"]The type of context management edit applied.
The type of context management edit applied.
class BetaClearThinking20251015EditResponse: …
Number of input tokens cleared by this edit.
Number of thinking turns that were cleared.
type: Literal["clear_thinking_20251015"]The type of context management edit applied.
The type of context management edit applied.
UnionMember0 = Literal["claude-3-7-sonnet-latest", "claude-3-7-sonnet-20250219", "claude-3-5-haiku-latest", 15 more]The model that will complete your prompt.
See models for additional details and options.
claude-3-7-sonnet-latest - Deprecated: Will reach end-of-life on February 19th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
claude-3-7-sonnet-20250219 - Deprecated: Will reach end-of-life on February 19th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
claude-3-5-haiku-latest - Fastest and most compact model for near-instant responsiveness
claude-3-5-haiku-20241022 - Our fastest model
claude-haiku-4-5 - Hybrid model, capable of near-instant responses and extended thinking
claude-haiku-4-5-20251001 - Hybrid model, capable of near-instant responses and extended thinking
claude-sonnet-4-20250514 - High-performance model with extended thinking
claude-sonnet-4-0 - High-performance model with extended thinking
claude-4-sonnet-20250514 - High-performance model with extended thinking
claude-sonnet-4-5 - Our best model for real-world agents and coding
claude-sonnet-4-5-20250929 - Our best model for real-world agents and coding
claude-opus-4-0 - Our most capable model
claude-opus-4-20250514 - Our most capable model
claude-4-opus-20250514 - Our most capable model
claude-opus-4-1-20250805 - Our most capable model
claude-3-opus-latest - Deprecated: Will reach end-of-life on January 5th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
claude-3-opus-20240229 - Deprecated: Will reach end-of-life on January 5th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
claude-3-haiku-20240307 - Our previous most fast and cost-effective
The model that will complete your prompt.
See models for additional details and options.
claude-3-7-sonnet-latest- Deprecated: Will reach end-of-life on February 19th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.claude-3-7-sonnet-20250219- Deprecated: Will reach end-of-life on February 19th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.claude-3-5-haiku-latest- Fastest and most compact model for near-instant responsivenessclaude-3-5-haiku-20241022- Our fastest modelclaude-haiku-4-5- Hybrid model, capable of near-instant responses and extended thinkingclaude-haiku-4-5-20251001- Hybrid model, capable of near-instant responses and extended thinkingclaude-sonnet-4-20250514- High-performance model with extended thinkingclaude-sonnet-4-0- High-performance model with extended thinkingclaude-4-sonnet-20250514- High-performance model with extended thinkingclaude-sonnet-4-5- Our best model for real-world agents and codingclaude-sonnet-4-5-20250929- Our best model for real-world agents and codingclaude-opus-4-0- Our most capable modelclaude-opus-4-20250514- Our most capable modelclaude-4-opus-20250514- Our most capable modelclaude-opus-4-1-20250805- Our most capable modelclaude-3-opus-latest- Deprecated: Will reach end-of-life on January 5th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.claude-3-opus-20240229- Deprecated: Will reach end-of-life on January 5th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.claude-3-haiku-20240307- Our previous most fast and cost-effective
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: Literal["assistant"]Conversational role of the generated message.
This will always be "assistant".
Conversational role of the generated message.
This will always be "assistant".
stop_reason: Optional[BetaStopReason]The reason that we stopped.
This may be one the following values:
"end_turn": the model reached a natural stopping point
"max_tokens": we exceeded the requested max_tokens or the model's maximum
"stop_sequence": one of your provided custom stop_sequences was generated
"tool_use": the model invoked one or more tools
"pause_turn": we paused a long-running turn. You may provide the response back as-is in a subsequent request to let the model continue.
"refusal": when streaming classifiers intervene to handle potential policy violations
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: Literal["message"]Object type.
For Messages, this is always "message".
Object type.
For Messages, this is always "message".
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.
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.
cache_creation: Optional[BetaCacheCreation]Breakdown 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.
server_tool_use: Optional[BetaServerToolUsage]The number of server tool requests.
The number of server tool requests.
The number of web fetch tool requests.
The number of web search tool requests.
service_tier: Optional[Literal["standard", "priority", "batch"]]If the request used the priority, standard, or batch tier.
If the request used the priority, standard, or batch tier.
class BetaMessageDeltaUsage: …
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.
server_tool_use: Optional[BetaServerToolUsage]The number of server tool requests.
The number of server tool requests.
The number of web fetch tool requests.
The number of web search tool requests.
class BetaMessageParam: …
class BetaTextBlockParam: …
type: Literal["text"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
class BetaCitationCharLocationParam: …
type: Literal["char_location"]
class BetaCitationPageLocationParam: …
type: Literal["page_location"]
class BetaCitationContentBlockLocationParam: …
type: Literal["content_block_location"]
class BetaCitationWebSearchResultLocationParam: …
type: Literal["web_search_result_location"]
class BetaCitationSearchResultLocationParam: …
type: Literal["search_result_location"]
class BetaImageBlockParam: …
source: Source
class BetaBase64ImageSource: …
media_type: Literal["image/jpeg", "image/png", "image/gif", "image/webp"]
type: Literal["base64"]
class BetaURLImageSource: …
type: Literal["url"]
class BetaFileImageSource: …
type: Literal["file"]
type: Literal["image"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
class BetaRequestDocumentBlock: …
source: Source
class BetaBase64PDFSource: …
media_type: Literal["application/pdf"]
type: Literal["base64"]
class BetaPlainTextSource: …
media_type: Literal["text/plain"]
type: Literal["text"]
class BetaContentBlockSource: …
class BetaTextBlockParam: …
type: Literal["text"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
class BetaCitationCharLocationParam: …
type: Literal["char_location"]
class BetaCitationPageLocationParam: …
type: Literal["page_location"]
class BetaCitationContentBlockLocationParam: …
type: Literal["content_block_location"]
class BetaCitationWebSearchResultLocationParam: …
type: Literal["web_search_result_location"]
class BetaCitationSearchResultLocationParam: …
type: Literal["search_result_location"]
class BetaImageBlockParam: …
source: Source
class BetaBase64ImageSource: …
media_type: Literal["image/jpeg", "image/png", "image/gif", "image/webp"]
type: Literal["base64"]
class BetaURLImageSource: …
type: Literal["url"]
class BetaFileImageSource: …
type: Literal["file"]
type: Literal["image"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
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: Literal["content"]
class BetaURLPDFSource: …
type: Literal["url"]
class BetaFileDocumentSource: …
type: Literal["file"]
type: Literal["document"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
citations: Optional[BetaCitationsConfigParam]
class BetaSearchResultBlockParam: …
type: Literal["text"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
class BetaCitationCharLocationParam: …
type: Literal["char_location"]
class BetaCitationPageLocationParam: …
type: Literal["page_location"]
class BetaCitationContentBlockLocationParam: …
type: Literal["content_block_location"]
class BetaCitationWebSearchResultLocationParam: …
type: Literal["web_search_result_location"]
class BetaCitationSearchResultLocationParam: …
type: Literal["search_result_location"]
type: Literal["search_result"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
citations: Optional[BetaCitationsConfigParam]
class BetaThinkingBlockParam: …
type: Literal["thinking"]
class BetaRedactedThinkingBlockParam: …
type: Literal["redacted_thinking"]
class BetaToolUseBlockParam: …
type: Literal["tool_use"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
class BetaToolResultBlockParam: …
type: Literal["tool_result"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
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: Optional[Union[str, List[Content], null]]
Content = List[Content]
class BetaTextBlockParam: …
type: Literal["text"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
class BetaCitationCharLocationParam: …
type: Literal["char_location"]
class BetaCitationPageLocationParam: …
type: Literal["page_location"]
class BetaCitationContentBlockLocationParam: …
type: Literal["content_block_location"]
class BetaCitationWebSearchResultLocationParam: …
type: Literal["web_search_result_location"]
class BetaCitationSearchResultLocationParam: …
type: Literal["search_result_location"]
class BetaImageBlockParam: …
source: Source
class BetaBase64ImageSource: …
media_type: Literal["image/jpeg", "image/png", "image/gif", "image/webp"]
type: Literal["base64"]
class BetaURLImageSource: …
type: Literal["url"]
class BetaFileImageSource: …
type: Literal["file"]
type: Literal["image"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
class BetaSearchResultBlockParam: …
type: Literal["text"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
class BetaCitationCharLocationParam: …
type: Literal["char_location"]
class BetaCitationPageLocationParam: …
type: Literal["page_location"]
class BetaCitationContentBlockLocationParam: …
type: Literal["content_block_location"]
class BetaCitationWebSearchResultLocationParam: …
type: Literal["web_search_result_location"]
class BetaCitationSearchResultLocationParam: …
type: Literal["search_result_location"]
type: Literal["search_result"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
citations: Optional[BetaCitationsConfigParam]
class BetaRequestDocumentBlock: …
source: Source
class BetaBase64PDFSource: …
media_type: Literal["application/pdf"]
type: Literal["base64"]
class BetaPlainTextSource: …
media_type: Literal["text/plain"]
type: Literal["text"]
class BetaContentBlockSource: …
class BetaTextBlockParam: …
type: Literal["text"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
class BetaCitationCharLocationParam: …
type: Literal["char_location"]
class BetaCitationPageLocationParam: …
type: Literal["page_location"]
class BetaCitationContentBlockLocationParam: …
type: Literal["content_block_location"]
class BetaCitationWebSearchResultLocationParam: …
type: Literal["web_search_result_location"]
class BetaCitationSearchResultLocationParam: …
type: Literal["search_result_location"]
class BetaImageBlockParam: …
source: Source
class BetaBase64ImageSource: …
media_type: Literal["image/jpeg", "image/png", "image/gif", "image/webp"]
type: Literal["base64"]
class BetaURLImageSource: …
type: Literal["url"]
class BetaFileImageSource: …
type: Literal["file"]
type: Literal["image"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
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: Literal["content"]
class BetaURLPDFSource: …
type: Literal["url"]
class BetaFileDocumentSource: …
type: Literal["file"]
type: Literal["document"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
citations: Optional[BetaCitationsConfigParam]
class BetaServerToolUseBlockParam: …
name: Literal["web_search", "web_fetch", "code_execution", 2 more]
type: Literal["server_tool_use"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
class BetaWebSearchToolResultBlockParam: …
type: Literal["web_search_result"]
class BetaWebSearchToolRequestError: …
type: Literal["web_search_tool_result_error"]
type: Literal["web_search_tool_result"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
class BetaWebFetchToolResultBlockParam: …
content: Content
class BetaWebFetchToolResultErrorBlockParam: …
type: Literal["web_fetch_tool_result_error"]
class BetaWebFetchBlockParam: …
source: Source
class BetaBase64PDFSource: …
media_type: Literal["application/pdf"]
type: Literal["base64"]
class BetaPlainTextSource: …
media_type: Literal["text/plain"]
type: Literal["text"]
class BetaContentBlockSource: …
class BetaTextBlockParam: …
type: Literal["text"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
class BetaCitationCharLocationParam: …
type: Literal["char_location"]
class BetaCitationPageLocationParam: …
type: Literal["page_location"]
class BetaCitationContentBlockLocationParam: …
type: Literal["content_block_location"]
class BetaCitationWebSearchResultLocationParam: …
type: Literal["web_search_result_location"]
class BetaCitationSearchResultLocationParam: …
type: Literal["search_result_location"]
class BetaImageBlockParam: …
source: Source
class BetaBase64ImageSource: …
media_type: Literal["image/jpeg", "image/png", "image/gif", "image/webp"]
type: Literal["base64"]
class BetaURLImageSource: …
type: Literal["url"]
class BetaFileImageSource: …
type: Literal["file"]
type: Literal["image"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
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: Literal["content"]
class BetaURLPDFSource: …
type: Literal["url"]
class BetaFileDocumentSource: …
type: Literal["file"]
type: Literal["document"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
citations: Optional[BetaCitationsConfigParam]
type: Literal["web_fetch_result"]
Fetched content URL
ISO 8601 timestamp when the content was retrieved
type: Literal["web_fetch_tool_result"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
class BetaCodeExecutionToolResultBlockParam: …
class BetaCodeExecutionToolResultErrorParam: …
type: Literal["code_execution_tool_result_error"]
class BetaCodeExecutionResultBlockParam: …
type: Literal["code_execution_output"]
type: Literal["code_execution_result"]
type: Literal["code_execution_tool_result"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
class BetaBashCodeExecutionToolResultBlockParam: …
content: Content
class BetaBashCodeExecutionToolResultErrorParam: …
error_code: Literal["invalid_tool_input", "unavailable", "too_many_requests", 2 more]
type: Literal["bash_code_execution_tool_result_error"]
class BetaBashCodeExecutionResultBlockParam: …
type: Literal["bash_code_execution_output"]
type: Literal["bash_code_execution_result"]
type: Literal["bash_code_execution_tool_result"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
class BetaTextEditorCodeExecutionToolResultBlockParam: …
content: Content
class BetaTextEditorCodeExecutionToolResultErrorParam: …
error_code: Literal["invalid_tool_input", "unavailable", "too_many_requests", 2 more]
type: Literal["text_editor_code_execution_tool_result_error"]
class BetaTextEditorCodeExecutionViewResultBlockParam: …
file_type: Literal["text", "image", "pdf"]
type: Literal["text_editor_code_execution_view_result"]
class BetaTextEditorCodeExecutionCreateResultBlockParam: …
type: Literal["text_editor_code_execution_create_result"]
class BetaTextEditorCodeExecutionStrReplaceResultBlockParam: …
type: Literal["text_editor_code_execution_str_replace_result"]
type: Literal["text_editor_code_execution_tool_result"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
class BetaMCPToolUseBlockParam: …
The name of the MCP server
type: Literal["mcp_tool_use"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
class BetaRequestMCPToolResultBlockParam: …
type: Literal["mcp_tool_result"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
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: Literal["text"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
class BetaCitationCharLocationParam: …
type: Literal["char_location"]
class BetaCitationPageLocationParam: …
type: Literal["page_location"]
class BetaCitationContentBlockLocationParam: …
type: Literal["content_block_location"]
class BetaCitationWebSearchResultLocationParam: …
type: Literal["web_search_result_location"]
class BetaCitationSearchResultLocationParam: …
type: Literal["search_result_location"]
class BetaContainerUploadBlockParam: …A content block that represents a file to be uploaded to the container
Files uploaded via this block will be available in the container's input directory.
A content block that represents a file to be uploaded to the container Files uploaded via this block will be available in the container's input directory.
type: Literal["container_upload"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
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: Literal["user", "assistant"]
class BetaMessageTokensCount: …
context_management: Optional[BetaCountTokensContextManagementResponse]Information about context management applied to the message.
Information about context management applied to the message.
The original token count before context management was applied
The total number of tokens across the provided list of messages, system prompt, and tools.
class BetaMetadata: …
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.
class BetaPlainTextSource: …
media_type: Literal["text/plain"]
type: Literal["text"]
class BetaTextDelta: …
type: Literal["text_delta"]
class BetaInputJSONDelta: …
type: Literal["input_json_delta"]
class BetaCitationsDelta: …
citation: Citation
class BetaCitationCharLocation: …
type: Literal["char_location"]
class BetaCitationPageLocation: …
type: Literal["page_location"]
class BetaCitationContentBlockLocation: …
type: Literal["content_block_location"]
class BetaCitationsWebSearchResultLocation: …
type: Literal["web_search_result_location"]
class BetaCitationSearchResultLocation: …
type: Literal["search_result_location"]
type: Literal["citations_delta"]
class BetaThinkingDelta: …
type: Literal["thinking_delta"]
class BetaSignatureDelta: …
type: Literal["signature_delta"]
class BetaRawContentBlockDeltaEvent: …
class BetaTextDelta: …
type: Literal["text_delta"]
class BetaInputJSONDelta: …
type: Literal["input_json_delta"]
class BetaCitationsDelta: …
citation: Citation
class BetaCitationCharLocation: …
type: Literal["char_location"]
class BetaCitationPageLocation: …
type: Literal["page_location"]
class BetaCitationContentBlockLocation: …
type: Literal["content_block_location"]
class BetaCitationsWebSearchResultLocation: …
type: Literal["web_search_result_location"]
class BetaCitationSearchResultLocation: …
type: Literal["search_result_location"]
type: Literal["citations_delta"]
class BetaThinkingDelta: …
type: Literal["thinking_delta"]
class BetaSignatureDelta: …
type: Literal["signature_delta"]
type: Literal["content_block_delta"]
class BetaRawContentBlockStartEvent: …
content_block: ContentBlockResponse model for a file uploaded to the container.
Response model for a file uploaded to the container.
class BetaTextBlock: …
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.
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.
class BetaCitationCharLocation: …
type: Literal["char_location"]
class BetaCitationPageLocation: …
type: Literal["page_location"]
class BetaCitationContentBlockLocation: …
type: Literal["content_block_location"]
class BetaCitationsWebSearchResultLocation: …
type: Literal["web_search_result_location"]
class BetaCitationSearchResultLocation: …
type: Literal["search_result_location"]
type: Literal["text"]
class BetaThinkingBlock: …
type: Literal["thinking"]
class BetaRedactedThinkingBlock: …
type: Literal["redacted_thinking"]
class BetaToolUseBlock: …
type: Literal["tool_use"]
class BetaServerToolUseBlock: …
name: Literal["web_search", "web_fetch", "code_execution", 2 more]
type: Literal["server_tool_use"]
class BetaWebSearchToolResultBlock: …
class BetaWebSearchToolResultError: …
type: Literal["web_search_tool_result_error"]
type: Literal["web_search_result"]
type: Literal["web_search_tool_result"]
class BetaWebFetchToolResultBlock: …
content: Content
class BetaWebFetchToolResultErrorBlock: …
type: Literal["web_fetch_tool_result_error"]
class BetaWebFetchBlock: …
citations: Optional[BetaCitationConfig]Citation configuration for the document
Citation configuration for the document
source: Source
class BetaBase64PDFSource: …
media_type: Literal["application/pdf"]
type: Literal["base64"]
class BetaPlainTextSource: …
media_type: Literal["text/plain"]
type: Literal["text"]
The title of the document
type: Literal["document"]
ISO 8601 timestamp when the content was retrieved
type: Literal["web_fetch_result"]
Fetched content URL
type: Literal["web_fetch_tool_result"]
class BetaCodeExecutionToolResultBlock: …
class BetaCodeExecutionToolResultError: …
type: Literal["code_execution_tool_result_error"]
class BetaCodeExecutionResultBlock: …
type: Literal["code_execution_output"]
type: Literal["code_execution_result"]
type: Literal["code_execution_tool_result"]
class BetaBashCodeExecutionToolResultBlock: …
content: Content
class BetaBashCodeExecutionToolResultError: …
error_code: Literal["invalid_tool_input", "unavailable", "too_many_requests", 2 more]
type: Literal["bash_code_execution_tool_result_error"]
class BetaBashCodeExecutionResultBlock: …
type: Literal["bash_code_execution_output"]
type: Literal["bash_code_execution_result"]
type: Literal["bash_code_execution_tool_result"]
class BetaTextEditorCodeExecutionToolResultBlock: …
content: Content
class BetaTextEditorCodeExecutionToolResultError: …
error_code: Literal["invalid_tool_input", "unavailable", "too_many_requests", 2 more]
type: Literal["text_editor_code_execution_tool_result_error"]
class BetaTextEditorCodeExecutionViewResultBlock: …
file_type: Literal["text", "image", "pdf"]
type: Literal["text_editor_code_execution_view_result"]
class BetaTextEditorCodeExecutionCreateResultBlock: …
type: Literal["text_editor_code_execution_create_result"]
class BetaTextEditorCodeExecutionStrReplaceResultBlock: …
type: Literal["text_editor_code_execution_str_replace_result"]
type: Literal["text_editor_code_execution_tool_result"]
class BetaMCPToolUseBlock: …
The name of the MCP tool
The name of the MCP server
type: Literal["mcp_tool_use"]
class BetaMCPToolResultBlock: …
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.
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.
class BetaCitationCharLocation: …
type: Literal["char_location"]
class BetaCitationPageLocation: …
type: Literal["page_location"]
class BetaCitationContentBlockLocation: …
type: Literal["content_block_location"]
class BetaCitationsWebSearchResultLocation: …
type: Literal["web_search_result_location"]
class BetaCitationSearchResultLocation: …
type: Literal["search_result_location"]
type: Literal["text"]
type: Literal["mcp_tool_result"]
class BetaContainerUploadBlock: …Response model for a file uploaded to the container.
Response model for a file uploaded to the container.
type: Literal["container_upload"]
type: Literal["content_block_start"]
class BetaRawContentBlockStopEvent: …
type: Literal["content_block_stop"]
class BetaRawMessageDeltaEvent: …
context_management: Optional[BetaContextManagementResponse]Information about context management strategies applied during the request
Information about context management strategies applied during the request
applied_edits: List[AppliedEdit]List of context management edits that were applied.
List of context management edits that were applied.
class BetaClearToolUses20250919EditResponse: …
Number of input tokens cleared by this edit.
Number of tool uses that were cleared.
type: Literal["clear_tool_uses_20250919"]The type of context management edit applied.
The type of context management edit applied.
class BetaClearThinking20251015EditResponse: …
Number of input tokens cleared by this edit.
Number of thinking turns that were cleared.
type: Literal["clear_thinking_20251015"]The type of context management edit applied.
The type of context management edit applied.
delta: Delta
container: Optional[BetaContainer]Information about the container used in the request (for the code execution tool)
Information about the container used in the request (for the code execution tool)
Identifier for the container used in this request
The time at which the container will expire.
Skills loaded in the container
Skills loaded in the container
Skill ID
type: Literal["anthropic", "custom"]Type of skill - either 'anthropic' (built-in) or 'custom' (user-defined)
Type of skill - either 'anthropic' (built-in) or 'custom' (user-defined)
Skill version or 'latest' for most recent version
stop_reason: Optional[BetaStopReason]
type: Literal["message_delta"]
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.
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.
server_tool_use: Optional[BetaServerToolUsage]The number of server tool requests.
The number of server tool requests.
The number of web fetch tool requests.
The number of web search tool requests.
class BetaRawMessageStartEvent: …
Unique object identifier.
The format and length of IDs may change over time.
container: Optional[BetaContainer]Information about the container used in the request (for the code execution tool)
Information about the container used in the request (for the code execution tool)
Identifier for the container used in this request
The time at which the container will expire.
Skills loaded in the container
Skills loaded in the container
Skill ID
type: Literal["anthropic", "custom"]Type of skill - either 'anthropic' (built-in) or 'custom' (user-defined)
Type of skill - either 'anthropic' (built-in) or 'custom' (user-defined)
Skill version or 'latest' for most recent version
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)"}]
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)"}]
class BetaTextBlock: …
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.
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.
class BetaCitationCharLocation: …
type: Literal["char_location"]
class BetaCitationPageLocation: …
type: Literal["page_location"]
class BetaCitationContentBlockLocation: …
type: Literal["content_block_location"]
class BetaCitationsWebSearchResultLocation: …
type: Literal["web_search_result_location"]
class BetaCitationSearchResultLocation: …
type: Literal["search_result_location"]
type: Literal["text"]
class BetaThinkingBlock: …
type: Literal["thinking"]
class BetaRedactedThinkingBlock: …
type: Literal["redacted_thinking"]
class BetaToolUseBlock: …
type: Literal["tool_use"]
class BetaServerToolUseBlock: …
name: Literal["web_search", "web_fetch", "code_execution", 2 more]
type: Literal["server_tool_use"]
class BetaWebSearchToolResultBlock: …
class BetaWebSearchToolResultError: …
type: Literal["web_search_tool_result_error"]
type: Literal["web_search_result"]
type: Literal["web_search_tool_result"]
class BetaWebFetchToolResultBlock: …
content: Content
class BetaWebFetchToolResultErrorBlock: …
type: Literal["web_fetch_tool_result_error"]
class BetaWebFetchBlock: …
citations: Optional[BetaCitationConfig]Citation configuration for the document
Citation configuration for the document
source: Source
class BetaBase64PDFSource: …
media_type: Literal["application/pdf"]
type: Literal["base64"]
class BetaPlainTextSource: …
media_type: Literal["text/plain"]
type: Literal["text"]
The title of the document
type: Literal["document"]
ISO 8601 timestamp when the content was retrieved
type: Literal["web_fetch_result"]
Fetched content URL
type: Literal["web_fetch_tool_result"]
class BetaCodeExecutionToolResultBlock: …
class BetaCodeExecutionToolResultError: …
type: Literal["code_execution_tool_result_error"]
class BetaCodeExecutionResultBlock: …
type: Literal["code_execution_output"]
type: Literal["code_execution_result"]
type: Literal["code_execution_tool_result"]
class BetaBashCodeExecutionToolResultBlock: …
content: Content
class BetaBashCodeExecutionToolResultError: …
error_code: Literal["invalid_tool_input", "unavailable", "too_many_requests", 2 more]
type: Literal["bash_code_execution_tool_result_error"]
class BetaBashCodeExecutionResultBlock: …
type: Literal["bash_code_execution_output"]
type: Literal["bash_code_execution_result"]
type: Literal["bash_code_execution_tool_result"]
class BetaTextEditorCodeExecutionToolResultBlock: …
content: Content
class BetaTextEditorCodeExecutionToolResultError: …
error_code: Literal["invalid_tool_input", "unavailable", "too_many_requests", 2 more]
type: Literal["text_editor_code_execution_tool_result_error"]
class BetaTextEditorCodeExecutionViewResultBlock: …
file_type: Literal["text", "image", "pdf"]
type: Literal["text_editor_code_execution_view_result"]
class BetaTextEditorCodeExecutionCreateResultBlock: …
type: Literal["text_editor_code_execution_create_result"]
class BetaTextEditorCodeExecutionStrReplaceResultBlock: …
type: Literal["text_editor_code_execution_str_replace_result"]
type: Literal["text_editor_code_execution_tool_result"]
class BetaMCPToolUseBlock: …
The name of the MCP tool
The name of the MCP server
type: Literal["mcp_tool_use"]
class BetaMCPToolResultBlock: …
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.
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.
class BetaCitationCharLocation: …
type: Literal["char_location"]
class BetaCitationPageLocation: …
type: Literal["page_location"]
class BetaCitationContentBlockLocation: …
type: Literal["content_block_location"]
class BetaCitationsWebSearchResultLocation: …
type: Literal["web_search_result_location"]
class BetaCitationSearchResultLocation: …
type: Literal["search_result_location"]
type: Literal["text"]
type: Literal["mcp_tool_result"]
class BetaContainerUploadBlock: …Response model for a file uploaded to the container.
Response model for a file uploaded to the container.
type: Literal["container_upload"]
context_management: Optional[BetaContextManagementResponse]Context management response.
Information about context management strategies applied during the request.
Context management response.
Information about context management strategies applied during the request.
applied_edits: List[AppliedEdit]List of context management edits that were applied.
List of context management edits that were applied.
class BetaClearToolUses20250919EditResponse: …
Number of input tokens cleared by this edit.
Number of tool uses that were cleared.
type: Literal["clear_tool_uses_20250919"]The type of context management edit applied.
The type of context management edit applied.
class BetaClearThinking20251015EditResponse: …
Number of input tokens cleared by this edit.
Number of thinking turns that were cleared.
type: Literal["clear_thinking_20251015"]The type of context management edit applied.
The type of context management edit applied.
UnionMember0 = Literal["claude-3-7-sonnet-latest", "claude-3-7-sonnet-20250219", "claude-3-5-haiku-latest", 15 more]The model that will complete your prompt.
See models for additional details and options.
claude-3-7-sonnet-latest - Deprecated: Will reach end-of-life on February 19th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
claude-3-7-sonnet-20250219 - Deprecated: Will reach end-of-life on February 19th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
claude-3-5-haiku-latest - Fastest and most compact model for near-instant responsiveness
claude-3-5-haiku-20241022 - Our fastest model
claude-haiku-4-5 - Hybrid model, capable of near-instant responses and extended thinking
claude-haiku-4-5-20251001 - Hybrid model, capable of near-instant responses and extended thinking
claude-sonnet-4-20250514 - High-performance model with extended thinking
claude-sonnet-4-0 - High-performance model with extended thinking
claude-4-sonnet-20250514 - High-performance model with extended thinking
claude-sonnet-4-5 - Our best model for real-world agents and coding
claude-sonnet-4-5-20250929 - Our best model for real-world agents and coding
claude-opus-4-0 - Our most capable model
claude-opus-4-20250514 - Our most capable model
claude-4-opus-20250514 - Our most capable model
claude-opus-4-1-20250805 - Our most capable model
claude-3-opus-latest - Deprecated: Will reach end-of-life on January 5th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
claude-3-opus-20240229 - Deprecated: Will reach end-of-life on January 5th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
claude-3-haiku-20240307 - Our previous most fast and cost-effective
The model that will complete your prompt.
See models for additional details and options.
claude-3-7-sonnet-latest- Deprecated: Will reach end-of-life on February 19th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.claude-3-7-sonnet-20250219- Deprecated: Will reach end-of-life on February 19th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.claude-3-5-haiku-latest- Fastest and most compact model for near-instant responsivenessclaude-3-5-haiku-20241022- Our fastest modelclaude-haiku-4-5- Hybrid model, capable of near-instant responses and extended thinkingclaude-haiku-4-5-20251001- Hybrid model, capable of near-instant responses and extended thinkingclaude-sonnet-4-20250514- High-performance model with extended thinkingclaude-sonnet-4-0- High-performance model with extended thinkingclaude-4-sonnet-20250514- High-performance model with extended thinkingclaude-sonnet-4-5- Our best model for real-world agents and codingclaude-sonnet-4-5-20250929- Our best model for real-world agents and codingclaude-opus-4-0- Our most capable modelclaude-opus-4-20250514- Our most capable modelclaude-4-opus-20250514- Our most capable modelclaude-opus-4-1-20250805- Our most capable modelclaude-3-opus-latest- Deprecated: Will reach end-of-life on January 5th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.claude-3-opus-20240229- Deprecated: Will reach end-of-life on January 5th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.claude-3-haiku-20240307- Our previous most fast and cost-effective
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: Literal["assistant"]Conversational role of the generated message.
This will always be "assistant".
Conversational role of the generated message.
This will always be "assistant".
stop_reason: Optional[BetaStopReason]The reason that we stopped.
This may be one the following values:
"end_turn": the model reached a natural stopping point
"max_tokens": we exceeded the requested max_tokens or the model's maximum
"stop_sequence": one of your provided custom stop_sequences was generated
"tool_use": the model invoked one or more tools
"pause_turn": we paused a long-running turn. You may provide the response back as-is in a subsequent request to let the model continue.
"refusal": when streaming classifiers intervene to handle potential policy violations
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: Literal["message"]Object type.
For Messages, this is always "message".
Object type.
For Messages, this is always "message".
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.
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.
cache_creation: Optional[BetaCacheCreation]Breakdown 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.
server_tool_use: Optional[BetaServerToolUsage]The number of server tool requests.
The number of server tool requests.
The number of web fetch tool requests.
The number of web search tool requests.
service_tier: Optional[Literal["standard", "priority", "batch"]]If the request used the priority, standard, or batch tier.
If the request used the priority, standard, or batch tier.
type: Literal["message_start"]
class BetaRawMessageStopEvent: …
type: Literal["message_stop"]
class BetaRawMessageStartEvent: …
Unique object identifier.
The format and length of IDs may change over time.
container: Optional[BetaContainer]Information about the container used in the request (for the code execution tool)
Information about the container used in the request (for the code execution tool)
Identifier for the container used in this request
The time at which the container will expire.
Skills loaded in the container
Skills loaded in the container
Skill ID
type: Literal["anthropic", "custom"]Type of skill - either 'anthropic' (built-in) or 'custom' (user-defined)
Type of skill - either 'anthropic' (built-in) or 'custom' (user-defined)
Skill version or 'latest' for most recent version
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)"}]
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)"}]
class BetaTextBlock: …
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.
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.
class BetaCitationCharLocation: …
type: Literal["char_location"]
class BetaCitationPageLocation: …
type: Literal["page_location"]
class BetaCitationContentBlockLocation: …
type: Literal["content_block_location"]
class BetaCitationsWebSearchResultLocation: …
type: Literal["web_search_result_location"]
class BetaCitationSearchResultLocation: …
type: Literal["search_result_location"]
type: Literal["text"]
class BetaThinkingBlock: …
type: Literal["thinking"]
class BetaRedactedThinkingBlock: …
type: Literal["redacted_thinking"]
class BetaToolUseBlock: …
type: Literal["tool_use"]
class BetaServerToolUseBlock: …
name: Literal["web_search", "web_fetch", "code_execution", 2 more]
type: Literal["server_tool_use"]
class BetaWebSearchToolResultBlock: …
class BetaWebSearchToolResultError: …
type: Literal["web_search_tool_result_error"]
type: Literal["web_search_result"]
type: Literal["web_search_tool_result"]
class BetaWebFetchToolResultBlock: …
content: Content
class BetaWebFetchToolResultErrorBlock: …
type: Literal["web_fetch_tool_result_error"]
class BetaWebFetchBlock: …
citations: Optional[BetaCitationConfig]Citation configuration for the document
Citation configuration for the document
source: Source
class BetaBase64PDFSource: …
media_type: Literal["application/pdf"]
type: Literal["base64"]
class BetaPlainTextSource: …
media_type: Literal["text/plain"]
type: Literal["text"]
The title of the document
type: Literal["document"]
ISO 8601 timestamp when the content was retrieved
type: Literal["web_fetch_result"]
Fetched content URL
type: Literal["web_fetch_tool_result"]
class BetaCodeExecutionToolResultBlock: …
class BetaCodeExecutionToolResultError: …
type: Literal["code_execution_tool_result_error"]
class BetaCodeExecutionResultBlock: …
type: Literal["code_execution_output"]
type: Literal["code_execution_result"]
type: Literal["code_execution_tool_result"]
class BetaBashCodeExecutionToolResultBlock: …
content: Content
class BetaBashCodeExecutionToolResultError: …
error_code: Literal["invalid_tool_input", "unavailable", "too_many_requests", 2 more]
type: Literal["bash_code_execution_tool_result_error"]
class BetaBashCodeExecutionResultBlock: …
type: Literal["bash_code_execution_output"]
type: Literal["bash_code_execution_result"]
type: Literal["bash_code_execution_tool_result"]
class BetaTextEditorCodeExecutionToolResultBlock: …
content: Content
class BetaTextEditorCodeExecutionToolResultError: …
error_code: Literal["invalid_tool_input", "unavailable", "too_many_requests", 2 more]
type: Literal["text_editor_code_execution_tool_result_error"]
class BetaTextEditorCodeExecutionViewResultBlock: …
file_type: Literal["text", "image", "pdf"]
type: Literal["text_editor_code_execution_view_result"]
class BetaTextEditorCodeExecutionCreateResultBlock: …
type: Literal["text_editor_code_execution_create_result"]
class BetaTextEditorCodeExecutionStrReplaceResultBlock: …
type: Literal["text_editor_code_execution_str_replace_result"]
type: Literal["text_editor_code_execution_tool_result"]
class BetaMCPToolUseBlock: …
The name of the MCP tool
The name of the MCP server
type: Literal["mcp_tool_use"]
class BetaMCPToolResultBlock: …
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.
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.
class BetaCitationCharLocation: …
type: Literal["char_location"]
class BetaCitationPageLocation: …
type: Literal["page_location"]
class BetaCitationContentBlockLocation: …
type: Literal["content_block_location"]
class BetaCitationsWebSearchResultLocation: …
type: Literal["web_search_result_location"]
class BetaCitationSearchResultLocation: …
type: Literal["search_result_location"]
type: Literal["text"]
type: Literal["mcp_tool_result"]
class BetaContainerUploadBlock: …Response model for a file uploaded to the container.
Response model for a file uploaded to the container.
type: Literal["container_upload"]
context_management: Optional[BetaContextManagementResponse]Context management response.
Information about context management strategies applied during the request.
Context management response.
Information about context management strategies applied during the request.
applied_edits: List[AppliedEdit]List of context management edits that were applied.
List of context management edits that were applied.
class BetaClearToolUses20250919EditResponse: …
Number of input tokens cleared by this edit.
Number of tool uses that were cleared.
type: Literal["clear_tool_uses_20250919"]The type of context management edit applied.
The type of context management edit applied.
class BetaClearThinking20251015EditResponse: …
Number of input tokens cleared by this edit.
Number of thinking turns that were cleared.
type: Literal["clear_thinking_20251015"]The type of context management edit applied.
The type of context management edit applied.
UnionMember0 = Literal["claude-3-7-sonnet-latest", "claude-3-7-sonnet-20250219", "claude-3-5-haiku-latest", 15 more]The model that will complete your prompt.
See models for additional details and options.
claude-3-7-sonnet-latest - Deprecated: Will reach end-of-life on February 19th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
claude-3-7-sonnet-20250219 - Deprecated: Will reach end-of-life on February 19th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
claude-3-5-haiku-latest - Fastest and most compact model for near-instant responsiveness
claude-3-5-haiku-20241022 - Our fastest model
claude-haiku-4-5 - Hybrid model, capable of near-instant responses and extended thinking
claude-haiku-4-5-20251001 - Hybrid model, capable of near-instant responses and extended thinking
claude-sonnet-4-20250514 - High-performance model with extended thinking
claude-sonnet-4-0 - High-performance model with extended thinking
claude-4-sonnet-20250514 - High-performance model with extended thinking
claude-sonnet-4-5 - Our best model for real-world agents and coding
claude-sonnet-4-5-20250929 - Our best model for real-world agents and coding
claude-opus-4-0 - Our most capable model
claude-opus-4-20250514 - Our most capable model
claude-4-opus-20250514 - Our most capable model
claude-opus-4-1-20250805 - Our most capable model
claude-3-opus-latest - Deprecated: Will reach end-of-life on January 5th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
claude-3-opus-20240229 - Deprecated: Will reach end-of-life on January 5th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
claude-3-haiku-20240307 - Our previous most fast and cost-effective
The model that will complete your prompt.
See models for additional details and options.
claude-3-7-sonnet-latest- Deprecated: Will reach end-of-life on February 19th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.claude-3-7-sonnet-20250219- Deprecated: Will reach end-of-life on February 19th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.claude-3-5-haiku-latest- Fastest and most compact model for near-instant responsivenessclaude-3-5-haiku-20241022- Our fastest modelclaude-haiku-4-5- Hybrid model, capable of near-instant responses and extended thinkingclaude-haiku-4-5-20251001- Hybrid model, capable of near-instant responses and extended thinkingclaude-sonnet-4-20250514- High-performance model with extended thinkingclaude-sonnet-4-0- High-performance model with extended thinkingclaude-4-sonnet-20250514- High-performance model with extended thinkingclaude-sonnet-4-5- Our best model for real-world agents and codingclaude-sonnet-4-5-20250929- Our best model for real-world agents and codingclaude-opus-4-0- Our most capable modelclaude-opus-4-20250514- Our most capable modelclaude-4-opus-20250514- Our most capable modelclaude-opus-4-1-20250805- Our most capable modelclaude-3-opus-latest- Deprecated: Will reach end-of-life on January 5th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.claude-3-opus-20240229- Deprecated: Will reach end-of-life on January 5th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.claude-3-haiku-20240307- Our previous most fast and cost-effective
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: Literal["assistant"]Conversational role of the generated message.
This will always be "assistant".
Conversational role of the generated message.
This will always be "assistant".
stop_reason: Optional[BetaStopReason]The reason that we stopped.
This may be one the following values:
"end_turn": the model reached a natural stopping point
"max_tokens": we exceeded the requested max_tokens or the model's maximum
"stop_sequence": one of your provided custom stop_sequences was generated
"tool_use": the model invoked one or more tools
"pause_turn": we paused a long-running turn. You may provide the response back as-is in a subsequent request to let the model continue.
"refusal": when streaming classifiers intervene to handle potential policy violations
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: Literal["message"]Object type.
For Messages, this is always "message".
Object type.
For Messages, this is always "message".
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.
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.
cache_creation: Optional[BetaCacheCreation]Breakdown 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.
server_tool_use: Optional[BetaServerToolUsage]The number of server tool requests.
The number of server tool requests.
The number of web fetch tool requests.
The number of web search tool requests.
service_tier: Optional[Literal["standard", "priority", "batch"]]If the request used the priority, standard, or batch tier.
If the request used the priority, standard, or batch tier.
type: Literal["message_start"]
class BetaRawMessageDeltaEvent: …
context_management: Optional[BetaContextManagementResponse]Information about context management strategies applied during the request
Information about context management strategies applied during the request
applied_edits: List[AppliedEdit]List of context management edits that were applied.
List of context management edits that were applied.
class BetaClearToolUses20250919EditResponse: …
Number of input tokens cleared by this edit.
Number of tool uses that were cleared.
type: Literal["clear_tool_uses_20250919"]The type of context management edit applied.
The type of context management edit applied.
class BetaClearThinking20251015EditResponse: …
Number of input tokens cleared by this edit.
Number of thinking turns that were cleared.
type: Literal["clear_thinking_20251015"]The type of context management edit applied.
The type of context management edit applied.
delta: Delta
container: Optional[BetaContainer]Information about the container used in the request (for the code execution tool)
Information about the container used in the request (for the code execution tool)
Identifier for the container used in this request
The time at which the container will expire.
Skills loaded in the container
Skills loaded in the container
Skill ID
type: Literal["anthropic", "custom"]Type of skill - either 'anthropic' (built-in) or 'custom' (user-defined)
Type of skill - either 'anthropic' (built-in) or 'custom' (user-defined)
Skill version or 'latest' for most recent version
stop_reason: Optional[BetaStopReason]
type: Literal["message_delta"]
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.
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.
server_tool_use: Optional[BetaServerToolUsage]The number of server tool requests.
The number of server tool requests.
The number of web fetch tool requests.
The number of web search tool requests.
class BetaRawMessageStopEvent: …
type: Literal["message_stop"]
class BetaRawContentBlockStartEvent: …
content_block: ContentBlockResponse model for a file uploaded to the container.
Response model for a file uploaded to the container.
class BetaTextBlock: …
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.
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.
class BetaCitationCharLocation: …
type: Literal["char_location"]
class BetaCitationPageLocation: …
type: Literal["page_location"]
class BetaCitationContentBlockLocation: …
type: Literal["content_block_location"]
class BetaCitationsWebSearchResultLocation: …
type: Literal["web_search_result_location"]
class BetaCitationSearchResultLocation: …
type: Literal["search_result_location"]
type: Literal["text"]
class BetaThinkingBlock: …
type: Literal["thinking"]
class BetaRedactedThinkingBlock: …
type: Literal["redacted_thinking"]
class BetaToolUseBlock: …
type: Literal["tool_use"]
class BetaServerToolUseBlock: …
name: Literal["web_search", "web_fetch", "code_execution", 2 more]
type: Literal["server_tool_use"]
class BetaWebSearchToolResultBlock: …
class BetaWebSearchToolResultError: …
type: Literal["web_search_tool_result_error"]
type: Literal["web_search_result"]
type: Literal["web_search_tool_result"]
class BetaWebFetchToolResultBlock: …
content: Content
class BetaWebFetchToolResultErrorBlock: …
type: Literal["web_fetch_tool_result_error"]
class BetaWebFetchBlock: …
citations: Optional[BetaCitationConfig]Citation configuration for the document
Citation configuration for the document
source: Source
class BetaBase64PDFSource: …
media_type: Literal["application/pdf"]
type: Literal["base64"]
class BetaPlainTextSource: …
media_type: Literal["text/plain"]
type: Literal["text"]
The title of the document
type: Literal["document"]
ISO 8601 timestamp when the content was retrieved
type: Literal["web_fetch_result"]
Fetched content URL
type: Literal["web_fetch_tool_result"]
class BetaCodeExecutionToolResultBlock: …
class BetaCodeExecutionToolResultError: …
type: Literal["code_execution_tool_result_error"]
class BetaCodeExecutionResultBlock: …
type: Literal["code_execution_output"]
type: Literal["code_execution_result"]
type: Literal["code_execution_tool_result"]
class BetaBashCodeExecutionToolResultBlock: …
content: Content
class BetaBashCodeExecutionToolResultError: …
error_code: Literal["invalid_tool_input", "unavailable", "too_many_requests", 2 more]
type: Literal["bash_code_execution_tool_result_error"]
class BetaBashCodeExecutionResultBlock: …
type: Literal["bash_code_execution_output"]
type: Literal["bash_code_execution_result"]
type: Literal["bash_code_execution_tool_result"]
class BetaTextEditorCodeExecutionToolResultBlock: …
content: Content
class BetaTextEditorCodeExecutionToolResultError: …
error_code: Literal["invalid_tool_input", "unavailable", "too_many_requests", 2 more]
type: Literal["text_editor_code_execution_tool_result_error"]
class BetaTextEditorCodeExecutionViewResultBlock: …
file_type: Literal["text", "image", "pdf"]
type: Literal["text_editor_code_execution_view_result"]
class BetaTextEditorCodeExecutionCreateResultBlock: …
type: Literal["text_editor_code_execution_create_result"]
class BetaTextEditorCodeExecutionStrReplaceResultBlock: …
type: Literal["text_editor_code_execution_str_replace_result"]
type: Literal["text_editor_code_execution_tool_result"]
class BetaMCPToolUseBlock: …
The name of the MCP tool
The name of the MCP server
type: Literal["mcp_tool_use"]
class BetaMCPToolResultBlock: …
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.
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.
class BetaCitationCharLocation: …
type: Literal["char_location"]
class BetaCitationPageLocation: …
type: Literal["page_location"]
class BetaCitationContentBlockLocation: …
type: Literal["content_block_location"]
class BetaCitationsWebSearchResultLocation: …
type: Literal["web_search_result_location"]
class BetaCitationSearchResultLocation: …
type: Literal["search_result_location"]
type: Literal["text"]
type: Literal["mcp_tool_result"]
class BetaContainerUploadBlock: …Response model for a file uploaded to the container.
Response model for a file uploaded to the container.
type: Literal["container_upload"]
type: Literal["content_block_start"]
class BetaRawContentBlockDeltaEvent: …
class BetaTextDelta: …
type: Literal["text_delta"]
class BetaInputJSONDelta: …
type: Literal["input_json_delta"]
class BetaCitationsDelta: …
citation: Citation
class BetaCitationCharLocation: …
type: Literal["char_location"]
class BetaCitationPageLocation: …
type: Literal["page_location"]
class BetaCitationContentBlockLocation: …
type: Literal["content_block_location"]
class BetaCitationsWebSearchResultLocation: …
type: Literal["web_search_result_location"]
class BetaCitationSearchResultLocation: …
type: Literal["search_result_location"]
type: Literal["citations_delta"]
class BetaThinkingDelta: …
type: Literal["thinking_delta"]
class BetaSignatureDelta: …
type: Literal["signature_delta"]
type: Literal["content_block_delta"]
class BetaRawContentBlockStopEvent: …
type: Literal["content_block_stop"]
class BetaRedactedThinkingBlock: …
type: Literal["redacted_thinking"]
class BetaRedactedThinkingBlockParam: …
type: Literal["redacted_thinking"]
class BetaRequestDocumentBlock: …
source: Source
class BetaBase64PDFSource: …
media_type: Literal["application/pdf"]
type: Literal["base64"]
class BetaPlainTextSource: …
media_type: Literal["text/plain"]
type: Literal["text"]
class BetaContentBlockSource: …
class BetaTextBlockParam: …
type: Literal["text"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
class BetaCitationCharLocationParam: …
type: Literal["char_location"]
class BetaCitationPageLocationParam: …
type: Literal["page_location"]
class BetaCitationContentBlockLocationParam: …
type: Literal["content_block_location"]
class BetaCitationWebSearchResultLocationParam: …
type: Literal["web_search_result_location"]
class BetaCitationSearchResultLocationParam: …
type: Literal["search_result_location"]
class BetaImageBlockParam: …
source: Source
class BetaBase64ImageSource: …
media_type: Literal["image/jpeg", "image/png", "image/gif", "image/webp"]
type: Literal["base64"]
class BetaURLImageSource: …
type: Literal["url"]
class BetaFileImageSource: …
type: Literal["file"]
type: Literal["image"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
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: Literal["content"]
class BetaURLPDFSource: …
type: Literal["url"]
class BetaFileDocumentSource: …
type: Literal["file"]
type: Literal["document"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
citations: Optional[BetaCitationsConfigParam]
class BetaRequestMCPServerToolConfiguration: …
class BetaRequestMCPServerURLDefinition: …
type: Literal["url"]
tool_configuration: Optional[BetaRequestMCPServerToolConfiguration]
class BetaRequestMCPToolResultBlockParam: …
type: Literal["mcp_tool_result"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
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: Literal["text"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
class BetaCitationCharLocationParam: …
type: Literal["char_location"]
class BetaCitationPageLocationParam: …
type: Literal["page_location"]
class BetaCitationContentBlockLocationParam: …
type: Literal["content_block_location"]
class BetaCitationWebSearchResultLocationParam: …
type: Literal["web_search_result_location"]
class BetaCitationSearchResultLocationParam: …
type: Literal["search_result_location"]
class BetaSearchResultBlockParam: …
type: Literal["text"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
class BetaCitationCharLocationParam: …
type: Literal["char_location"]
class BetaCitationPageLocationParam: …
type: Literal["page_location"]
class BetaCitationContentBlockLocationParam: …
type: Literal["content_block_location"]
class BetaCitationWebSearchResultLocationParam: …
type: Literal["web_search_result_location"]
class BetaCitationSearchResultLocationParam: …
type: Literal["search_result_location"]
type: Literal["search_result"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
citations: Optional[BetaCitationsConfigParam]
class BetaServerToolUsage: …
The number of web fetch tool requests.
The number of web search tool requests.
class BetaServerToolUseBlock: …
name: Literal["web_search", "web_fetch", "code_execution", 2 more]
type: Literal["server_tool_use"]
class BetaServerToolUseBlockParam: …
name: Literal["web_search", "web_fetch", "code_execution", 2 more]
type: Literal["server_tool_use"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
class BetaSignatureDelta: …
type: Literal["signature_delta"]
class BetaSkill: …A skill that was loaded in a container (response model).
A skill that was loaded in a container (response model).
Skill ID
type: Literal["anthropic", "custom"]Type of skill - either 'anthropic' (built-in) or 'custom' (user-defined)
Type of skill - either 'anthropic' (built-in) or 'custom' (user-defined)
Skill version or 'latest' for most recent version
class BetaSkillParams: …Specification for a skill to be loaded in a container (request model).
Specification for a skill to be loaded in a container (request model).
Skill ID
type: Literal["anthropic", "custom"]Type of skill - either 'anthropic' (built-in) or 'custom' (user-defined)
Type of skill - either 'anthropic' (built-in) or 'custom' (user-defined)
Skill version or 'latest' for most recent version
BetaStopReason = Literal["end_turn", "max_tokens", "stop_sequence", 4 more]
class BetaTextBlock: …
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.
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.
class BetaCitationCharLocation: …
type: Literal["char_location"]
class BetaCitationPageLocation: …
type: Literal["page_location"]
class BetaCitationContentBlockLocation: …
type: Literal["content_block_location"]
class BetaCitationsWebSearchResultLocation: …
type: Literal["web_search_result_location"]
class BetaCitationSearchResultLocation: …
type: Literal["search_result_location"]
type: Literal["text"]
class BetaTextBlockParam: …
type: Literal["text"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
class BetaCitationCharLocationParam: …
type: Literal["char_location"]
class BetaCitationPageLocationParam: …
type: Literal["page_location"]
class BetaCitationContentBlockLocationParam: …
type: Literal["content_block_location"]
class BetaCitationWebSearchResultLocationParam: …
type: Literal["web_search_result_location"]
class BetaCitationSearchResultLocationParam: …
type: Literal["search_result_location"]
class BetaCitationCharLocation: …
type: Literal["char_location"]
class BetaCitationPageLocation: …
type: Literal["page_location"]
class BetaCitationContentBlockLocation: …
type: Literal["content_block_location"]
class BetaCitationsWebSearchResultLocation: …
type: Literal["web_search_result_location"]
class BetaCitationSearchResultLocation: …
type: Literal["search_result_location"]
class BetaCitationCharLocationParam: …
type: Literal["char_location"]
class BetaCitationPageLocationParam: …
type: Literal["page_location"]
class BetaCitationContentBlockLocationParam: …
type: Literal["content_block_location"]
class BetaCitationWebSearchResultLocationParam: …
type: Literal["web_search_result_location"]
class BetaCitationSearchResultLocationParam: …
type: Literal["search_result_location"]
class BetaTextDelta: …
type: Literal["text_delta"]
class BetaTextEditorCodeExecutionCreateResultBlock: …
type: Literal["text_editor_code_execution_create_result"]
class BetaTextEditorCodeExecutionCreateResultBlockParam: …
type: Literal["text_editor_code_execution_create_result"]
class BetaTextEditorCodeExecutionStrReplaceResultBlock: …
type: Literal["text_editor_code_execution_str_replace_result"]
class BetaTextEditorCodeExecutionStrReplaceResultBlockParam: …
type: Literal["text_editor_code_execution_str_replace_result"]
class BetaTextEditorCodeExecutionToolResultBlock: …
content: Content
class BetaTextEditorCodeExecutionToolResultError: …
error_code: Literal["invalid_tool_input", "unavailable", "too_many_requests", 2 more]
type: Literal["text_editor_code_execution_tool_result_error"]
class BetaTextEditorCodeExecutionViewResultBlock: …
file_type: Literal["text", "image", "pdf"]
type: Literal["text_editor_code_execution_view_result"]
class BetaTextEditorCodeExecutionCreateResultBlock: …
type: Literal["text_editor_code_execution_create_result"]
class BetaTextEditorCodeExecutionStrReplaceResultBlock: …
type: Literal["text_editor_code_execution_str_replace_result"]
type: Literal["text_editor_code_execution_tool_result"]
class BetaTextEditorCodeExecutionToolResultBlockParam: …
content: Content
class BetaTextEditorCodeExecutionToolResultErrorParam: …
error_code: Literal["invalid_tool_input", "unavailable", "too_many_requests", 2 more]
type: Literal["text_editor_code_execution_tool_result_error"]
class BetaTextEditorCodeExecutionViewResultBlockParam: …
file_type: Literal["text", "image", "pdf"]
type: Literal["text_editor_code_execution_view_result"]
class BetaTextEditorCodeExecutionCreateResultBlockParam: …
type: Literal["text_editor_code_execution_create_result"]
class BetaTextEditorCodeExecutionStrReplaceResultBlockParam: …
type: Literal["text_editor_code_execution_str_replace_result"]
type: Literal["text_editor_code_execution_tool_result"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
class BetaTextEditorCodeExecutionToolResultError: …
error_code: Literal["invalid_tool_input", "unavailable", "too_many_requests", 2 more]
type: Literal["text_editor_code_execution_tool_result_error"]
class BetaTextEditorCodeExecutionToolResultErrorParam: …
error_code: Literal["invalid_tool_input", "unavailable", "too_many_requests", 2 more]
type: Literal["text_editor_code_execution_tool_result_error"]
class BetaTextEditorCodeExecutionViewResultBlock: …
file_type: Literal["text", "image", "pdf"]
type: Literal["text_editor_code_execution_view_result"]
class BetaTextEditorCodeExecutionViewResultBlockParam: …
file_type: Literal["text", "image", "pdf"]
type: Literal["text_editor_code_execution_view_result"]
class BetaThinkingBlock: …
type: Literal["thinking"]
class BetaThinkingBlockParam: …
type: Literal["thinking"]
class BetaThinkingConfigDisabled: …
type: Literal["disabled"]
class BetaThinkingConfigEnabled: …
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: Literal["enabled"]
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.
class BetaThinkingConfigEnabled: …
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: Literal["enabled"]
class BetaThinkingConfigDisabled: …
type: Literal["disabled"]
class BetaThinkingDelta: …
type: Literal["thinking_delta"]
class BetaThinkingTurns: …
type: Literal["thinking_turns"]
class BetaTool: …
input_schema: InputSchemaJSON 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: Literal["object"]
Name of the tool.
This is how the tool will be called by the model and in tool_use blocks.
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
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: Optional[Literal["custom"]]
class BetaToolBash20241022: …
name: Literal["bash"]Name 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: Literal["bash_20241022"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
class BetaToolBash20250124: …
name: Literal["bash"]Name 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: Literal["bash_20250124"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
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.
class BetaToolChoiceAuto: …The model will automatically decide whether to use tools.
The model will automatically decide whether to use tools.
type: Literal["auto"]
Whether to disable parallel tool use.
Defaults to false. If set to true, the model will output at most one tool use.
class BetaToolChoiceAny: …The model will use any available tools.
The model will use any available tools.
type: Literal["any"]
Whether to disable parallel tool use.
Defaults to false. If set to true, the model will output exactly one tool use.
class BetaToolChoiceTool: …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: Literal["tool"]
Whether to disable parallel tool use.
Defaults to false. If set to true, the model will output exactly one tool use.
class BetaToolChoiceNone: …The model will not be allowed to use tools.
The model will not be allowed to use tools.
type: Literal["none"]
class BetaToolChoiceAny: …The model will use any available tools.
The model will use any available tools.
type: Literal["any"]
Whether to disable parallel tool use.
Defaults to false. If set to true, the model will output exactly one tool use.
class BetaToolChoiceAuto: …The model will automatically decide whether to use tools.
The model will automatically decide whether to use tools.
type: Literal["auto"]
Whether to disable parallel tool use.
Defaults to false. If set to true, the model will output at most one tool use.
class BetaToolChoiceNone: …The model will not be allowed to use tools.
The model will not be allowed to use tools.
type: Literal["none"]
class BetaToolChoiceTool: …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: Literal["tool"]
Whether to disable parallel tool use.
Defaults to false. If set to true, the model will output exactly one tool use.
class BetaToolComputerUse20241022: …
The height of the display in pixels.
The width of the display in pixels.
name: Literal["computer"]Name 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: Literal["computer_20241022"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
The X11 display number (e.g. 0, 1) for the display.
class BetaToolComputerUse20250124: …
The height of the display in pixels.
The width of the display in pixels.
name: Literal["computer"]Name 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: Literal["computer_20250124"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
The X11 display number (e.g. 0, 1) for the display.
class BetaToolResultBlockParam: …
type: Literal["tool_result"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
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: Optional[Union[str, List[Content], null]]
Content = List[Content]
class BetaTextBlockParam: …
type: Literal["text"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
class BetaCitationCharLocationParam: …
type: Literal["char_location"]
class BetaCitationPageLocationParam: …
type: Literal["page_location"]
class BetaCitationContentBlockLocationParam: …
type: Literal["content_block_location"]
class BetaCitationWebSearchResultLocationParam: …
type: Literal["web_search_result_location"]
class BetaCitationSearchResultLocationParam: …
type: Literal["search_result_location"]
class BetaImageBlockParam: …
source: Source
class BetaBase64ImageSource: …
media_type: Literal["image/jpeg", "image/png", "image/gif", "image/webp"]
type: Literal["base64"]
class BetaURLImageSource: …
type: Literal["url"]
class BetaFileImageSource: …
type: Literal["file"]
type: Literal["image"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
class BetaSearchResultBlockParam: …
type: Literal["text"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
class BetaCitationCharLocationParam: …
type: Literal["char_location"]
class BetaCitationPageLocationParam: …
type: Literal["page_location"]
class BetaCitationContentBlockLocationParam: …
type: Literal["content_block_location"]
class BetaCitationWebSearchResultLocationParam: …
type: Literal["web_search_result_location"]
class BetaCitationSearchResultLocationParam: …
type: Literal["search_result_location"]
type: Literal["search_result"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
citations: Optional[BetaCitationsConfigParam]
class BetaRequestDocumentBlock: …
source: Source
class BetaBase64PDFSource: …
media_type: Literal["application/pdf"]
type: Literal["base64"]
class BetaPlainTextSource: …
media_type: Literal["text/plain"]
type: Literal["text"]
class BetaContentBlockSource: …
class BetaTextBlockParam: …
type: Literal["text"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
class BetaCitationCharLocationParam: …
type: Literal["char_location"]
class BetaCitationPageLocationParam: …
type: Literal["page_location"]
class BetaCitationContentBlockLocationParam: …
type: Literal["content_block_location"]
class BetaCitationWebSearchResultLocationParam: …
type: Literal["web_search_result_location"]
class BetaCitationSearchResultLocationParam: …
type: Literal["search_result_location"]
class BetaImageBlockParam: …
source: Source
class BetaBase64ImageSource: …
media_type: Literal["image/jpeg", "image/png", "image/gif", "image/webp"]
type: Literal["base64"]
class BetaURLImageSource: …
type: Literal["url"]
class BetaFileImageSource: …
type: Literal["file"]
type: Literal["image"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
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: Literal["content"]
class BetaURLPDFSource: …
type: Literal["url"]
class BetaFileDocumentSource: …
type: Literal["file"]
type: Literal["document"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
citations: Optional[BetaCitationsConfigParam]
class BetaToolTextEditor20241022: …
name: Literal["str_replace_editor"]Name 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: Literal["text_editor_20241022"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
class BetaToolTextEditor20250124: …
name: Literal["str_replace_editor"]Name 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: Literal["text_editor_20250124"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
class BetaToolTextEditor20250429: …
name: Literal["str_replace_based_edit_tool"]Name 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: Literal["text_editor_20250429"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
class BetaToolTextEditor20250728: …
name: Literal["str_replace_based_edit_tool"]Name 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: Literal["text_editor_20250728"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
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.
class BetaTool: …
input_schema: InputSchemaJSON 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: Literal["object"]
Name of the tool.
This is how the tool will be called by the model and in tool_use blocks.
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
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: Optional[Literal["custom"]]
class BetaToolBash20241022: …
name: Literal["bash"]Name 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: Literal["bash_20241022"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
class BetaToolBash20250124: …
name: Literal["bash"]Name 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: Literal["bash_20250124"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
class BetaCodeExecutionTool20250522: …
name: Literal["code_execution"]Name 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: Literal["code_execution_20250522"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
class BetaCodeExecutionTool20250825: …
name: Literal["code_execution"]Name 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: Literal["code_execution_20250825"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
class BetaToolComputerUse20241022: …
The height of the display in pixels.
The width of the display in pixels.
name: Literal["computer"]Name 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: Literal["computer_20241022"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
The X11 display number (e.g. 0, 1) for the display.
class BetaMemoryTool20250818: …
name: Literal["memory"]Name 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: Literal["memory_20250818"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
class BetaToolComputerUse20250124: …
The height of the display in pixels.
The width of the display in pixels.
name: Literal["computer"]Name 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: Literal["computer_20250124"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
The X11 display number (e.g. 0, 1) for the display.
class BetaToolTextEditor20241022: …
name: Literal["str_replace_editor"]Name 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: Literal["text_editor_20241022"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
class BetaToolTextEditor20250124: …
name: Literal["str_replace_editor"]Name 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: Literal["text_editor_20250124"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
class BetaToolTextEditor20250429: …
name: Literal["str_replace_based_edit_tool"]Name 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: Literal["text_editor_20250429"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
class BetaToolTextEditor20250728: …
name: Literal["str_replace_based_edit_tool"]Name 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: Literal["text_editor_20250728"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
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.
class BetaWebSearchTool20250305: …
name: Literal["web_search"]Name 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: Literal["web_search_20250305"]
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.
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
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.
user_location: Optional[UserLocation]Parameters 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: Literal["approximate"]
The city of the user.
The region of the user.
class BetaWebFetchTool20250910: …
name: Literal["web_fetch"]Name 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: Literal["web_fetch_20250910"]
List of domains to allow fetching from
List of domains to block fetching from
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
citations: Optional[BetaCitationsConfigParam]Citations configuration for fetched documents. Citations are disabled by default.
Citations configuration for fetched documents. Citations are disabled by default.
Maximum number of tokens used by including web page text content in the context. The limit is approximate and does not apply to binary content such as PDFs.
Maximum number of times the tool can be used in the API request.
class BetaToolUseBlock: …
type: Literal["tool_use"]
class BetaToolUseBlockParam: …
type: Literal["tool_use"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
class BetaToolUsesKeep: …
type: Literal["tool_uses"]
class BetaToolUsesTrigger: …
type: Literal["tool_uses"]
class BetaURLImageSource: …
type: Literal["url"]
class BetaURLPDFSource: …
type: Literal["url"]
class BetaUsage: …
cache_creation: Optional[BetaCacheCreation]Breakdown 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.
server_tool_use: Optional[BetaServerToolUsage]The number of server tool requests.
The number of server tool requests.
The number of web fetch tool requests.
The number of web search tool requests.
service_tier: Optional[Literal["standard", "priority", "batch"]]If the request used the priority, standard, or batch tier.
If the request used the priority, standard, or batch tier.
class BetaWebFetchBlock: …
citations: Optional[BetaCitationConfig]Citation configuration for the document
Citation configuration for the document
source: Source
class BetaBase64PDFSource: …
media_type: Literal["application/pdf"]
type: Literal["base64"]
class BetaPlainTextSource: …
media_type: Literal["text/plain"]
type: Literal["text"]
The title of the document
type: Literal["document"]
ISO 8601 timestamp when the content was retrieved
type: Literal["web_fetch_result"]
Fetched content URL
class BetaWebFetchBlockParam: …
source: Source
class BetaBase64PDFSource: …
media_type: Literal["application/pdf"]
type: Literal["base64"]
class BetaPlainTextSource: …
media_type: Literal["text/plain"]
type: Literal["text"]
class BetaContentBlockSource: …
class BetaTextBlockParam: …
type: Literal["text"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
class BetaCitationCharLocationParam: …
type: Literal["char_location"]
class BetaCitationPageLocationParam: …
type: Literal["page_location"]
class BetaCitationContentBlockLocationParam: …
type: Literal["content_block_location"]
class BetaCitationWebSearchResultLocationParam: …
type: Literal["web_search_result_location"]
class BetaCitationSearchResultLocationParam: …
type: Literal["search_result_location"]
class BetaImageBlockParam: …
source: Source
class BetaBase64ImageSource: …
media_type: Literal["image/jpeg", "image/png", "image/gif", "image/webp"]
type: Literal["base64"]
class BetaURLImageSource: …
type: Literal["url"]
class BetaFileImageSource: …
type: Literal["file"]
type: Literal["image"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
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: Literal["content"]
class BetaURLPDFSource: …
type: Literal["url"]
class BetaFileDocumentSource: …
type: Literal["file"]
type: Literal["document"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
citations: Optional[BetaCitationsConfigParam]
type: Literal["web_fetch_result"]
Fetched content URL
ISO 8601 timestamp when the content was retrieved
class BetaWebFetchTool20250910: …
name: Literal["web_fetch"]Name 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: Literal["web_fetch_20250910"]
List of domains to allow fetching from
List of domains to block fetching from
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
citations: Optional[BetaCitationsConfigParam]Citations configuration for fetched documents. Citations are disabled by default.
Citations configuration for fetched documents. Citations are disabled by default.
Maximum number of tokens used by including web page text content in the context. The limit is approximate and does not apply to binary content such as PDFs.
Maximum number of times the tool can be used in the API request.
class BetaWebFetchToolResultBlock: …
content: Content
class BetaWebFetchToolResultErrorBlock: …
type: Literal["web_fetch_tool_result_error"]
class BetaWebFetchBlock: …
citations: Optional[BetaCitationConfig]Citation configuration for the document
Citation configuration for the document
source: Source
class BetaBase64PDFSource: …
media_type: Literal["application/pdf"]
type: Literal["base64"]
class BetaPlainTextSource: …
media_type: Literal["text/plain"]
type: Literal["text"]
The title of the document
type: Literal["document"]
ISO 8601 timestamp when the content was retrieved
type: Literal["web_fetch_result"]
Fetched content URL
type: Literal["web_fetch_tool_result"]
class BetaWebFetchToolResultBlockParam: …
content: Content
class BetaWebFetchToolResultErrorBlockParam: …
type: Literal["web_fetch_tool_result_error"]
class BetaWebFetchBlockParam: …
source: Source
class BetaBase64PDFSource: …
media_type: Literal["application/pdf"]
type: Literal["base64"]
class BetaPlainTextSource: …
media_type: Literal["text/plain"]
type: Literal["text"]
class BetaContentBlockSource: …
class BetaTextBlockParam: …
type: Literal["text"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
class BetaCitationCharLocationParam: …
type: Literal["char_location"]
class BetaCitationPageLocationParam: …
type: Literal["page_location"]
class BetaCitationContentBlockLocationParam: …
type: Literal["content_block_location"]
class BetaCitationWebSearchResultLocationParam: …
type: Literal["web_search_result_location"]
class BetaCitationSearchResultLocationParam: …
type: Literal["search_result_location"]
class BetaImageBlockParam: …
source: Source
class BetaBase64ImageSource: …
media_type: Literal["image/jpeg", "image/png", "image/gif", "image/webp"]
type: Literal["base64"]
class BetaURLImageSource: …
type: Literal["url"]
class BetaFileImageSource: …
type: Literal["file"]
type: Literal["image"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
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: Literal["content"]
class BetaURLPDFSource: …
type: Literal["url"]
class BetaFileDocumentSource: …
type: Literal["file"]
type: Literal["document"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
citations: Optional[BetaCitationsConfigParam]
type: Literal["web_fetch_result"]
Fetched content URL
ISO 8601 timestamp when the content was retrieved
type: Literal["web_fetch_tool_result"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes1h: 1 hour
Defaults to 5m.
class BetaWebFetchToolResultErrorBlock: …
type: Literal["web_fetch_tool_result_error"]
class BetaWebFetchToolResultErrorBlockParam: …
type: Literal["web_fetch_tool_result_error"]
BetaWebFetchToolResultErrorCode = Literal["invalid_tool_input", "url_too_long", "url_not_allowed", 5 more]
class BetaWebSearchResultBlock: …
type: Literal["web_search_result"]
class BetaWebSearchResultBlockParam: …
type: Literal["web_search_result"]
class BetaWebSearchTool20250305: …
name: Literal["web_search"]Name 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: Literal["web_search_20250305"]
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.
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
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.
user_location: Optional[UserLocation]Parameters 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: Literal["approximate"]
The city of the user.
The region of the user.
class BetaWebSearchToolRequestError: …
type: Literal["web_search_tool_result_error"]
class BetaWebSearchToolResultBlock: …
class BetaWebSearchToolResultError: …
type: Literal["web_search_tool_result_error"]
type: Literal["web_search_result"]
type: Literal["web_search_tool_result"]
class BetaWebSearchToolResultError: …
type: Literal["web_search_tool_result_error"]
type: Literal["web_search_result"]
class BetaWebSearchToolResultBlockParam: …
type: Literal["web_search_result"]
class BetaWebSearchToolRequestError: …
type: Literal["web_search_tool_result_error"]
type: Literal["web_search_tool_result"]
cache_control: Optional[BetaCacheControlEphemeral]Create a cache control breakpoint at this content block.
Create a cache control breakpoint at this content block.
type: Literal["ephemeral"]
ttl: Optional[Literal["5m", "1h"]]The time-to-live for the cache control breakpoint.
This may be one the following values:
5m: 5 minutes
1h: 1 hour
Defaults to 5m.
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: Literal["web_search_result"]
class BetaWebSearchToolRequestError: …
type: Literal["web_search_tool_result_error"]
class BetaWebSearchToolResultError: …
type: Literal["web_search_tool_result_error"]
BetaWebSearchToolResultErrorCode = Literal["invalid_tool_input", "unavailable", "max_uses_exceeded", 2 more]
BetaMessagesBatches
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
class BetaDeletedMessageBatch: …
ID of the Message Batch.
type: Literal["message_batch_deleted"]Deleted object type.
For Message Batches, this is always "message_batch_deleted".
Deleted object type.
For Message Batches, this is always "message_batch_deleted".
class BetaMessageBatch: …
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.
processing_status: Literal["in_progress", "canceling", "ended"]Processing status of the Message Batch.
Processing status of the Message 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.
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: Literal["message_batch"]Object type.
For Message Batches, this is always "message_batch".
Object type.
For Message Batches, this is always "message_batch".
class BetaMessageBatchCanceledResult: …
type: Literal["canceled"]
class BetaMessageBatchErroredResult: …
class BetaInvalidRequestError: …
type: Literal["invalid_request_error"]
class BetaAuthenticationError: …
type: Literal["authentication_error"]
class BetaBillingError: …
type: Literal["billing_error"]
class BetaPermissionError: …
type: Literal["permission_error"]
class BetaNotFoundError: …
type: Literal["not_found_error"]
class BetaRateLimitError: …
type: Literal["rate_limit_error"]
class BetaGatewayTimeoutError: …
type: Literal["timeout_error"]
class BetaAPIError: …
type: Literal["api_error"]
class BetaOverloadedError: …
type: Literal["overloaded_error"]
type: Literal["error"]
type: Literal["errored"]
class BetaMessageBatchExpiredResult: …
type: Literal["expired"]
class BetaMessageBatchIndividualResponse: …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.
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.
class BetaMessageBatchSucceededResult: …
Unique object identifier.
The format and length of IDs may change over time.
container: Optional[BetaContainer]Information about the container used in the request (for the code execution tool)
Information about the container used in the request (for the code execution tool)
Identifier for the container used in this request
The time at which the container will expire.
Skills loaded in the container
Skills loaded in the container
Skill ID
type: Literal["anthropic", "custom"]Type of skill - either 'anthropic' (built-in) or 'custom' (user-defined)
Type of skill - either 'anthropic' (built-in) or 'custom' (user-defined)
Skill version or 'latest' for most recent version
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)"}]
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)"}]
class BetaTextBlock: …
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.
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.
class BetaCitationCharLocation: …
type: Literal["char_location"]
class BetaCitationPageLocation: …
type: Literal["page_location"]
class BetaCitationContentBlockLocation: …
type: Literal["content_block_location"]
class BetaCitationsWebSearchResultLocation: …
type: Literal["web_search_result_location"]
class BetaCitationSearchResultLocation: …
type: Literal["search_result_location"]
type: Literal["text"]
class BetaThinkingBlock: …
type: Literal["thinking"]
class BetaRedactedThinkingBlock: …
type: Literal["redacted_thinking"]
class BetaToolUseBlock: …
type: Literal["tool_use"]
class BetaServerToolUseBlock: …
name: Literal["web_search", "web_fetch", "code_execution", 2 more]
type: Literal["server_tool_use"]
class BetaWebSearchToolResultBlock: …
class BetaWebSearchToolResultError: …
type: Literal["web_search_tool_result_error"]
type: Literal["web_search_result"]
type: Literal["web_search_tool_result"]
class BetaWebFetchToolResultBlock: …
content: Content
class BetaWebFetchToolResultErrorBlock: …
type: Literal["web_fetch_tool_result_error"]
class BetaWebFetchBlock: …
citations: Optional[BetaCitationConfig]Citation configuration for the document
Citation configuration for the document
source: Source
class BetaBase64PDFSource: …
media_type: Literal["application/pdf"]
type: Literal["base64"]
class BetaPlainTextSource: …
media_type: Literal["text/plain"]
type: Literal["text"]
The title of the document
type: Literal["document"]
ISO 8601 timestamp when the content was retrieved
type: Literal["web_fetch_result"]
Fetched content URL
type: Literal["web_fetch_tool_result"]
class BetaCodeExecutionToolResultBlock: …
class BetaCodeExecutionToolResultError: …
type: Literal["code_execution_tool_result_error"]
class BetaCodeExecutionResultBlock: …
type: Literal["code_execution_output"]
type: Literal["code_execution_result"]
type: Literal["code_execution_tool_result"]
class BetaBashCodeExecutionToolResultBlock: …
content: Content
class BetaBashCodeExecutionToolResultError: …
error_code: Literal["invalid_tool_input", "unavailable", "too_many_requests", 2 more]
type: Literal["bash_code_execution_tool_result_error"]
class BetaBashCodeExecutionResultBlock: …
type: Literal["bash_code_execution_output"]
type: Literal["bash_code_execution_result"]
type: Literal["bash_code_execution_tool_result"]
class BetaTextEditorCodeExecutionToolResultBlock: …
content: Content
class BetaTextEditorCodeExecutionToolResultError: …
error_code: Literal["invalid_tool_input", "unavailable", "too_many_requests", 2 more]
type: Literal["text_editor_code_execution_tool_result_error"]
class BetaTextEditorCodeExecutionViewResultBlock: …
file_type: Literal["text", "image", "pdf"]
type: Literal["text_editor_code_execution_view_result"]
class BetaTextEditorCodeExecutionCreateResultBlock: …
type: Literal["text_editor_code_execution_create_result"]
class BetaTextEditorCodeExecutionStrReplaceResultBlock: …
type: Literal["text_editor_code_execution_str_replace_result"]
type: Literal["text_editor_code_execution_tool_result"]
class BetaMCPToolUseBlock: …
The name of the MCP tool
The name of the MCP server
type: Literal["mcp_tool_use"]
class BetaMCPToolResultBlock: …
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.
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.
class BetaCitationCharLocation: …
type: Literal["char_location"]
class BetaCitationPageLocation: …
type: Literal["page_location"]
class BetaCitationContentBlockLocation: …
type: Literal["content_block_location"]
class BetaCitationsWebSearchResultLocation: …
type: Literal["web_search_result_location"]
class BetaCitationSearchResultLocation: …
type: Literal["search_result_location"]
type: Literal["text"]
type: Literal["mcp_tool_result"]
class BetaContainerUploadBlock: …Response model for a file uploaded to the container.
Response model for a file uploaded to the container.
type: Literal["container_upload"]
context_management: Optional[BetaContextManagementResponse]Context management response.
Information about context management strategies applied during the request.
Context management response.
Information about context management strategies applied during the request.
applied_edits: List[AppliedEdit]List of context management edits that were applied.
List of context management edits that were applied.
class BetaClearToolUses20250919EditResponse: …
Number of input tokens cleared by this edit.
Number of tool uses that were cleared.
type: Literal["clear_tool_uses_20250919"]The type of context management edit applied.
The type of context management edit applied.
class BetaClearThinking20251015EditResponse: …
Number of input tokens cleared by this edit.
Number of thinking turns that were cleared.
type: Literal["clear_thinking_20251015"]The type of context management edit applied.
The type of context management edit applied.
UnionMember0 = Literal["claude-3-7-sonnet-latest", "claude-3-7-sonnet-20250219", "claude-3-5-haiku-latest", 15 more]The model that will complete your prompt.
See models for additional details and options.
claude-3-7-sonnet-latest - Deprecated: Will reach end-of-life on February 19th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
claude-3-7-sonnet-20250219 - Deprecated: Will reach end-of-life on February 19th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
claude-3-5-haiku-latest - Fastest and most compact model for near-instant responsiveness
claude-3-5-haiku-20241022 - Our fastest model
claude-haiku-4-5 - Hybrid model, capable of near-instant responses and extended thinking
claude-haiku-4-5-20251001 - Hybrid model, capable of near-instant responses and extended thinking
claude-sonnet-4-20250514 - High-performance model with extended thinking
claude-sonnet-4-0 - High-performance model with extended thinking
claude-4-sonnet-20250514 - High-performance model with extended thinking
claude-sonnet-4-5 - Our best model for real-world agents and coding
claude-sonnet-4-5-20250929 - Our best model for real-world agents and coding
claude-opus-4-0 - Our most capable model
claude-opus-4-20250514 - Our most capable model
claude-4-opus-20250514 - Our most capable model
claude-opus-4-1-20250805 - Our most capable model
claude-3-opus-latest - Deprecated: Will reach end-of-life on January 5th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
claude-3-opus-20240229 - Deprecated: Will reach end-of-life on January 5th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
claude-3-haiku-20240307 - Our previous most fast and cost-effective
The model that will complete your prompt.
See models for additional details and options.
claude-3-7-sonnet-latest- Deprecated: Will reach end-of-life on February 19th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.claude-3-7-sonnet-20250219- Deprecated: Will reach end-of-life on February 19th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.claude-3-5-haiku-latest- Fastest and most compact model for near-instant responsivenessclaude-3-5-haiku-20241022- Our fastest modelclaude-haiku-4-5- Hybrid model, capable of near-instant responses and extended thinkingclaude-haiku-4-5-20251001- Hybrid model, capable of near-instant responses and extended thinkingclaude-sonnet-4-20250514- High-performance model with extended thinkingclaude-sonnet-4-0- High-performance model with extended thinkingclaude-4-sonnet-20250514- High-performance model with extended thinkingclaude-sonnet-4-5- Our best model for real-world agents and codingclaude-sonnet-4-5-20250929- Our best model for real-world agents and codingclaude-opus-4-0- Our most capable modelclaude-opus-4-20250514- Our most capable modelclaude-4-opus-20250514- Our most capable modelclaude-opus-4-1-20250805- Our most capable modelclaude-3-opus-latest- Deprecated: Will reach end-of-life on January 5th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.claude-3-opus-20240229- Deprecated: Will reach end-of-life on January 5th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.claude-3-haiku-20240307- Our previous most fast and cost-effective
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: Literal["assistant"]Conversational role of the generated message.
This will always be "assistant".
Conversational role of the generated message.
This will always be "assistant".
stop_reason: Optional[BetaStopReason]The reason that we stopped.
This may be one the following values:
"end_turn": the model reached a natural stopping point
"max_tokens": we exceeded the requested max_tokens or the model's maximum
"stop_sequence": one of your provided custom stop_sequences was generated
"tool_use": the model invoked one or more tools
"pause_turn": we paused a long-running turn. You may provide the response back as-is in a subsequent request to let the model continue.
"refusal": when streaming classifiers intervene to handle potential policy violations
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: Literal["message"]Object type.
For Messages, this is always "message".
Object type.
For Messages, this is always "message".
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.
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.
cache_creation: Optional[BetaCacheCreation]Breakdown 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.
server_tool_use: Optional[BetaServerToolUsage]The number of server tool requests.
The number of server tool requests.
The number of web fetch tool requests.
The number of web search tool requests.
service_tier: Optional[Literal["standard", "priority", "batch"]]If the request used the priority, standard, or batch tier.
If the request used the priority, standard, or batch tier.
type: Literal["succeeded"]
class BetaMessageBatchErroredResult: …
class BetaInvalidRequestError: …
type: Literal["invalid_request_error"]
class BetaAuthenticationError: …
type: Literal["authentication_error"]
class BetaBillingError: …
type: Literal["billing_error"]
class BetaPermissionError: …
type: Literal["permission_error"]
class BetaNotFoundError: …
type: Literal["not_found_error"]
class BetaRateLimitError: …
type: Literal["rate_limit_error"]
class BetaGatewayTimeoutError: …
type: Literal["timeout_error"]
class BetaAPIError: …
type: Literal["api_error"]
class BetaOverloadedError: …
type: Literal["overloaded_error"]
type: Literal["error"]
type: Literal["errored"]
class BetaMessageBatchCanceledResult: …
type: Literal["canceled"]
class BetaMessageBatchExpiredResult: …
type: Literal["expired"]
class BetaMessageBatchRequestCounts: …
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.
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.
class BetaMessageBatchSucceededResult: …
Unique object identifier.
The format and length of IDs may change over time.
container: Optional[BetaContainer]Information about the container used in the request (for the code execution tool)
Information about the container used in the request (for the code execution tool)
Identifier for the container used in this request
The time at which the container will expire.
Skills loaded in the container
Skills loaded in the container
Skill ID
type: Literal["anthropic", "custom"]Type of skill - either 'anthropic' (built-in) or 'custom' (user-defined)
Type of skill - either 'anthropic' (built-in) or 'custom' (user-defined)
Skill version or 'latest' for most recent version
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)"}]
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)"}]
class BetaTextBlock: …
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.
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.
class BetaCitationCharLocation: …
type: Literal["char_location"]
class BetaCitationPageLocation: …
type: Literal["page_location"]
class BetaCitationContentBlockLocation: …
type: Literal["content_block_location"]
class BetaCitationsWebSearchResultLocation: …
type: Literal["web_search_result_location"]
class BetaCitationSearchResultLocation: …
type: Literal["search_result_location"]
type: Literal["text"]
class BetaThinkingBlock: …
type: Literal["thinking"]
class BetaRedactedThinkingBlock: …
type: Literal["redacted_thinking"]
class BetaToolUseBlock: …
type: Literal["tool_use"]
class BetaServerToolUseBlock: …
name: Literal["web_search", "web_fetch", "code_execution", 2 more]
type: Literal["server_tool_use"]
class BetaWebSearchToolResultBlock: …
class BetaWebSearchToolResultError: …
type: Literal["web_search_tool_result_error"]
type: Literal["web_search_result"]
type: Literal["web_search_tool_result"]
class BetaWebFetchToolResultBlock: …
content: Content
class BetaWebFetchToolResultErrorBlock: …
type: Literal["web_fetch_tool_result_error"]
class BetaWebFetchBlock: …
citations: Optional[BetaCitationConfig]Citation configuration for the document
Citation configuration for the document
source: Source
class BetaBase64PDFSource: …
media_type: Literal["application/pdf"]
type: Literal["base64"]
class BetaPlainTextSource: …
media_type: Literal["text/plain"]
type: Literal["text"]
The title of the document
type: Literal["document"]
ISO 8601 timestamp when the content was retrieved
type: Literal["web_fetch_result"]
Fetched content URL
type: Literal["web_fetch_tool_result"]
class BetaCodeExecutionToolResultBlock: …
class BetaCodeExecutionToolResultError: …
type: Literal["code_execution_tool_result_error"]
class BetaCodeExecutionResultBlock: …
type: Literal["code_execution_output"]
type: Literal["code_execution_result"]
type: Literal["code_execution_tool_result"]
class BetaBashCodeExecutionToolResultBlock: …
content: Content
class BetaBashCodeExecutionToolResultError: …
error_code: Literal["invalid_tool_input", "unavailable", "too_many_requests", 2 more]
type: Literal["bash_code_execution_tool_result_error"]
class BetaBashCodeExecutionResultBlock: …
type: Literal["bash_code_execution_output"]
type: Literal["bash_code_execution_result"]
type: Literal["bash_code_execution_tool_result"]
class BetaTextEditorCodeExecutionToolResultBlock: …
content: Content
class BetaTextEditorCodeExecutionToolResultError: …
error_code: Literal["invalid_tool_input", "unavailable", "too_many_requests", 2 more]
type: Literal["text_editor_code_execution_tool_result_error"]
class BetaTextEditorCodeExecutionViewResultBlock: …
file_type: Literal["text", "image", "pdf"]
type: Literal["text_editor_code_execution_view_result"]
class BetaTextEditorCodeExecutionCreateResultBlock: …
type: Literal["text_editor_code_execution_create_result"]
class BetaTextEditorCodeExecutionStrReplaceResultBlock: …
type: Literal["text_editor_code_execution_str_replace_result"]
type: Literal["text_editor_code_execution_tool_result"]
class BetaMCPToolUseBlock: …
The name of the MCP tool
The name of the MCP server
type: Literal["mcp_tool_use"]
class BetaMCPToolResultBlock: …
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.
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.
class BetaCitationCharLocation: …
type: Literal["char_location"]
class BetaCitationPageLocation: …
type: Literal["page_location"]
class BetaCitationContentBlockLocation: …
type: Literal["content_block_location"]
class BetaCitationsWebSearchResultLocation: …
type: Literal["web_search_result_location"]
class BetaCitationSearchResultLocation: …
type: Literal["search_result_location"]
type: Literal["text"]
type: Literal["mcp_tool_result"]
class BetaContainerUploadBlock: …Response model for a file uploaded to the container.
Response model for a file uploaded to the container.
type: Literal["container_upload"]
context_management: Optional[BetaContextManagementResponse]Context management response.
Information about context management strategies applied during the request.
Context management response.
Information about context management strategies applied during the request.
applied_edits: List[AppliedEdit]List of context management edits that were applied.
List of context management edits that were applied.
class BetaClearToolUses20250919EditResponse: …
Number of input tokens cleared by this edit.
Number of tool uses that were cleared.
type: Literal["clear_tool_uses_20250919"]The type of context management edit applied.
The type of context management edit applied.
class BetaClearThinking20251015EditResponse: …
Number of input tokens cleared by this edit.
Number of thinking turns that were cleared.
type: Literal["clear_thinking_20251015"]The type of context management edit applied.
The type of context management edit applied.
UnionMember0 = Literal["claude-3-7-sonnet-latest", "claude-3-7-sonnet-20250219", "claude-3-5-haiku-latest", 15 more]The model that will complete your prompt.
See models for additional details and options.
claude-3-7-sonnet-latest - Deprecated: Will reach end-of-life on February 19th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
claude-3-7-sonnet-20250219 - Deprecated: Will reach end-of-life on February 19th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
claude-3-5-haiku-latest - Fastest and most compact model for near-instant responsiveness
claude-3-5-haiku-20241022 - Our fastest model
claude-haiku-4-5 - Hybrid model, capable of near-instant responses and extended thinking
claude-haiku-4-5-20251001 - Hybrid model, capable of near-instant responses and extended thinking
claude-sonnet-4-20250514 - High-performance model with extended thinking
claude-sonnet-4-0 - High-performance model with extended thinking
claude-4-sonnet-20250514 - High-performance model with extended thinking
claude-sonnet-4-5 - Our best model for real-world agents and coding
claude-sonnet-4-5-20250929 - Our best model for real-world agents and coding
claude-opus-4-0 - Our most capable model
claude-opus-4-20250514 - Our most capable model
claude-4-opus-20250514 - Our most capable model
claude-opus-4-1-20250805 - Our most capable model
claude-3-opus-latest - Deprecated: Will reach end-of-life on January 5th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
claude-3-opus-20240229 - Deprecated: Will reach end-of-life on January 5th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
claude-3-haiku-20240307 - Our previous most fast and cost-effective
The model that will complete your prompt.
See models for additional details and options.
claude-3-7-sonnet-latest- Deprecated: Will reach end-of-life on February 19th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.claude-3-7-sonnet-20250219- Deprecated: Will reach end-of-life on February 19th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.claude-3-5-haiku-latest- Fastest and most compact model for near-instant responsivenessclaude-3-5-haiku-20241022- Our fastest modelclaude-haiku-4-5- Hybrid model, capable of near-instant responses and extended thinkingclaude-haiku-4-5-20251001- Hybrid model, capable of near-instant responses and extended thinkingclaude-sonnet-4-20250514- High-performance model with extended thinkingclaude-sonnet-4-0- High-performance model with extended thinkingclaude-4-sonnet-20250514- High-performance model with extended thinkingclaude-sonnet-4-5- Our best model for real-world agents and codingclaude-sonnet-4-5-20250929- Our best model for real-world agents and codingclaude-opus-4-0- Our most capable modelclaude-opus-4-20250514- Our most capable modelclaude-4-opus-20250514- Our most capable modelclaude-opus-4-1-20250805- Our most capable modelclaude-3-opus-latest- Deprecated: Will reach end-of-life on January 5th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.claude-3-opus-20240229- Deprecated: Will reach end-of-life on January 5th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.claude-3-haiku-20240307- Our previous most fast and cost-effective
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: Literal["assistant"]Conversational role of the generated message.
This will always be "assistant".
Conversational role of the generated message.
This will always be "assistant".
stop_reason: Optional[BetaStopReason]The reason that we stopped.
This may be one the following values:
"end_turn": the model reached a natural stopping point
"max_tokens": we exceeded the requested max_tokens or the model's maximum
"stop_sequence": one of your provided custom stop_sequences was generated
"tool_use": the model invoked one or more tools
"pause_turn": we paused a long-running turn. You may provide the response back as-is in a subsequent request to let the model continue.
"refusal": when streaming classifiers intervene to handle potential policy violations
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: Literal["message"]Object type.
For Messages, this is always "message".
Object type.
For Messages, this is always "message".
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.
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.
cache_creation: Optional[BetaCacheCreation]Breakdown 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.
server_tool_use: Optional[BetaServerToolUsage]The number of server tool requests.
The number of server tool requests.
The number of web fetch tool requests.
The number of web search tool requests.
service_tier: Optional[Literal["standard", "priority", "batch"]]If the request used the priority, standard, or batch tier.
If the request used the priority, standard, or batch tier.
type: Literal["succeeded"]
class BetaMessageBatchErroredResult: …
class BetaInvalidRequestError: …
type: Literal["invalid_request_error"]
class BetaAuthenticationError: …
type: Literal["authentication_error"]
class BetaBillingError: …
type: Literal["billing_error"]
class BetaPermissionError: …
type: Literal["permission_error"]
class BetaNotFoundError: …
type: Literal["not_found_error"]
class BetaRateLimitError: …
type: Literal["rate_limit_error"]
class BetaGatewayTimeoutError: …
type: Literal["timeout_error"]
class BetaAPIError: …
type: Literal["api_error"]
class BetaOverloadedError: …
type: Literal["overloaded_error"]
type: Literal["error"]
type: Literal["errored"]
class BetaMessageBatchCanceledResult: …
type: Literal["canceled"]
class BetaMessageBatchExpiredResult: …
type: Literal["expired"]
class BetaMessageBatchSucceededResult: …
Unique object identifier.
The format and length of IDs may change over time.
container: Optional[BetaContainer]Information about the container used in the request (for the code execution tool)
Information about the container used in the request (for the code execution tool)
Identifier for the container used in this request
The time at which the container will expire.
Skills loaded in the container
Skills loaded in the container
Skill ID
type: Literal["anthropic", "custom"]Type of skill - either 'anthropic' (built-in) or 'custom' (user-defined)
Type of skill - either 'anthropic' (built-in) or 'custom' (user-defined)
Skill version or 'latest' for most recent version
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)"}]
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)"}]
class BetaTextBlock: …
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.
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.
class BetaCitationCharLocation: …
type: Literal["char_location"]
class BetaCitationPageLocation: …
type: Literal["page_location"]
class BetaCitationContentBlockLocation: …
type: Literal["content_block_location"]
class BetaCitationsWebSearchResultLocation: …
type: Literal["web_search_result_location"]
class BetaCitationSearchResultLocation: …
type: Literal["search_result_location"]
type: Literal["text"]
class BetaThinkingBlock: …
type: Literal["thinking"]
class BetaRedactedThinkingBlock: …
type: Literal["redacted_thinking"]
class BetaToolUseBlock: …
type: Literal["tool_use"]
class BetaServerToolUseBlock: …
name: Literal["web_search", "web_fetch", "code_execution", 2 more]
type: Literal["server_tool_use"]
class BetaWebSearchToolResultBlock: …
class BetaWebSearchToolResultError: …
type: Literal["web_search_tool_result_error"]
type: Literal["web_search_result"]
type: Literal["web_search_tool_result"]
class BetaWebFetchToolResultBlock: …
content: Content
class BetaWebFetchToolResultErrorBlock: …
type: Literal["web_fetch_tool_result_error"]
class BetaWebFetchBlock: …
citations: Optional[BetaCitationConfig]Citation configuration for the document
Citation configuration for the document
source: Source
class BetaBase64PDFSource: …
media_type: Literal["application/pdf"]
type: Literal["base64"]
class BetaPlainTextSource: …
media_type: Literal["text/plain"]
type: Literal["text"]
The title of the document
type: Literal["document"]
ISO 8601 timestamp when the content was retrieved
type: Literal["web_fetch_result"]
Fetched content URL
type: Literal["web_fetch_tool_result"]
class BetaCodeExecutionToolResultBlock: …
class BetaCodeExecutionToolResultError: …
type: Literal["code_execution_tool_result_error"]
class BetaCodeExecutionResultBlock: …
type: Literal["code_execution_output"]
type: Literal["code_execution_result"]
type: Literal["code_execution_tool_result"]
class BetaBashCodeExecutionToolResultBlock: …
content: Content
class BetaBashCodeExecutionToolResultError: …
error_code: Literal["invalid_tool_input", "unavailable", "too_many_requests", 2 more]
type: Literal["bash_code_execution_tool_result_error"]
class BetaBashCodeExecutionResultBlock: …
type: Literal["bash_code_execution_output"]
type: Literal["bash_code_execution_result"]
type: Literal["bash_code_execution_tool_result"]
class BetaTextEditorCodeExecutionToolResultBlock: …
content: Content
class BetaTextEditorCodeExecutionToolResultError: …
error_code: Literal["invalid_tool_input", "unavailable", "too_many_requests", 2 more]
type: Literal["text_editor_code_execution_tool_result_error"]
class BetaTextEditorCodeExecutionViewResultBlock: …
file_type: Literal["text", "image", "pdf"]
type: Literal["text_editor_code_execution_view_result"]
class BetaTextEditorCodeExecutionCreateResultBlock: …
type: Literal["text_editor_code_execution_create_result"]
class BetaTextEditorCodeExecutionStrReplaceResultBlock: …
type: Literal["text_editor_code_execution_str_replace_result"]
type: Literal["text_editor_code_execution_tool_result"]
class BetaMCPToolUseBlock: …
The name of the MCP tool
The name of the MCP server
type: Literal["mcp_tool_use"]
class BetaMCPToolResultBlock: …
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.
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.
class BetaCitationCharLocation: …
type: Literal["char_location"]
class BetaCitationPageLocation: …
type: Literal["page_location"]
class BetaCitationContentBlockLocation: …
type: Literal["content_block_location"]
class BetaCitationsWebSearchResultLocation: …
type: Literal["web_search_result_location"]
class BetaCitationSearchResultLocation: …
type: Literal["search_result_location"]
type: Literal["text"]
type: Literal["mcp_tool_result"]
class BetaContainerUploadBlock: …Response model for a file uploaded to the container.
Response model for a file uploaded to the container.
type: Literal["container_upload"]
context_management: Optional[BetaContextManagementResponse]Context management response.
Information about context management strategies applied during the request.
Context management response.
Information about context management strategies applied during the request.
applied_edits: List[AppliedEdit]List of context management edits that were applied.
List of context management edits that were applied.
class BetaClearToolUses20250919EditResponse: …
Number of input tokens cleared by this edit.
Number of tool uses that were cleared.
type: Literal["clear_tool_uses_20250919"]The type of context management edit applied.
The type of context management edit applied.
class BetaClearThinking20251015EditResponse: …
Number of input tokens cleared by this edit.
Number of thinking turns that were cleared.
type: Literal["clear_thinking_20251015"]The type of context management edit applied.
The type of context management edit applied.
UnionMember0 = Literal["claude-3-7-sonnet-latest", "claude-3-7-sonnet-20250219", "claude-3-5-haiku-latest", 15 more]The model that will complete your prompt.
See models for additional details and options.
claude-3-7-sonnet-latest - Deprecated: Will reach end-of-life on February 19th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
claude-3-7-sonnet-20250219 - Deprecated: Will reach end-of-life on February 19th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
claude-3-5-haiku-latest - Fastest and most compact model for near-instant responsiveness
claude-3-5-haiku-20241022 - Our fastest model
claude-haiku-4-5 - Hybrid model, capable of near-instant responses and extended thinking
claude-haiku-4-5-20251001 - Hybrid model, capable of near-instant responses and extended thinking
claude-sonnet-4-20250514 - High-performance model with extended thinking
claude-sonnet-4-0 - High-performance model with extended thinking
claude-4-sonnet-20250514 - High-performance model with extended thinking
claude-sonnet-4-5 - Our best model for real-world agents and coding
claude-sonnet-4-5-20250929 - Our best model for real-world agents and coding
claude-opus-4-0 - Our most capable model
claude-opus-4-20250514 - Our most capable model
claude-4-opus-20250514 - Our most capable model
claude-opus-4-1-20250805 - Our most capable model
claude-3-opus-latest - Deprecated: Will reach end-of-life on January 5th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
claude-3-opus-20240229 - Deprecated: Will reach end-of-life on January 5th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
claude-3-haiku-20240307 - Our previous most fast and cost-effective
The model that will complete your prompt.
See models for additional details and options.
claude-3-7-sonnet-latest- Deprecated: Will reach end-of-life on February 19th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.claude-3-7-sonnet-20250219- Deprecated: Will reach end-of-life on February 19th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.claude-3-5-haiku-latest- Fastest and most compact model for near-instant responsivenessclaude-3-5-haiku-20241022- Our fastest modelclaude-haiku-4-5- Hybrid model, capable of near-instant responses and extended thinkingclaude-haiku-4-5-20251001- Hybrid model, capable of near-instant responses and extended thinkingclaude-sonnet-4-20250514- High-performance model with extended thinkingclaude-sonnet-4-0- High-performance model with extended thinkingclaude-4-sonnet-20250514- High-performance model with extended thinkingclaude-sonnet-4-5- Our best model for real-world agents and codingclaude-sonnet-4-5-20250929- Our best model for real-world agents and codingclaude-opus-4-0- Our most capable modelclaude-opus-4-20250514- Our most capable modelclaude-4-opus-20250514- Our most capable modelclaude-opus-4-1-20250805- Our most capable modelclaude-3-opus-latest- Deprecated: Will reach end-of-life on January 5th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.claude-3-opus-20240229- Deprecated: Will reach end-of-life on January 5th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.claude-3-haiku-20240307- Our previous most fast and cost-effective
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: Literal["assistant"]Conversational role of the generated message.
This will always be "assistant".
Conversational role of the generated message.
This will always be "assistant".
stop_reason: Optional[BetaStopReason]The reason that we stopped.
This may be one the following values:
"end_turn": the model reached a natural stopping point
"max_tokens": we exceeded the requested max_tokens or the model's maximum
"stop_sequence": one of your provided custom stop_sequences was generated
"tool_use": the model invoked one or more tools
"pause_turn": we paused a long-running turn. You may provide the response back as-is in a subsequent request to let the model continue.
"refusal": when streaming classifiers intervene to handle potential policy violations
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: Literal["message"]Object type.
For Messages, this is always "message".
Object type.
For Messages, this is always "message".
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.
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.
cache_creation: Optional[BetaCacheCreation]Breakdown 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.
server_tool_use: Optional[BetaServerToolUsage]The number of server tool requests.
The number of server tool requests.
The number of web fetch tool requests.
The number of web search tool requests.
service_tier: Optional[Literal["standard", "priority", "batch"]]If the request used the priority, standard, or batch tier.
If the request used the priority, standard, or batch tier.
type: Literal["succeeded"]
BetaModels
List Models
Get a Model
ModelsExpand Collapse
class BetaModelInfo: …
Unique model identifier.
RFC 3339 datetime string representing the time at which the model was released. May be set to an epoch value if the release date is unknown.
A human-readable name for the model.
type: Literal["model"]Object type.
For Models, this is always "model".
Object type.
For Models, this is always "model".