Skip to content

aiollm_anthropic

aiollm_anthropic

Anthropic provider: its client, API and error resolver.

Modules:

Name Description
adapters

Anthropic's adapters between shared types and its methods.

api

URLs and version of the Anthropic API.

client

Client of the Anthropic API.

methods

Anthropic's methods of the Messages and Files APIs.

resolver

Error mapping of the Anthropic API.

tools

Anthropic's built-in tools, as the shared request takes them.

types

Anthropic's own types and the options of a generation call.

Classes:

Name Description
AnthropicAPI

Builds Anthropic request URLs.

AnthropicClient

Client of the Anthropic API.

AnthropicErrorResolver

Error resolver with Anthropic's specifics.

Attributes:

Name Type Description
ANTHROPIC_API Final[AnthropicAPI]

The Anthropic API, version 1.

API_VERSION Final

The anthropic-version that the library's Anthropic types follow.

ANTHROPIC_API module-attribute

ANTHROPIC_API: Final[AnthropicAPI] = AnthropicAPI(
    base_url="https://api.anthropic.com/", version="v1"
)

The Anthropic API, version 1.

API_VERSION module-attribute

API_VERSION: Final = '2026-10-21'

The anthropic-version that the library's Anthropic types follow.

Anthropic requires the header on every request; it fixes the request and response format, so it belongs to the methods written against it.

AnthropicAPI

AnthropicAPI(base_url: str | URL, version: str)

Bases: BaseAPI

Builds Anthropic request URLs.

AnthropicClient

AnthropicClient(
    token: str | None = None,
    *,
    session: ISession | None = None,
    default_max_tokens: int = DEFAULT_MAX_TOKENS,
    **session_kwargs: Unpack[AiohttpSessionOptions],
)

Bases: BaseProviderClient

Client of the Anthropic API.

Anthropic takes the key in Authorization or x-api-key; a given session that sends it elsewhere, or uses the generic BaseErrorResolver, gets a warning from warn_about_session.

Attributes:

Name Type Description
generation

Shared text generation over the Messages API, with max_tokens of default_max_tokens for a request without max_output_tokens.

files

Shared file storage over the Files API.

Example

async with AnthropicClient("sk-ant-...") as client: ... response = await client.generation.create( ... GenerationRequest(model="claude-opus-5-5", input="Hi") ... )

Create the client from a token or a ready session.

Parameters:

Name Type Description Default
token str | None

API key; an AiohttpSession with Anthropic's URL, error resolver and BearerAuth is created from it. Without a token and a session, ANTHROPIC_API_KEY is used.

None
session ISession | None

A ready session, for custom settings; it is checked with warn_about_session.

None
default_max_tokens int

max_tokens that generation sends for a request without max_output_tokens, since Anthropic requires it.

DEFAULT_MAX_TOKENS
**session_kwargs Unpack[AiohttpSessionOptions]

Further arguments of the AiohttpSession built from the token, such as timeout or max_body_size.

{}

Raises:

Type Description
ValueError

If both token and session are given, or neither is and ANTHROPIC_API_KEY is unset or empty, or session_kwargs are given with a session, or default_max_tokens is not positive.

AnthropicErrorResolver

Bases: BaseErrorResolver

Error resolver with Anthropic's specifics.

Anthropic's error object has a type (rate_limit_error, overloaded_error, ...) and no code; details.error_code, when present, is read as the code. A reached spend cap (429 with enforced_spend_limit_reached) or spend limit (400 whose message says so) is a QuotaExceededError and is not retried. The 529 overloaded_error is a transient ServiceUnavailableError, as OpenAI's 503. An error event of a stream arrives with the stream's 200 status, so its class is picked by its type; as for every resolver, it is never transient.

Methods:

Name Description
get_error_code

Read details.error_code of the error object.

classify_status

Pick the error class and transience of Anthropic's statuses.

get_error_code

get_error_code(error: Mapping[str, Any]) -> str | None

Read details.error_code of the error object.

Parameters:

Name Type Description Default
error Mapping[str, Any]

The error object of the response body.

required

Returns:

Type Description
str | None

The error code, or None if there is none.

classify_status

classify_status(
    *,
    status: int,
    code: str | None,
    error_type: str | None,
    message: str | None,
    retry_after: float | None,
) -> tuple[type[APIStatusError], bool]

Pick the error class and transience of Anthropic's statuses.

Parameters:

Name Type Description Default
status int

HTTP status the error is classified by.

required
code str | None

Provider error code, if any.

required
error_type str | None

Provider error type, if any.

required
message str | None

Error message, if any.

required
retry_after float | None

Seconds from Retry-After, if any.

required

Returns:

Type Description
type[APIStatusError]

QuotaExceededError (never transient) for a reached spend

bool

cap or limit, a transient ServiceUnavailableError for 529,

tuple[type[APIStatusError], bool]

else the default classification.

methods

Anthropic's methods of the Messages and Files APIs.

Their request fields are the generated mixins of methods.params.

Modules:

Name Description
files

Methods of Anthropic's Files API.

messages

Methods of Anthropic's Messages API.

params

Generated provider component types.

Classes:

Name Description
CreateFile

Upload a file, to refer to it by its id in later requests.

DeleteFile

Delete a file.

DownloadFile

Stream the content of a file that a tool created.

ListFiles

List the files of the workspace, newest first, a page at a time.

RetrieveFile

Get the metadata of a file.

CreateMessage

Create a message and wait for the whole of it.

StreamMessage

Create a message and stream its events.

Attributes:

Name Type Description
VERSION_HEADERS Final[Mapping[str, str]]

__request_headers__ of every Anthropic method.

VERSION_HEADERS module-attribute

VERSION_HEADERS: Final[Mapping[str, str]] = {
    ANTHROPIC_VERSION: API_VERSION
}

__request_headers__ of every Anthropic method.

Anthropic requires anthropic-version on every request, and the version fixes the request and response format, so a method written against API_VERSION sends it itself. A method of your own sets __request_headers__ = VERSION_HEADERS too.

CreateFile

Bases: CreateFileParams, BaseAPIMethod[FileMetadata]

Upload a file, to refer to it by its id in later requests.

The upload is never retried: POST /files is not idempotent, and a retry after a lost answer would store the file twice. A timeout or a lost connection may therefore leave a file at Anthropic whose id you never got; give the file expires_in_seconds where that matters.

Every key of the workspace sees its files: treat a file id as a server-side reference and never take one from an end user.

Example

file = await client.send_request( ... CreateFile(file=Path("report.pdf"), expires_in_seconds=3600) ... ) file.id

DeleteFile

Bases: DeleteFileParams, BaseAPIMethod[DeletedFile]

Delete a file.

It is retried on a transient failure, as the official SDKs do; a retry after a deletion whose answer was lost raises NotFoundError, since the file is already gone.

Example

await client.send_request(DeleteFile(file_id="file_1"))

DownloadFile

Bases: DownloadFileParams, BaseStreamMethod[bytes]

Stream the content of a file that a tool created.

Only files with downloadable set (made by code execution or a skill) can be downloaded; any other raises BadRequestError (file_not_downloadable), and an expired one NotFoundError. Only opening the download is retried. Stream.save(path) writes it to a file.

Example

method = DownloadFile(file_id="file_1") async with client.stream(method) as content: ... await content.save(Path("chart.png"))

ListFiles

Bases: ListFilesParams, BaseAPIMethod[ListFilesResponse]

List the files of the workspace, newest first, a page at a time.

Pass the page's next_page as page while it is not None. ids (up to 100) asks for those files only, in one page, and cannot be combined with page or limit. The id of a deleted or unknown file is left out, while one that is not a valid file id fails the whole request with BadRequestError.

Example

page = await client.send_request(ListFiles(limit=100)) while page.next_page is not None: ... page = await client.send_request( ... ListFiles(limit=100, page=page.next_page) ... )

RetrieveFile

Bases: RetrieveFileParams, BaseAPIMethod[FileMetadata]

Get the metadata of a file.

Example

file = await client.send_request(RetrieveFile(file_id="file_1"))

CreateMessage

Bases: MessageLimits, CreateMessageParams, BaseAPIMethod[Message]

Create a message and wait for the whole of it.

A transient failure (a lost connection, a timeout, a 5xx, the 529 overloaded_error, a 429 with Retry-After) is retried, as the official SDKs do. A timeout or a lost connection may hide a generation that ran on the server, a risk the SDKs accept too.

Example

message = await client.send_request( ... CreateMessage( ... model="claude-opus-5-5", ... max_tokens=1024, ... messages=[{"role": "user", "content": "Hi"}], ... ) ... ) message.content

StreamMessage

Bases: MessageLimits, StreamMessageParams, BaseStreamMethod[MessageStreamEvent]

Create a message and stream its events.

The stream is message_start, content blocks (each a content_block_start, deltas and a content_block_stop), one or more message_delta and message_stop, with ping events in between; an error event is raised as an APIStatusError. Only opening the stream is retried, on a transient failure. A body that ends before message_stop raises APIStreamInterruptedError.

Its stream field is always True: it asks for server-sent events.

Example

method = StreamMessage( ... model="claude-opus-5-5", ... max_tokens=1024, ... messages=[{"role": "user", "content": "Hi"}], ... ) async with client.stream(method) as events: ... async for event in events: ... if isinstance(event, ContentBlockDeltaEvent): ... ...

params

Generated provider component types.

Modules:

Name Description
files

Provider files types generated from OpenAPI.

images

Provider images types generated from OpenAPI.

messages

Provider messages types generated from OpenAPI.

shared

Provider shared types generated from OpenAPI.

tools

Provider tools types generated from OpenAPI.

Classes:

Name Description
BrowserFileUploadConfigParam

file_upload's config overrides.

ContainerUploadBlock

Response model for a file uploaded to the container.

CreateFileParams

CreateFileParams from the Anthropic Messages API.

CreateFileRequest

CreateFileRequest from the Anthropic Messages API.

DeleteFileParams

DeleteFileParams from the Anthropic Messages API.

DownloadFileParams

DownloadFileParams from the Anthropic Messages API.

FileDocumentSourceParam

FileDocumentSourceParam from the Anthropic Messages API.

FileImageSourceParam

FileImageSourceParam from the Anthropic Messages API.

ListFilesParams

ListFilesParams from the Anthropic Messages API.

RetrieveFileParams

RetrieveFileParams from the Anthropic Messages API.

Base64ImageSourceParam

Base64ImageSourceParam from the Anthropic Messages API.

ImageBlockParam

ImageBlockParam from the Anthropic Messages API.

ImageTransformationsParam

ImageTransformationsParam from the Anthropic Messages API.

URLImageSourceParam

URLImageSourceParam from the Anthropic Messages API.

AssistantMessageParam

AssistantMessageParam from the Anthropic Messages API.

CitationCharLocation

CitationCharLocation from the Anthropic Messages API.

CitationContentBlockLocation

CitationContentBlockLocation from the Anthropic Messages API.

CitationContentBlockLocationParam

CitationContentBlockLocationParam.

CitationPageLocation

CitationPageLocation from the Anthropic Messages API.

CitationsSearchResultLocation

CitationsSearchResultLocation from the Anthropic Messages API.

CitationsWebSearchResultLocation

CitationsWebSearchResultLocation.

ContainerParams

Container parameters with skills to be loaded.

ContentBlockSourceParam

ContentBlockSourceParam from the Anthropic Messages API.

CreateMessageParams

CreateMessageParams from the Anthropic Messages API.

DiagnosticsParam

Request-level diagnostics.

DocumentBlockParam

DocumentBlockParam from the Anthropic Messages API.

JSONOutputFormatParam

JSONOutputFormatParam from the Anthropic Messages API.

MessagesCreateWireBody

MessagesCreateWireBody from the Anthropic Messages API.

MetadataParam

MetadataParam from the Anthropic Messages API.

OutputConfigParam

OutputConfigParam from the Anthropic Messages API.

RedactedThinkingBlock

RedactedThinkingBlock from the Anthropic Messages API.

RedactedThinkingBlockParam

RedactedThinkingBlockParam from the Anthropic Messages API.

SearchResultBlockParam

SearchResultBlockParam from the Anthropic Messages API.

SkillParams

Specification for a skill to be loaded in a container.

StreamMessageParams

StreamMessageParams from the Anthropic Messages API.

SystemMessageParam

SystemMessageParam from the Anthropic Messages API.

TextBlock

TextBlock from the Anthropic Messages API.

TextBlockParam

TextBlockParam from the Anthropic Messages API.

ThinkingBlock

ThinkingBlock from the Anthropic Messages API.

ThinkingBlockParam

ThinkingBlockParam from the Anthropic Messages API.

ThinkingConfigAdaptiveParam

ThinkingConfigAdaptiveParam from the Anthropic Messages API.

ThinkingConfigDisabledParam

ThinkingConfigDisabledParam from the Anthropic Messages API.

ThinkingConfigEnabledParam

ThinkingConfigEnabledParam from the Anthropic Messages API.

ToolResultBlockParam

ToolResultBlockParam from the Anthropic Messages API.

UserMessageParam

UserMessageParam from the Anthropic Messages API.

WebFetchBlockParam

WebFetchBlockParam from the Anthropic Messages API.

WebFetchToolResultBlockParam

WebFetchToolResultBlockParam from the Anthropic Messages API.

Base64PDFSourceParam

Base64PDFSourceParam from the Anthropic Messages API.

CacheControlEphemeralParam

CacheControlEphemeralParam from the Anthropic Messages API.

CitationCharLocationParam

CitationCharLocationParam from the Anthropic Messages API.

CitationPageLocationParam

CitationPageLocationParam from the Anthropic Messages API.

CitationsConfigParam

CitationsConfigParam from the Anthropic Messages API.

CitationSearchResultLocationParam

CitationSearchResultLocationParam.

CitationWebSearchResultLocationParam

CitationWebSearchResultLocationParam.

ContainerUploadBlockParam

ContainerUploadBlockParam from the Anthropic Messages API.

PlainTextSourceParam

PlainTextSourceParam from the Anthropic Messages API.

URLPDFSourceParam

URLPDFSourceParam from the Anthropic Messages API.

Base64PDFSource

Base64PDFSource from the Anthropic Messages API.

BashCodeExecutionOutputBlock

BashCodeExecutionOutputBlock from the Anthropic Messages API.

BashCodeExecutionOutputBlockParam

BashCodeExecutionOutputBlockParam.

BashCodeExecutionResultBlock

BashCodeExecutionResultBlock from the Anthropic Messages API.

BashCodeExecutionResultBlockParam

BashCodeExecutionResultBlockParam.

BashCodeExecutionToolResultBlock

BashCodeExecutionToolResultBlock.

BashCodeExecutionToolResultBlockParam

BashCodeExecutionToolResultBlockParam.

BashCodeExecutionToolResultErrorObject

BashCodeExecutionToolResultErrorObject.

BashCodeExecutionToolResultErrorParam

BashCodeExecutionToolResultErrorParam.

BrowserCloseTabConfigParam

close_tab's config overrides.

BrowserDoubleClickConfigParam

double_click's config overrides.

BrowserFindConfigParam

find's config overrides.

BrowserFormInputConfigParam

form_input's config overrides.

BrowserGetPageTextConfigParam

get_page_text's config overrides.

BrowserHoldKeyConfigParam

hold_key's config overrides.

BrowserHoverConfigParam

hover's config overrides.

BrowserJavascriptExecConfigParam

javascript_exec's config overrides.

BrowserKeyConfigParam

key's config overrides.

BrowserLeftClickConfigParam

left_click's config overrides.

BrowserLeftClickDragConfigParam

left_click_drag's config overrides.

BrowserLeftMouseDownConfigParam

left_mouse_down's config overrides.

BrowserLeftMouseUpConfigParam

left_mouse_up's config overrides.

BrowserListTabsConfigParam

list_tabs's config overrides.

BrowserMiddleClickConfigParam

middle_click's config overrides.

BrowserMouseMoveConfigParam

mouse_move's config overrides.

BrowserNavigateConfigParam

navigate's config overrides.

BrowserNewTabConfigParam

new_tab's config overrides.

BrowserReadConsoleConfigParam

read_console's config overrides.

BrowserReadNetworkConfigParam

read_network's config overrides.

BrowserReadPageConfigParam

read_page's config overrides.

BrowserRightClickConfigParam

right_click's config overrides.

BrowserScreenshotConfigParam

screenshot's config overrides.

BrowserScrollConfigParam

scroll's config overrides.

BrowserScrollToConfigParam

scroll_to's config overrides.

BrowserStateBlockParam

BrowserStateBlockParam from the Anthropic Messages API.

BrowserStateChangeDownloadCompletedParam

BrowserStateChangeDownloadCompletedParam.

BrowserStateChangeDownloadFailedParam

BrowserStateChangeDownloadFailedParam.

BrowserStateChangeDownloadStartedParam

A file download that started during this call.

BrowserStateChangeTabOpenedParam

BrowserStateChangeTabOpenedParam.

BrowserStateTabEntryParam

BrowserStateTabEntryParam from the Anthropic Messages API.

BrowserSwitchTabConfigParam

switch_tab's config overrides.

BrowserToolset20260801Param

BrowserToolset20260801Param from the Anthropic Messages API.

BrowserToolsetConfigsParam

BrowserToolsetConfigsParam from the Anthropic Messages API.

BrowserTripleClickConfigParam

triple_click's config overrides.

BrowserTypeConfigParam

type's config overrides.

BrowserWaitConfigParam

wait's config overrides.

BrowserZoomConfigParam

zoom's config overrides.

CitationsConfig

CitationsConfig from the Anthropic Messages API.

CodeExecutionOutputBlock

CodeExecutionOutputBlock from the Anthropic Messages API.

CodeExecutionOutputBlockParam

CodeExecutionOutputBlockParam from the Anthropic Messages API.

CodeExecutionResultBlock

CodeExecutionResultBlock from the Anthropic Messages API.

CodeExecutionResultBlockParam

CodeExecutionResultBlockParam from the Anthropic Messages API.

CodeExecutionTool20250522Param

CodeExecutionTool20250522Param from the Anthropic Messages API.

CodeExecutionTool20250825Param

CodeExecutionTool20250825Param from the Anthropic Messages API.

CodeExecutionTool20260120Param

CodeExecutionTool20260120Param from the Anthropic Messages API.

CodeExecutionTool20260521Param

Code execution tool with REPL state persistence.

CodeExecutionToolResultBlock

CodeExecutionToolResultBlock from the Anthropic Messages API.

CodeExecutionToolResultBlockParam

CodeExecutionToolResultBlockParam.

CodeExecutionToolResultErrorObject

CodeExecutionToolResultErrorObject.

CodeExecutionToolResultErrorParam

CodeExecutionToolResultErrorParam.

ComputerCursorPositionConfigParam

cursor_position's config overrides.

ComputerDoubleClickConfigParam

double_click's config overrides.

ComputerHoldKeyConfigParam

hold_key's config overrides.

ComputerKeyConfigParam

key's config overrides.

ComputerLeftClickConfigParam

left_click's config overrides.

ComputerLeftClickDragConfigParam

left_click_drag's config overrides.

ComputerLeftMouseDownConfigParam

left_mouse_down's config overrides.

ComputerLeftMouseUpConfigParam

left_mouse_up's config overrides.

ComputerMiddleClickConfigParam

middle_click's config overrides.

ComputerMouseMoveConfigParam

mouse_move's config overrides.

ComputerRightClickConfigParam

right_click's config overrides.

ComputerScreenshotConfigParam

screenshot's config overrides.

ComputerScrollConfigParam

scroll's config overrides.

ComputerToolset20260801Param

ComputerToolset20260801Param from the Anthropic Messages API.

ComputerToolsetConfigsParam

ComputerToolsetConfigsParam from the Anthropic Messages API.

ComputerTripleClickConfigParam

triple_click's config overrides.

ComputerTypeConfigParam

type's config overrides.

ComputerWaitConfigParam

wait's config overrides.

ComputerZoomConfigParam

zoom's config overrides.

DirectCaller

Tool invocation directly from the model.

DirectCallerParam

Tool invocation directly from the model.

DocumentBlock

DocumentBlock from the Anthropic Messages API.

EncryptedCodeExecutionResultBlock

EncryptedCodeExecutionResultBlock.

EncryptedCodeExecutionResultBlockParam

EncryptedCodeExecutionResultBlockParam.

InputSchemaTyped

InputSchemaTyped from the Anthropic Messages API.

MemoryTool20250818Param

MemoryTool20250818Param from the Anthropic Messages API.

PlainTextSource

PlainTextSource from the Anthropic Messages API.

ServerToolCaller

Tool invocation generated by a server-side tool.

ServerToolCaller20260120

ServerToolCaller20260120 from the Anthropic Messages API.

ServerToolCaller20260120Param

ServerToolCaller20260120Param from the Anthropic Messages API.

ServerToolCallerParam

Tool invocation generated by a server-side tool.

ServerToolUseBlock

ServerToolUseBlock from the Anthropic Messages API.

ServerToolUseBlockParam

ServerToolUseBlockParam from the Anthropic Messages API.

TextEditorCodeExecutionCreateResultBlock

TextEditorCodeExecutionCreateResultBlock.

TextEditorCodeExecutionCreateResultBlockParam

TextEditorCodeExecutionCreateResultBlockParam.

TextEditorCodeExecutionStrReplaceResultBlock

TextEditorCodeExecutionStrReplaceResultBlock.

TextEditorCodeExecutionStrReplaceResultBlockParam

TextEditorCodeExecutionStrReplaceResultBlockParam.

TextEditorCodeExecutionToolResultBlock

TextEditorCodeExecutionToolResultBlock.

TextEditorCodeExecutionToolResultBlockParam

TextEditorCodeExecutionToolResultBlockParam.

TextEditorCodeExecutionToolResultErrorObject

TextEditorCodeExecutionToolResultErrorObject.

TextEditorCodeExecutionToolResultErrorParam

TextEditorCodeExecutionToolResultErrorParam.

TextEditorCodeExecutionViewResultBlock

TextEditorCodeExecutionViewResultBlock.

TextEditorCodeExecutionViewResultBlockParam

TextEditorCodeExecutionViewResultBlockParam.

ThinkingConfigBetweenToolsParam

ThinkingConfigBetweenToolsParam.

ToolBash20250124Param

ToolBash20250124Param from the Anthropic Messages API.

ToolChoiceAnyParam

The model will use any available tools.

ToolChoiceAutoParam

The model will automatically decide whether to use tools.

ToolChoiceNoneParam

The model will not be allowed to use tools.

ToolChoiceToolParam

The model will use the specified tool with tool_choice.name.

ToolParam

ToolParam from the Anthropic Messages API.

ToolReferenceBlock

ToolReferenceBlock from the Anthropic Messages API.

ToolReferenceBlockParam

Tool reference block that can be included in tool_result content.

ToolSearchToolBm2520251119Param

ToolSearchToolBm2520251119Param.

ToolSearchToolRegex20251119Param

ToolSearchToolRegex20251119Param.

ToolSearchToolResultBlock

ToolSearchToolResultBlock from the Anthropic Messages API.

ToolSearchToolResultBlockParam

ToolSearchToolResultBlockParam from the Anthropic Messages API.

ToolSearchToolResultErrorObject

ToolSearchToolResultErrorObject.

ToolSearchToolResultErrorParam

ToolSearchToolResultErrorParam from the Anthropic Messages API.

ToolSearchToolSearchResultBlock

ToolSearchToolSearchResultBlock.

ToolSearchToolSearchResultBlockParam

ToolSearchToolSearchResultBlockParam.

ToolTextEditor20250124Param

ToolTextEditor20250124Param from the Anthropic Messages API.

ToolTextEditor20250429Param

ToolTextEditor20250429Param from the Anthropic Messages API.

ToolTextEditor20250728Param

ToolTextEditor20250728Param from the Anthropic Messages API.

ToolUseBlock

ToolUseBlock from the Anthropic Messages API.

ToolUseBlockParam

ToolUseBlockParam from the Anthropic Messages API.

UserLocationParam

UserLocationParam from the Anthropic Messages API.

WebFetchBlock

WebFetchBlock from the Anthropic Messages API.

WebFetchTool20250910Param

WebFetchTool20250910Param from the Anthropic Messages API.

WebFetchTool20260209Param

WebFetchTool20260209Param from the Anthropic Messages API.

WebFetchTool20260309Param

WebFetchTool20260309Param from the Anthropic Messages API.

WebFetchTool20260318Param

WebFetchTool20260318Param from the Anthropic Messages API.

WebFetchToolResultBlock

WebFetchToolResultBlock from the Anthropic Messages API.

WebFetchToolResultErrorBlock

WebFetchToolResultErrorBlock from the Anthropic Messages API.

WebFetchToolResultErrorBlockParam

WebFetchToolResultErrorBlockParam.

WebFetchURLSourceAllParam

WebFetchURLSourceAllParam from the Anthropic Messages API.

WebFetchURLSourceExceptParam

WebFetchURLSourceExceptParam from the Anthropic Messages API.

WebFetchURLSourceNoneParam

WebFetchURLSourceNoneParam from the Anthropic Messages API.

WebFetchURLSourceOnlyParam

WebFetchURLSourceOnlyParam from the Anthropic Messages API.

WebFetchURLSourcesParam

Which sources contribute to the set of URLs web fetch may fetch.

WebFetchURLSourceToolReferenceParam

WebFetchURLSourceToolReferenceParam.

WebSearchResultBlock

WebSearchResultBlock from the Anthropic Messages API.

WebSearchResultBlockParam

WebSearchResultBlockParam from the Anthropic Messages API.

WebSearchTool20250305Param

WebSearchTool20250305Param from the Anthropic Messages API.

WebSearchTool20260209Param

WebSearchTool20260209Param from the Anthropic Messages API.

WebSearchTool20260318Param

WebSearchTool20260318Param from the Anthropic Messages API.

WebSearchToolRequestErrorObjectParam

WebSearchToolRequestErrorObjectParam.

WebSearchToolResultBlock

WebSearchToolResultBlock from the Anthropic Messages API.

WebSearchToolResultBlockParam

WebSearchToolResultBlockParam from the Anthropic Messages API.

WebSearchToolResultErrorObject

WebSearchToolResultErrorObject from the Anthropic Messages API.

BrowserFileUploadConfigParam

Bases: BaseAPIType

file_upload's config overrides.

ContainerUploadBlock

Bases: BaseAPIType

Response model for a file uploaded to the container.

CreateFileParams

Bases: BaseAPIType

CreateFileParams from the Anthropic Messages API.

Attributes:

Name Type Description
file Annotated[InputFile, Field(description="The file to upload. Only the final path component of the part's `filename` is kept; an absent or empty `filename` is replaced with `unnamed` plus the extension for the file's stored `mime_type`, when known.")]

The file to upload. Only the final path component of the part's filename is kept; an absent or empty filename is replaced with unnamed plus the extension for the file's stored mime_type, when known.

expires_in_seconds Annotated[int | MISSING, Field(description='Seconds from upload until the file expires and its bytes become permanently unavailable. Must be between 3600 (one hour) and 7776000 (ninety days).', ge=3600, le=7776000)]

Seconds from upload until the file expires and its bytes become permanently unavailable. Must be between 3600 (one hour) and 7776000 (ninety days).

CreateFileRequest

Bases: BaseAPIType

CreateFileRequest from the Anthropic Messages API.

Attributes:

Name Type Description
file Annotated[InputFile, Field(description="The file to upload. Only the final path component of the part's `filename` is kept; an absent or empty `filename` is replaced with `unnamed` plus the extension for the file's stored `mime_type`, when known.")]

The file to upload. Only the final path component of the part's filename is kept; an absent or empty filename is replaced with unnamed plus the extension for the file's stored mime_type, when known.

expires_in_seconds Annotated[int | MISSING, Field(description='Seconds from upload until the file expires and its bytes become permanently unavailable. Must be between 3600 (one hour) and 7776000 (ninety days).', ge=3600, le=7776000)]

Seconds from upload until the file expires and its bytes become permanently unavailable. Must be between 3600 (one hour) and 7776000 (ninety days).

DeleteFileParams

Bases: BaseAPIType

DeleteFileParams from the Anthropic Messages API.

DownloadFileParams

Bases: BaseAPIType

DownloadFileParams from the Anthropic Messages API.

FileDocumentSourceParam

Bases: BaseAPIType

FileDocumentSourceParam from the Anthropic Messages API.

FileImageSourceParam

Bases: BaseAPIType

FileImageSourceParam from the Anthropic Messages API.

ListFilesParams

Bases: BaseAPIType

ListFilesParams from the Anthropic Messages API.

RetrieveFileParams

Bases: BaseAPIType

RetrieveFileParams from the Anthropic Messages API.

Base64ImageSourceParam

Bases: BaseAPIType

Base64ImageSourceParam from the Anthropic Messages API.

ImageBlockParam

Bases: BaseAPIType

ImageBlockParam from the Anthropic Messages API.

Attributes:

Name Type Description
transformations ImageTransformationsParam | None | MISSING

Configures the transformations the server applies to this image before the model observes it. Each key names a condition the server transforms images for; its value selects the transformation applied. Omitted keys keep their default behavior, and an empty object is equivalent to omitting the field.

ImageTransformationsParam

Bases: BaseAPIType

ImageTransformationsParam from the Anthropic Messages API.

Configures the transformations the server applies to this image before the model observes it. Each key names a condition the server transforms images for; its value selects the transformation applied. Omitted keys keep their default behavior, and an empty object is equivalent to omitting the field.

URLImageSourceParam

Bases: BaseAPIType

URLImageSourceParam from the Anthropic Messages API.

AssistantMessageParam

Bases: BaseAPIType

AssistantMessageParam from the Anthropic Messages API.

CitationCharLocation

Bases: BaseAPIType

CitationCharLocation from the Anthropic Messages API.

CitationContentBlockLocation

Bases: BaseAPIType

CitationContentBlockLocation from the Anthropic Messages API.

CitationContentBlockLocationParam

Bases: BaseAPIType

CitationContentBlockLocationParam.

CitationPageLocation

Bases: BaseAPIType

CitationPageLocation from the Anthropic Messages API.

CitationsSearchResultLocation

Bases: BaseAPIType

CitationsSearchResultLocation from the Anthropic Messages API.

CitationsWebSearchResultLocation

Bases: BaseAPIType

CitationsWebSearchResultLocation.

ContainerParams

Bases: BaseAPIType

Container parameters with skills to be loaded.

Attributes:

Name Type Description
skills Annotated[list[SkillParams] | None | MISSING, Field(title='Skills')]

Specification for a skill to be loaded in a container.

ContentBlockSourceParam

Bases: BaseAPIType

ContentBlockSourceParam from the Anthropic Messages API.

CreateMessageParams

Bases: BaseAPIType

CreateMessageParams from the Anthropic Messages API.

Attributes:

Name Type Description
container Annotated[ContainerParams | str | None | MISSING, Field(title='Container')]

Container parameters with skills to be loaded.

diagnostics DiagnosticsParam | None | MISSING

Request-level diagnostics.

DiagnosticsParam

Bases: BaseAPIType

Request-level diagnostics.

Currently carries the previous response id for prompt-cache divergence reporting.

DocumentBlockParam

Bases: BaseAPIType

DocumentBlockParam from the Anthropic Messages API.

JSONOutputFormatParam

Bases: BaseAPIType

JSONOutputFormatParam from the Anthropic Messages API.

MessagesCreateWireBody

Bases: BaseAPIType

MessagesCreateWireBody from the Anthropic Messages API.

Attributes:

Name Type Description
container Annotated[ContainerParams | str | None | MISSING, Field(title='Container')]

Container parameters with skills to be loaded.

diagnostics DiagnosticsParam | None | MISSING

Request-level diagnostics.

MetadataParam

Bases: BaseAPIType

MetadataParam from the Anthropic Messages API.

OutputConfigParam

Bases: BaseAPIType

OutputConfigParam from the Anthropic Messages API.

RedactedThinkingBlock

Bases: BaseAPIType

RedactedThinkingBlock from the Anthropic Messages API.

RedactedThinkingBlockParam

Bases: BaseAPIType

RedactedThinkingBlockParam from the Anthropic Messages API.

SearchResultBlockParam

Bases: BaseAPIType

SearchResultBlockParam from the Anthropic Messages API.

SkillParams

Bases: BaseAPIType

Specification for a skill to be loaded in a container.

StreamMessageParams

Bases: BaseAPIType

StreamMessageParams from the Anthropic Messages API.

Attributes:

Name Type Description
container Annotated[ContainerParams | str | None | MISSING, Field(title='Container')]

Container parameters with skills to be loaded.

diagnostics DiagnosticsParam | None | MISSING

Request-level diagnostics.

SystemMessageParam

Bases: BaseAPIType

SystemMessageParam from the Anthropic Messages API.

TextBlock

Bases: BaseAPIType

TextBlock from the Anthropic Messages API.

TextBlockParam

Bases: BaseAPIType

TextBlockParam from the Anthropic Messages API.

ThinkingBlock

Bases: BaseAPIType

ThinkingBlock from the Anthropic Messages API.

ThinkingBlockParam

Bases: BaseAPIType

ThinkingBlockParam from the Anthropic Messages API.

ThinkingConfigAdaptiveParam

Bases: BaseAPIType

ThinkingConfigAdaptiveParam from the Anthropic Messages API.

ThinkingConfigDisabledParam

Bases: BaseAPIType

ThinkingConfigDisabledParam from the Anthropic Messages API.

ThinkingConfigEnabledParam

Bases: BaseAPIType

ThinkingConfigEnabledParam from the Anthropic Messages API.

ToolResultBlockParam

Bases: BaseAPIType

ToolResultBlockParam from the Anthropic Messages API.

UserMessageParam

Bases: BaseAPIType

UserMessageParam from the Anthropic Messages API.

WebFetchBlockParam

Bases: BaseAPIType

WebFetchBlockParam from the Anthropic Messages API.

WebFetchToolResultBlockParam

Bases: BaseAPIType

WebFetchToolResultBlockParam from the Anthropic Messages API.

Base64PDFSourceParam

Bases: BaseAPIType

Base64PDFSourceParam from the Anthropic Messages API.

CacheControlEphemeralParam

Bases: BaseAPIType

CacheControlEphemeralParam from the Anthropic Messages API.

CitationCharLocationParam

Bases: BaseAPIType

CitationCharLocationParam from the Anthropic Messages API.

CitationPageLocationParam

Bases: BaseAPIType

CitationPageLocationParam from the Anthropic Messages API.

CitationsConfigParam

Bases: BaseAPIType

CitationsConfigParam from the Anthropic Messages API.

CitationSearchResultLocationParam

Bases: BaseAPIType

CitationSearchResultLocationParam.

CitationWebSearchResultLocationParam

Bases: BaseAPIType

CitationWebSearchResultLocationParam.

ContainerUploadBlockParam

Bases: BaseAPIType

ContainerUploadBlockParam from the Anthropic Messages API.

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.

PlainTextSourceParam

Bases: BaseAPIType

PlainTextSourceParam from the Anthropic Messages API.

URLPDFSourceParam

Bases: BaseAPIType

URLPDFSourceParam from the Anthropic Messages API.

Base64PDFSource

Bases: BaseAPIType

Base64PDFSource from the Anthropic Messages API.

BashCodeExecutionOutputBlock

Bases: BaseAPIType

BashCodeExecutionOutputBlock from the Anthropic Messages API.

BashCodeExecutionOutputBlockParam

Bases: BaseAPIType

BashCodeExecutionOutputBlockParam.

BashCodeExecutionResultBlock

Bases: BaseAPIType

BashCodeExecutionResultBlock from the Anthropic Messages API.

BashCodeExecutionResultBlockParam

Bases: BaseAPIType

BashCodeExecutionResultBlockParam.

BashCodeExecutionToolResultBlock

Bases: BaseAPIType

BashCodeExecutionToolResultBlock.

BashCodeExecutionToolResultBlockParam

Bases: BaseAPIType

BashCodeExecutionToolResultBlockParam.

BashCodeExecutionToolResultErrorObject

Bases: BaseAPIType

BashCodeExecutionToolResultErrorObject.

BashCodeExecutionToolResultErrorParam

Bases: BaseAPIType

BashCodeExecutionToolResultErrorParam.

BrowserCloseTabConfigParam

Bases: BaseAPIType

close_tab's config overrides.

BrowserDoubleClickConfigParam

Bases: BaseAPIType

double_click's config overrides.

BrowserFindConfigParam

Bases: BaseAPIType

find's config overrides.

BrowserFormInputConfigParam

Bases: BaseAPIType

form_input's config overrides.

BrowserGetPageTextConfigParam

Bases: BaseAPIType

get_page_text's config overrides.

BrowserHoldKeyConfigParam

Bases: BaseAPIType

hold_key's config overrides.

BrowserHoverConfigParam

Bases: BaseAPIType

hover's config overrides.

BrowserJavascriptExecConfigParam

Bases: BaseAPIType

javascript_exec's config overrides.

BrowserKeyConfigParam

Bases: BaseAPIType

key's config overrides.

BrowserLeftClickConfigParam

Bases: BaseAPIType

left_click's config overrides.

BrowserLeftClickDragConfigParam

Bases: BaseAPIType

left_click_drag's config overrides.

BrowserLeftMouseDownConfigParam

Bases: BaseAPIType

left_mouse_down's config overrides.

BrowserLeftMouseUpConfigParam

Bases: BaseAPIType

left_mouse_up's config overrides.

BrowserListTabsConfigParam

Bases: BaseAPIType

list_tabs's config overrides.

BrowserMiddleClickConfigParam

Bases: BaseAPIType

middle_click's config overrides.

BrowserMouseMoveConfigParam

Bases: BaseAPIType

mouse_move's config overrides.

BrowserNavigateConfigParam

Bases: BaseAPIType

navigate's config overrides.

BrowserNewTabConfigParam

Bases: BaseAPIType

new_tab's config overrides.

BrowserReadConsoleConfigParam

Bases: BaseAPIType

read_console's config overrides.

BrowserReadNetworkConfigParam

Bases: BaseAPIType

read_network's config overrides.

BrowserReadPageConfigParam

Bases: BaseAPIType

read_page's config overrides.

BrowserRightClickConfigParam

Bases: BaseAPIType

right_click's config overrides.

BrowserScreenshotConfigParam

Bases: BaseAPIType

screenshot's config overrides.

BrowserScrollConfigParam

Bases: BaseAPIType

scroll's config overrides.

BrowserScrollToConfigParam

Bases: BaseAPIType

scroll_to's config overrides.

BrowserStateBlockParam

Bases: BaseAPIType

BrowserStateBlockParam from the Anthropic Messages API.

The caller's browser state after a browser toolset member call — the full inventory of open tabs, which tab is active, and any side effects (tabs opened, download state changes) the call produced.

At most one per tool_result, only on a non-error result answering a browser toolset member tool_use. The server renders the model-visible text from it; the model never sees the raw fields.

Attributes:

Name Type Description
tabs Annotated[list[BrowserStateTabEntryParam], Field(title='Tabs')]

One open browser tab reported in a browser_state block's tabs inventory.

BrowserStateChangeDownloadCompletedParam

Bases: BaseAPIType

BrowserStateChangeDownloadCompletedParam.

A file download that finished during this call, reported with the same download_id as its download_started — or without a prior download_started, when the download finished during the call that started it (at most one state change per download_id per result).

BrowserStateChangeDownloadFailedParam

Bases: BaseAPIType

BrowserStateChangeDownloadFailedParam.

A file download that failed — or was cancelled — during this call.

BrowserStateChangeDownloadStartedParam

Bases: BaseAPIType

A file download that started during this call.

BrowserStateChangeTabOpenedParam

Bases: BaseAPIType

BrowserStateChangeTabOpenedParam.

A tab this call's execution opened that remains open at its end — the creation delta of the tabs inventory, not an event log.

Carries only the tab_id; the tab's title and url live on its tabs entry, which must include the same tab_id. A tab opened during a failed call gets no deferred tab_opened; it simply appears in the next result's tabs inventory.

BrowserStateTabEntryParam

Bases: BaseAPIType

BrowserStateTabEntryParam from the Anthropic Messages API.

One open browser tab reported in a browser_state block's tabs inventory.

tab_id is the caller-assigned identifier for the tab; title and url describe the page the tab is currently showing and may be empty strings (a blank tab legitimately has both empty). active marks the tab that is active after this call; whenever tabs is non-empty, exactly one entry is marked.

BrowserSwitchTabConfigParam

Bases: BaseAPIType

switch_tab's config overrides.

BrowserToolset20260801Param

Bases: BaseAPIType

BrowserToolset20260801Param from the Anthropic Messages API.

The browser toolset: a single tools[] entry (carrying no name) that declares the browser tool family. The model is served the family's tool with any members disabled via configs removed from its schema.

Attributes:

Name Type Description
configs BrowserToolsetConfigsParam | None | MISSING

Per-member configuration for browser_toolset_20260801: one optional field per member tool, keyed by the member name — the same name the member's tool_use blocks carry. Every member is an accepted key, and a member's defaults apply wherever its key is absent. Unknown keys are rejected: the field set is this toolset version's complete member set.

BrowserToolsetConfigsParam

Bases: BaseAPIType

BrowserToolsetConfigsParam from the Anthropic Messages API.

Per-member configuration for browser_toolset_20260801: one optional field per member tool, keyed by the member name — the same name the member's tool_use blocks carry. Every member is an accepted key, and a member's defaults apply wherever its key is absent. Unknown keys are rejected: the field set is this toolset version's complete member set.

Attributes:

Name Type Description
close_tab BrowserCloseTabConfigParam | None | MISSING

close_tab's config overrides.

double_click BrowserDoubleClickConfigParam | None | MISSING

double_click's config overrides.

file_upload BrowserFileUploadConfigParam | None | MISSING

file_upload's config overrides.

find BrowserFindConfigParam | None | MISSING

find's config overrides.

form_input BrowserFormInputConfigParam | None | MISSING

form_input's config overrides.

get_page_text BrowserGetPageTextConfigParam | None | MISSING

get_page_text's config overrides.

hold_key BrowserHoldKeyConfigParam | None | MISSING

hold_key's config overrides.

hover BrowserHoverConfigParam | None | MISSING

hover's config overrides.

javascript_exec BrowserJavascriptExecConfigParam | None | MISSING

javascript_exec's config overrides.

key BrowserKeyConfigParam | None | MISSING

key's config overrides.

left_click BrowserLeftClickConfigParam | None | MISSING

left_click's config overrides.

left_click_drag BrowserLeftClickDragConfigParam | None | MISSING

left_click_drag's config overrides.

left_mouse_down BrowserLeftMouseDownConfigParam | None | MISSING

left_mouse_down's config overrides.

left_mouse_up BrowserLeftMouseUpConfigParam | None | MISSING

left_mouse_up's config overrides.

list_tabs BrowserListTabsConfigParam | None | MISSING

list_tabs's config overrides.

middle_click BrowserMiddleClickConfigParam | None | MISSING

middle_click's config overrides.

mouse_move BrowserMouseMoveConfigParam | None | MISSING

mouse_move's config overrides.

navigate BrowserNavigateConfigParam | None | MISSING

navigate's config overrides.

new_tab BrowserNewTabConfigParam | None | MISSING

new_tab's config overrides.

read_console BrowserReadConsoleConfigParam | None | MISSING

read_console's config overrides.

read_network BrowserReadNetworkConfigParam | None | MISSING

read_network's config overrides.

read_page BrowserReadPageConfigParam | None | MISSING

read_page's config overrides.

right_click BrowserRightClickConfigParam | None | MISSING

right_click's config overrides.

screenshot BrowserScreenshotConfigParam | None | MISSING

screenshot's config overrides.

scroll BrowserScrollConfigParam | None | MISSING

scroll's config overrides.

scroll_to BrowserScrollToConfigParam | None | MISSING

scroll_to's config overrides.

switch_tab BrowserSwitchTabConfigParam | None | MISSING

switch_tab's config overrides.

triple_click BrowserTripleClickConfigParam | None | MISSING

triple_click's config overrides.

type BrowserTypeConfigParam | None | MISSING

type's config overrides.

wait BrowserWaitConfigParam | None | MISSING

wait's config overrides.

zoom BrowserZoomConfigParam | None | MISSING

zoom's config overrides.

BrowserTripleClickConfigParam

Bases: BaseAPIType

triple_click's config overrides.

BrowserTypeConfigParam

Bases: BaseAPIType

type's config overrides.

BrowserWaitConfigParam

Bases: BaseAPIType

wait's config overrides.

BrowserZoomConfigParam

Bases: BaseAPIType

zoom's config overrides.

CitationsConfig

Bases: BaseAPIType

CitationsConfig from the Anthropic Messages API.

CodeExecutionOutputBlock

Bases: BaseAPIType

CodeExecutionOutputBlock from the Anthropic Messages API.

CodeExecutionOutputBlockParam

Bases: BaseAPIType

CodeExecutionOutputBlockParam from the Anthropic Messages API.

CodeExecutionResultBlock

Bases: BaseAPIType

CodeExecutionResultBlock from the Anthropic Messages API.

CodeExecutionResultBlockParam

Bases: BaseAPIType

CodeExecutionResultBlockParam from the Anthropic Messages API.

CodeExecutionTool20250522Param

Bases: BaseAPIType

CodeExecutionTool20250522Param from the Anthropic Messages API.

CodeExecutionTool20250825Param

Bases: BaseAPIType

CodeExecutionTool20250825Param from the Anthropic Messages API.

CodeExecutionTool20260120Param

Bases: BaseAPIType

CodeExecutionTool20260120Param from the Anthropic Messages API.

A tools entry for the code execution tool, version code_execution_20260120.

It adds REPL state persistence to version code_execution_20250825.

REPL state persistence applies with programmatic tool calling. With it, the Python interpreter state, such as variable bindings, persists across requests that reuse the container.

See the code execution tool guide to learn what each tool version adds.

CodeExecutionTool20260521Param

Bases: BaseAPIType

Code execution tool with REPL state persistence.

CodeExecutionToolResultBlock

Bases: BaseAPIType

CodeExecutionToolResultBlock from the Anthropic Messages API.

Attributes:

Name Type Description
content Annotated[CodeExecutionToolResultErrorObject | CodeExecutionResultBlock | EncryptedCodeExecutionResultBlock, Field(title='Content')]

The output and exit code of Python code that Claude ran with the code execution tool, with standard output in encrypted form.

CodeExecutionToolResultBlockParam

Bases: BaseAPIType

CodeExecutionToolResultBlockParam.

Attributes:

Name Type Description
content Annotated[CodeExecutionToolResultErrorParam | CodeExecutionResultBlockParam | EncryptedCodeExecutionResultBlockParam, Field(title='Content')]

The output and exit code of Python code that Claude ran with the code execution tool, with standard output in encrypted form, sent back in a later request.

CodeExecutionToolResultErrorObject

Bases: BaseAPIType

CodeExecutionToolResultErrorObject.

CodeExecutionToolResultErrorParam

Bases: BaseAPIType

CodeExecutionToolResultErrorParam.

ComputerCursorPositionConfigParam

Bases: BaseAPIType

cursor_position's config overrides.

ComputerDoubleClickConfigParam

Bases: BaseAPIType

double_click's config overrides.

ComputerHoldKeyConfigParam

Bases: BaseAPIType

hold_key's config overrides.

ComputerKeyConfigParam

Bases: BaseAPIType

key's config overrides.

ComputerLeftClickConfigParam

Bases: BaseAPIType

left_click's config overrides.

ComputerLeftClickDragConfigParam

Bases: BaseAPIType

left_click_drag's config overrides.

ComputerLeftMouseDownConfigParam

Bases: BaseAPIType

left_mouse_down's config overrides.

ComputerLeftMouseUpConfigParam

Bases: BaseAPIType

left_mouse_up's config overrides.

ComputerMiddleClickConfigParam

Bases: BaseAPIType

middle_click's config overrides.

ComputerMouseMoveConfigParam

Bases: BaseAPIType

mouse_move's config overrides.

ComputerRightClickConfigParam

Bases: BaseAPIType

right_click's config overrides.

ComputerScreenshotConfigParam

Bases: BaseAPIType

screenshot's config overrides.

ComputerScrollConfigParam

Bases: BaseAPIType

scroll's config overrides.

ComputerToolset20260801Param

Bases: BaseAPIType

ComputerToolset20260801Param from the Anthropic Messages API.

The computer toolset: a single tools[] entry (carrying no name) that declares the computer tool family. The model is served the family's tool with any members disabled via configs removed from its schema. Every member is enabled by default, zoom included. The single-tool options display_number and enable_zoom are not fields of a toolset entry — it carries only type, configs, and cache_control; zoom is controlled via configs.zoom.enabled.

Attributes:

Name Type Description
configs ComputerToolsetConfigsParam | None | MISSING

Per-member configuration for computer_toolset_20260801: one optional field per member tool, keyed by the member name — the same name the member's tool_use blocks carry. Every member is an accepted key, and a member's defaults apply wherever its key is absent. Unknown keys are rejected: the field set is this toolset version's complete member set.

ComputerToolsetConfigsParam

Bases: BaseAPIType

ComputerToolsetConfigsParam from the Anthropic Messages API.

Per-member configuration for computer_toolset_20260801: one optional field per member tool, keyed by the member name — the same name the member's tool_use blocks carry. Every member is an accepted key, and a member's defaults apply wherever its key is absent. Unknown keys are rejected: the field set is this toolset version's complete member set.

Attributes:

Name Type Description
cursor_position ComputerCursorPositionConfigParam | None | MISSING

cursor_position's config overrides.

double_click ComputerDoubleClickConfigParam | None | MISSING

double_click's config overrides.

hold_key ComputerHoldKeyConfigParam | None | MISSING

hold_key's config overrides.

key ComputerKeyConfigParam | None | MISSING

key's config overrides.

left_click ComputerLeftClickConfigParam | None | MISSING

left_click's config overrides.

left_click_drag ComputerLeftClickDragConfigParam | None | MISSING

left_click_drag's config overrides.

left_mouse_down ComputerLeftMouseDownConfigParam | None | MISSING

left_mouse_down's config overrides.

left_mouse_up ComputerLeftMouseUpConfigParam | None | MISSING

left_mouse_up's config overrides.

middle_click ComputerMiddleClickConfigParam | None | MISSING

middle_click's config overrides.

mouse_move ComputerMouseMoveConfigParam | None | MISSING

mouse_move's config overrides.

right_click ComputerRightClickConfigParam | None | MISSING

right_click's config overrides.

screenshot ComputerScreenshotConfigParam | None | MISSING

screenshot's config overrides.

scroll ComputerScrollConfigParam | None | MISSING

scroll's config overrides.

triple_click ComputerTripleClickConfigParam | None | MISSING

triple_click's config overrides.

type ComputerTypeConfigParam | None | MISSING

type's config overrides.

wait ComputerWaitConfigParam | None | MISSING

wait's config overrides.

zoom ComputerZoomConfigParam | None | MISSING

zoom's config overrides.

ComputerTripleClickConfigParam

Bases: BaseAPIType

triple_click's config overrides.

ComputerTypeConfigParam

Bases: BaseAPIType

type's config overrides.

ComputerWaitConfigParam

Bases: BaseAPIType

wait's config overrides.

ComputerZoomConfigParam

Bases: BaseAPIType

zoom's config overrides.

DirectCaller

Bases: BaseAPIType

Tool invocation directly from the model.

DirectCallerParam

Bases: BaseAPIType

Tool invocation directly from the model.

DocumentBlock

Bases: BaseAPIType

DocumentBlock from the Anthropic Messages API.

EncryptedCodeExecutionResultBlock

Bases: BaseAPIType

EncryptedCodeExecutionResultBlock.

The output and exit code of Python code that Claude ran with the code execution tool, with standard output in encrypted form.

The API returns this block in place of code_execution_result when the code called the web search tool.

See the programmatic tool calling guide to learn more about programmatic tool calling.

EncryptedCodeExecutionResultBlockParam

Bases: BaseAPIType

EncryptedCodeExecutionResultBlockParam.

The output and exit code of Python code that Claude ran with the code execution tool, with standard output in encrypted form, sent back in a later request.

InputSchemaTyped

Bases: BaseAPIType

InputSchemaTyped from the Anthropic Messages API.

JSON schema for this tool's input.

This defines the shape of the input that your tool accepts and that the model will produce.

MemoryTool20250818Param

Bases: BaseAPIType

MemoryTool20250818Param from the Anthropic Messages API.

PlainTextSource

Bases: BaseAPIType

PlainTextSource from the Anthropic Messages API.

ServerToolCaller

Bases: BaseAPIType

Tool invocation generated by a server-side tool.

ServerToolCaller20260120

Bases: BaseAPIType

ServerToolCaller20260120 from the Anthropic Messages API.

ServerToolCaller20260120Param

Bases: BaseAPIType

ServerToolCaller20260120Param from the Anthropic Messages API.

ServerToolCallerParam

Bases: BaseAPIType

Tool invocation generated by a server-side tool.

ServerToolUseBlock

Bases: BaseAPIType

ServerToolUseBlock from the Anthropic Messages API.

ServerToolUseBlockParam

Bases: BaseAPIType

ServerToolUseBlockParam from the Anthropic Messages API.

TextEditorCodeExecutionCreateResultBlock

Bases: BaseAPIType

TextEditorCodeExecutionCreateResultBlock.

TextEditorCodeExecutionCreateResultBlockParam

Bases: BaseAPIType

TextEditorCodeExecutionCreateResultBlockParam.

TextEditorCodeExecutionStrReplaceResultBlock

Bases: BaseAPIType

TextEditorCodeExecutionStrReplaceResultBlock.

TextEditorCodeExecutionStrReplaceResultBlockParam

Bases: BaseAPIType

TextEditorCodeExecutionStrReplaceResultBlockParam.

TextEditorCodeExecutionToolResultBlock

Bases: BaseAPIType

TextEditorCodeExecutionToolResultBlock.

TextEditorCodeExecutionToolResultBlockParam

Bases: BaseAPIType

TextEditorCodeExecutionToolResultBlockParam.

TextEditorCodeExecutionToolResultErrorObject

Bases: BaseAPIType

TextEditorCodeExecutionToolResultErrorObject.

TextEditorCodeExecutionToolResultErrorParam

Bases: BaseAPIType

TextEditorCodeExecutionToolResultErrorParam.

TextEditorCodeExecutionViewResultBlock

Bases: BaseAPIType

TextEditorCodeExecutionViewResultBlock.

TextEditorCodeExecutionViewResultBlockParam

Bases: BaseAPIType

TextEditorCodeExecutionViewResultBlockParam.

ThinkingConfigBetweenToolsParam

Bases: BaseAPIType

ThinkingConfigBetweenToolsParam.

ToolBash20250124Param

Bases: BaseAPIType

ToolBash20250124Param from the Anthropic Messages API.

ToolChoiceAnyParam

Bases: BaseAPIType

The model will use any available tools.

ToolChoiceAutoParam

Bases: BaseAPIType

The model will automatically decide whether to use tools.

ToolChoiceNoneParam

Bases: BaseAPIType

The model will not be allowed to use tools.

ToolChoiceToolParam

Bases: BaseAPIType

The model will use the specified tool with tool_choice.name.

ToolParam

Bases: BaseAPIType

ToolParam from the Anthropic Messages API.

Attributes:

Name Type Description
input_schema Annotated[InputSchemaTyped | dict[str, Any], Field(title='Input Schema')]

JSON schema for this tool's input.

ToolReferenceBlock

Bases: BaseAPIType

ToolReferenceBlock from the Anthropic Messages API.

ToolReferenceBlockParam

Bases: BaseAPIType

Tool reference block that can be included in tool_result content.

ToolSearchToolBm2520251119Param

Bases: BaseAPIType

ToolSearchToolBm2520251119Param.

ToolSearchToolRegex20251119Param

Bases: BaseAPIType

ToolSearchToolRegex20251119Param.

ToolSearchToolResultBlock

Bases: BaseAPIType

ToolSearchToolResultBlock from the Anthropic Messages API.

ToolSearchToolResultBlockParam

Bases: BaseAPIType

ToolSearchToolResultBlockParam from the Anthropic Messages API.

ToolSearchToolResultErrorObject

Bases: BaseAPIType

ToolSearchToolResultErrorObject.

ToolSearchToolResultErrorParam

Bases: BaseAPIType

ToolSearchToolResultErrorParam from the Anthropic Messages API.

ToolSearchToolSearchResultBlock

Bases: BaseAPIType

ToolSearchToolSearchResultBlock.

ToolSearchToolSearchResultBlockParam

Bases: BaseAPIType

ToolSearchToolSearchResultBlockParam.

Attributes:

Name Type Description
tool_references Annotated[list[ToolReferenceBlockParam], Field(title='Tool References')]

Tool reference block that can be included in tool_result content.

ToolTextEditor20250124Param

Bases: BaseAPIType

ToolTextEditor20250124Param from the Anthropic Messages API.

ToolTextEditor20250429Param

Bases: BaseAPIType

ToolTextEditor20250429Param from the Anthropic Messages API.

ToolTextEditor20250728Param

Bases: BaseAPIType

ToolTextEditor20250728Param from the Anthropic Messages API.

ToolUseBlock

Bases: BaseAPIType

ToolUseBlock from the Anthropic Messages API.

ToolUseBlockParam

Bases: BaseAPIType

ToolUseBlockParam from the Anthropic Messages API.

UserLocationParam

Bases: BaseAPIType

UserLocationParam from the Anthropic Messages API.

WebFetchBlock

Bases: BaseAPIType

WebFetchBlock from the Anthropic Messages API.

WebFetchTool20250910Param

Bases: BaseAPIType

WebFetchTool20250910Param from the Anthropic Messages API.

Attributes:

Name Type Description
url_sources WebFetchURLSourcesParam | None | MISSING

Which sources contribute to the set of URLs web fetch may fetch.

WebFetchTool20260209Param

Bases: BaseAPIType

WebFetchTool20260209Param from the Anthropic Messages API.

Attributes:

Name Type Description
url_sources WebFetchURLSourcesParam | None | MISSING

Which sources contribute to the set of URLs web fetch may fetch.

WebFetchTool20260309Param

Bases: BaseAPIType

WebFetchTool20260309Param from the Anthropic Messages API.

Web fetch tool with use_cache parameter for bypassing cached content.

Attributes:

Name Type Description
url_sources WebFetchURLSourcesParam | None | MISSING

Which sources contribute to the set of URLs web fetch may fetch.

WebFetchTool20260318Param

Bases: BaseAPIType

WebFetchTool20260318Param from the Anthropic Messages API.

Attributes:

Name Type Description
url_sources WebFetchURLSourcesParam | None | MISSING

Which sources contribute to the set of URLs web fetch may fetch.

WebFetchToolResultBlock

Bases: BaseAPIType

WebFetchToolResultBlock from the Anthropic Messages API.

WebFetchToolResultErrorBlock

Bases: BaseAPIType

WebFetchToolResultErrorBlock from the Anthropic Messages API.

WebFetchToolResultErrorBlockParam

Bases: BaseAPIType

WebFetchToolResultErrorBlockParam.

WebFetchURLSourceAllParam

Bases: BaseAPIType

WebFetchURLSourceAllParam from the Anthropic Messages API.

The url_sources variant under which a source contributes in full: every result of the tool filter's source, or all user input.

WebFetchURLSourceExceptParam

Bases: BaseAPIType

WebFetchURLSourceExceptParam from the Anthropic Messages API.

The tool filter variant under which every result but the named tools' contributes.

Attributes:

Name Type Description
tools Annotated[list[WebFetchURLSourceToolReferenceParam], Field(title='Tools')]

One entry of a tool filter's tools: it must name a tool declared in this request's tools[].

WebFetchURLSourceNoneParam

Bases: BaseAPIType

WebFetchURLSourceNoneParam from the Anthropic Messages API.

The url_sources variant under which a source contributes nothing: no result of the tool filter's source, or no user input.

WebFetchURLSourceOnlyParam

Bases: BaseAPIType

WebFetchURLSourceOnlyParam from the Anthropic Messages API.

The tool filter variant under which only the named tools' results contribute.

Attributes:

Name Type Description
tools Annotated[list[WebFetchURLSourceToolReferenceParam], Field(title='Tools')]

One entry of a tool filter's tools: it must name a tool declared in this request's tools[].

WebFetchURLSourcesParam

Bases: BaseAPIType

Which sources contribute to the set of URLs web fetch may fetch.

Each key is a tagged variant: user_input is all or none; the two tool filters are all, none, only (only the named tools' results) or except (every result but the named tools'). A named tool must be declared in this request's tools[].

WebFetchURLSourceToolReferenceParam

Bases: BaseAPIType

WebFetchURLSourceToolReferenceParam.

One entry of a tool filter's tools: it must name a tool declared in this request's tools[].

WebSearchResultBlock

Bases: BaseAPIType

WebSearchResultBlock from the Anthropic Messages API.

WebSearchResultBlockParam

Bases: BaseAPIType

WebSearchResultBlockParam from the Anthropic Messages API.

WebSearchTool20250305Param

Bases: BaseAPIType

WebSearchTool20250305Param from the Anthropic Messages API.

WebSearchTool20260209Param

Bases: BaseAPIType

WebSearchTool20260209Param from the Anthropic Messages API.

WebSearchTool20260318Param

Bases: BaseAPIType

WebSearchTool20260318Param from the Anthropic Messages API.

WebSearchToolRequestErrorObjectParam

Bases: BaseAPIType

WebSearchToolRequestErrorObjectParam.

WebSearchToolResultBlock

Bases: BaseAPIType

WebSearchToolResultBlock from the Anthropic Messages API.

WebSearchToolResultBlockParam

Bases: BaseAPIType

WebSearchToolResultBlockParam from the Anthropic Messages API.

WebSearchToolResultErrorObject

Bases: BaseAPIType

WebSearchToolResultErrorObject from the Anthropic Messages API.

adapters

Anthropic's adapters between shared types and its methods.

Modules:

Name Description
conversions

Conversions of Anthropic's Messages types into shared types.

files

Adapter of shared files to Anthropic's Files API.

generation

Adapter of shared generation to Anthropic's Messages API.

Classes:

Name Description
AnthropicFilesAdapter

Stores files with Anthropic's /files.

AnthropicGenerationAdapter

Generates text with POST /messages.

Functions:

Name Description
message_text

Join the text of a message.

message_thinking

Join the thinking of a message.

message_tool_calls

Collect the tool calls of a message.

AnthropicFilesAdapter

AnthropicFilesAdapter(
    *, page_size: int = DEFAULT_PAGE_SIZE
)

Bases: BaseFilesAdapter[FileMetadata, ListFilesResponse]

Stores files with Anthropic's /files.

expires_in_seconds is sent as it is. The list goes newest first, page_size files a request, by the opaque next_page. Uploads take no provider options.

Attributes:

Name Type Description
page_size

Files asked for in one page of the list, 1 to 1000.

Example

files = FilesResource(session, AnthropicFilesAdapter()) stored = await files.upload(Path("report.pdf"))

Store the page size.

Parameters:

Name Type Description Default
page_size int

Files asked for in one page of the list.

DEFAULT_PAGE_SIZE

Methods:

Name Description
with_options

Check that no option is given; Anthropic's uploads take none.

to_upload_method

Build the method that stores a file.

to_retrieve_method

Build the method that reads a file's metadata.

to_list_method

Build the method that reads one page of the stored files.

to_page

Take the files of a page and where the next one starts.

to_delete_method

Build the method that deletes a file.

to_download_method

Build the method that streams a file's content.

to_stored_file

Convert Anthropic's file metadata into the shared metadata.

with_options

with_options(options: NoProviderOptions) -> Self

Check that no option is given; Anthropic's uploads take none.

Parameters:

Name Type Description Default
options NoProviderOptions

The call's provider options, which must be empty.

required

Returns:

Type Description
Self

A copy of the adapter.

Raises:

Type Description
RequestValidationError

A key is given.

to_upload_method

to_upload_method(request: FileUpload) -> CreateFile

Build the method that stores a file.

Parameters:

Name Type Description Default
request FileUpload

The shared upload.

required

Returns:

Type Description
CreateFile

CreateFile with the file and its expiry.

Raises:

Type Description
RequestValidationError

Anthropic cannot take the upload, such as an expiry outside 3600 to 7 776 000 seconds.

to_retrieve_method

to_retrieve_method(file_id: str) -> RetrieveFile

Build the method that reads a file's metadata.

Parameters:

Name Type Description Default
file_id str

Anthropic's id of the file.

required

Returns:

Type Description
RetrieveFile

RetrieveFile.

to_list_method

to_list_method(cursor: str | None) -> ListFiles

Build the method that reads one page of the stored files.

Parameters:

Name Type Description Default
cursor str | None

next_page of the page before, or None for the first page.

required

Returns:

Type Description
ListFiles

ListFiles of page_size files.

to_page

to_page(
    raw: ListFilesResponse,
) -> tuple[Sequence[FileMetadata], str | None]

Take the files of a page and where the next one starts.

Parameters:

Name Type Description Default
raw ListFilesResponse

The page.

required

Returns:

Type Description
tuple[Sequence[FileMetadata], str | None]

Its files and its next_page.

to_delete_method

to_delete_method(file_id: str) -> DeleteFile

Build the method that deletes a file.

Parameters:

Name Type Description Default
file_id str

Anthropic's id of the file.

required

Returns:

Type Description
DeleteFile

DeleteFile.

to_download_method

to_download_method(file: ProviderFile) -> DownloadFile

Build the method that streams a file's content.

Anthropic keeps the files its code makes with the stored files, so a ProducedFile of the Messages API downloads as any other.

Parameters:

Name Type Description Default
file ProviderFile

The file.

required

Returns:

Type Description
DownloadFile

DownloadFile; Anthropic refuses a file it did not make

DownloadFile

(downloadable false).

Raises:

Type Description
RequestValidationError

The file names a container (ProducedFile.container_id): Anthropic serves no file from a container.

to_stored_file

to_stored_file(
    raw: FileMetadata,
) -> StoredFile[FileMetadata]

Convert Anthropic's file metadata into the shared metadata.

Parameters:

Name Type Description Default
raw FileMetadata

Anthropic's metadata.

required

Returns:

Type Description
StoredFile[FileMetadata]

Its id, name, size_bytes as size and its times in

StoredFile[FileMetadata]

UTC.

AnthropicGenerationAdapter

AnthropicGenerationAdapter(
    *,
    default_max_tokens: int = DEFAULT_MAX_TOKENS,
    input_conversion: IConversion[
        str | Sequence[InputItem], list[dict[str, Any]]
    ] = INPUT_CONVERSION,
    usage_conversion: IConversion[
        Usage, TokenUsage
    ] = USAGE_CONVERSION,
    stop_conversion: IConversion[
        Message | Delta, Stop
    ] = STOP_CONVERSION,
)

Bases: BaseCompositeAdapter[GenerationRequest, Message, GenerationResponse[Message], MessageStreamEvent, GenerationEvent[MessageStreamEvent]]

Generates text with POST /messages.

A text input becomes one user turn, a list of turns the messages as they are, and instructions the system prompt. Anthropic requires max_tokens, so a request without max_output_tokens gets default_max_tokens. A request that Anthropic would reject raises RequestValidationError before anything is sent, such as a conversation that does not end with a user turn. end_user_id becomes metadata.user_id.

The conversions of the input, the token counts and the stop are keyword arguments, so any of them can be swapped without a subclass; a stream goes through the same ones as a message.

Attributes:

Name Type Description
default_max_tokens

max_tokens of a request without max_output_tokens.

input_conversion

Turns the shared input into messages.

usage_conversion

Turns Anthropic's Usage into shared counts.

stop_conversion

Tells how a message, or a stream, stopped.

Example

generation = GenerationResource( ... session, AnthropicGenerationAdapter(default_max_tokens=4096) ... )

Store the default token limit and the conversions.

Parameters:

Name Type Description Default
default_max_tokens int

max_tokens of a request without max_output_tokens; positive.

DEFAULT_MAX_TOKENS
input_conversion IConversion[str | Sequence[InputItem], list[dict[str, Any]]]

Turns the shared input into messages.

INPUT_CONVERSION
usage_conversion IConversion[Usage, TokenUsage]

Turns Anthropic's Usage into shared counts.

USAGE_CONVERSION
stop_conversion IConversion[Message | Delta, Stop]

Tells how a message, or a stream, stopped.

STOP_CONVERSION

Raises:

Type Description
ValueError

If default_max_tokens is not positive.

Methods:

Name Description
with_options

Return a copy that sends the options with every method.

to_method

Build the method that creates a message at once.

to_response

Convert a finished message.

to_stream_method

Build the method that streams a message.

to_events

Convert the events of a message stream.

with_options

with_options(options: AnthropicGenerationOptions) -> Self

Return a copy that sends the options with every method.

Parameters:

Name Type Description Default
options AnthropicGenerationOptions

Fields of CreateMessage that the shared request does not hold, such as {"stop_sequences": ["END"]}.

required

Returns:

Type Description
Self

A copy of the adapter; this one is left as it is.

Raises:

Type Description
RequestValidationError

A key is not one of the options.

to_method

to_method(request: GenerationRequest) -> CreateMessage

Build the method that creates a message at once.

Parameters:

Name Type Description Default
request GenerationRequest

The shared request.

required

Returns:

Type Description
CreateMessage

CreateMessage for the request.

Raises:

Type Description
RequestValidationError

Anthropic cannot take the request.

to_response

to_response(
    raw: Message, request: GenerationRequest
) -> GenerationResponse[Message]

Convert a finished message.

Parameters:

Name Type Description Default
raw Message

Anthropic's message.

required
request GenerationRequest

The request it answers.

required

Returns:

Type Description
GenerationResponse[Message]

The generated text with its token counts, the calls of the

GenerationResponse[Message]

built-in tools Anthropic ran (server_tool_calls), the

GenerationResponse[Message]

sources its text cites (citations) and the files its code

GenerationResponse[Message]

made (files); a message stopped

GenerationResponse[Message]

early, by max_tokens for example, keeps its text and gets

GenerationResponse[Message]

incomplete_reason (PAUSED for pause_turn), and a

GenerationResponse[Message]

refusal gets refusal.

Raises:

Type Description
APIResponseError

The message has no stop reason.

to_stream_method

to_stream_method(
    request: GenerationRequest,
) -> StreamMessage

Build the method that streams a message.

Parameters:

Name Type Description Default
request GenerationRequest

The shared request.

required

Returns:

Type Description
StreamMessage

StreamMessage for the request.

Raises:

Type Description
RequestValidationError

Anthropic cannot take the request.

to_events async

to_events(
    items: AsyncIterator[MessageStreamEvent],
    request: GenerationRequest,
) -> AsyncGenerator[GenerationEvent[MessageStreamEvent]]

Convert the events of a message stream.

Text deltas become TextDeltaEvent and non-empty thinking deltas ReasoningDeltaEvent; a tool_use block becomes ToolCallStartEvent, a ToolCallDeltaEvent per input_json_delta and ToolCallDoneEvent at its content_block_stop; a built-in tool's server_tool_use block becomes a ServerToolCallEvent that starts the call and its result block one that ends it; message_stop becomes CompletedEvent with the counts and stop reason collected from message_start and message_delta, the built-in tool calls, citations and files, and the content as native; every other event (the pieces of a built-in tool's input, citations) is an OtherEvent.

Parameters:

Name Type Description Default
items AsyncIterator[MessageStreamEvent]

The events Anthropic sent.

required
request GenerationRequest

The request the stream answers.

required

Yields:

Type Description
AsyncGenerator[GenerationEvent[MessageStreamEvent]]

One shared event per Anthropic event.

Raises:

Type Description
APIResponseError

message_stop came without a stop reason or without message_start, or arguments came for a block no tool_use or server_tool_use opened. The stream's end is checked by StreamMessage and by the use case.

message_text

message_text(message: Message) -> str | None

Join the text of a message.

Parameters:

Name Type Description Default
message Message

A message.

required

Returns:

Type Description
str | None

The text of all text blocks, or None if there are none.

message_thinking

message_thinking(message: Message) -> str | None

Join the thinking of a message.

Parameters:

Name Type Description Default
message Message

A message.

required

Returns:

Type Description
str | None

The text of all thinking blocks, or None if there are

str | None

none or all are empty (thinking whose display is omitted).

message_tool_calls

message_tool_calls(message: Message) -> list[ToolCall]

Collect the tool calls of a message.

Parameters:

Name Type Description Default
message Message

A message.

required

Returns:

Type Description
list[ToolCall]

A shared call per tool_use block, in content order; empty

list[ToolCall]

without calls.

types

Anthropic's own types and the options of a generation call.

Every module but options is written by aiollm-codegen through scripts/generate_types.py; do not edit them by hand.

Modules:

Name Description
events

Provider events types generated from OpenAPI.

files

Provider files types generated from OpenAPI.

messages

Provider messages types generated from OpenAPI.

options

Anthropic's own options of a generation call.

shared

Provider shared types generated from OpenAPI.

tools

Provider tools types generated from OpenAPI.

usage

Provider usage types generated from OpenAPI.

Classes:

Name Description
AnthropicGenerationOptions

Fields of POST /v1/messages that the shared request does not hold.

ThinkingAdaptive

The model decides how much it thinks.

ThinkingBetweenTools

Thinking only between tool calls.

ThinkingDisabled

No thinking, on the models that allow it.

ThinkingEnabled

Thinking with a fixed budget, on the models that take one.

CitationsDelta

CitationsDelta from the Anthropic Messages API.

Delta

Delta from the Anthropic Messages API (upstream: Delta).

InputJSONDelta

InputJSONDelta from the Anthropic Messages API.

RawContentBlockDeltaEvent

RawContentBlockDeltaEvent from the Anthropic Messages API.

RawContentBlockStartEvent

RawContentBlockStartEvent from the Anthropic Messages API.

RawContentBlockStopEvent

RawContentBlockStopEvent from the Anthropic Messages API.

RawMessageDeltaEvent

RawMessageDeltaEvent from the Anthropic Messages API.

RawMessageStartEvent

RawMessageStartEvent from the Anthropic Messages API.

RawMessageStopEvent

RawMessageStopEvent from the Anthropic Messages API.

SignatureDelta

SignatureDelta from the Anthropic Messages API.

TextDelta

TextDelta from the Anthropic Messages API.

ThinkingDelta

ThinkingDelta from the Anthropic Messages API.

ContainerUploadBlock

Response model for a file uploaded to the container.

DeletedFile

DeletedFile from the Anthropic Messages API.

FileMetadata

FileMetadata from the Anthropic Messages API.

ListFilesResponse

ListFilesResponse from the Anthropic Messages API.

CacheMissMessagesChanged

CacheMissMessagesChanged from the Anthropic Messages API.

CacheMissModelChanged

CacheMissModelChanged from the Anthropic Messages API.

CacheMissPreviousMessageNotFound

CacheMissPreviousMessageNotFound.

CacheMissSystemChanged

CacheMissSystemChanged from the Anthropic Messages API.

CacheMissUnavailable

A cache_miss_reason for when the API can't give a diagnosis.

CitationContentBlockLocation

CitationContentBlockLocation from the Anthropic Messages API.

Diagnostics

Diagnostics from the Anthropic Messages API.

Message

Message from the Anthropic Messages API (upstream: Message).

RefusalStopDetails

Structured information about a refusal.

TextBlock

TextBlock from the Anthropic Messages API.

CitationCharLocation

CitationCharLocation from the Anthropic Messages API.

CitationPageLocation

CitationPageLocation from the Anthropic Messages API.

CitationsSearchResultLocation

CitationsSearchResultLocation from the Anthropic Messages API.

CitationsWebSearchResultLocation

CitationsWebSearchResultLocation.

Container

Container from the Anthropic Messages API.

ContainerSkill

A skill that was loaded in a container (response model).

RedactedThinkingBlock

RedactedThinkingBlock from the Anthropic Messages API.

ThinkingBlock

ThinkingBlock from the Anthropic Messages API.

Base64PDFSource

Base64PDFSource from the Anthropic Messages API.

BashCodeExecutionOutputBlock

BashCodeExecutionOutputBlock from the Anthropic Messages API.

BashCodeExecutionResultBlock

BashCodeExecutionResultBlock from the Anthropic Messages API.

BashCodeExecutionToolResultBlock

BashCodeExecutionToolResultBlock.

BashCodeExecutionToolResultErrorObject

BashCodeExecutionToolResultErrorObject.

CacheMissToolsChanged

CacheMissToolsChanged from the Anthropic Messages API.

CitationsConfig

CitationsConfig from the Anthropic Messages API.

CodeExecutionOutputBlock

CodeExecutionOutputBlock from the Anthropic Messages API.

CodeExecutionResultBlock

CodeExecutionResultBlock from the Anthropic Messages API.

CodeExecutionToolResultBlock

CodeExecutionToolResultBlock from the Anthropic Messages API.

CodeExecutionToolResultErrorObject

CodeExecutionToolResultErrorObject.

DirectCaller

Tool invocation directly from the model.

DocumentBlock

DocumentBlock from the Anthropic Messages API.

EncryptedCodeExecutionResultBlock

EncryptedCodeExecutionResultBlock.

PlainTextSource

PlainTextSource from the Anthropic Messages API.

ServerToolCaller

Tool invocation generated by a server-side tool.

ServerToolCaller20260120

ServerToolCaller20260120 from the Anthropic Messages API.

ServerToolUseBlock

ServerToolUseBlock from the Anthropic Messages API.

TextEditorCodeExecutionCreateResultBlock

TextEditorCodeExecutionCreateResultBlock.

TextEditorCodeExecutionStrReplaceResultBlock

TextEditorCodeExecutionStrReplaceResultBlock.

TextEditorCodeExecutionToolResultBlock

TextEditorCodeExecutionToolResultBlock.

TextEditorCodeExecutionToolResultErrorObject

TextEditorCodeExecutionToolResultErrorObject.

TextEditorCodeExecutionViewResultBlock

TextEditorCodeExecutionViewResultBlock.

ToolReferenceBlock

ToolReferenceBlock from the Anthropic Messages API.

ToolSearchToolResultBlock

ToolSearchToolResultBlock from the Anthropic Messages API.

ToolSearchToolResultErrorObject

ToolSearchToolResultErrorObject.

ToolSearchToolSearchResultBlock

ToolSearchToolSearchResultBlock.

ToolUseBlock

ToolUseBlock from the Anthropic Messages API.

WebFetchBlock

WebFetchBlock from the Anthropic Messages API.

WebFetchToolResultBlock

WebFetchToolResultBlock from the Anthropic Messages API.

WebFetchToolResultErrorBlock

WebFetchToolResultErrorBlock from the Anthropic Messages API.

WebSearchResultBlock

WebSearchResultBlock from the Anthropic Messages API.

WebSearchToolResultBlock

WebSearchToolResultBlock from the Anthropic Messages API.

WebSearchToolResultErrorObject

WebSearchToolResultErrorObject from the Anthropic Messages API.

CacheCreation

CacheCreation from the Anthropic Messages API.

MessageDeltaUsage

MessageDeltaUsage from the Anthropic Messages API.

OutputTokensDetails

OutputTokensDetails from the Anthropic Messages API.

ServerToolUsage

ServerToolUsage from the Anthropic Messages API.

Usage

Usage from the Anthropic Messages API (upstream: Usage).

AnthropicGenerationOptions

Bases: TypedDict

Fields of POST /v1/messages that the shared request does not hold.

Given to client.generation.create() or stream() as provider_options; a key left out is not sent. Each key is a field of CreateMessage, its value of the field's type or a TypedDict with the same keys, so a dict literal type-checks; the method checks the value.

Attributes:

Name Type Description
stop_sequences list[str]

Texts that stop generation.

thinking ThinkingEnabled | ThinkingDisabled | ThinkingBetweenTools | ThinkingAdaptive

How the model thinks; {"type": "adaptive", "display": "summarized"} brings a summary back as GenerationResponse.reasoning and ReasoningDeltaEvent.

Example

await client.generation.create( ... model="claude-opus-5-5", ... input="Count to ten", ... provider_options={"stop_sequences": ["5"]}, ... )

ThinkingAdaptive

Bases: TypedDict

The model decides how much it thinks.

Mirrors ThinkingConfigAdaptiveParam as a TypedDict, so a dict literal type-checks.

Attributes:

Name Type Description
type Literal['adaptive']

Always adaptive.

display NotRequired[Literal['summarized', 'omitted'] | None]

Whether a summary of the thinking comes back.

ThinkingBetweenTools

Bases: TypedDict

Thinking only between tool calls.

Mirrors ThinkingConfigBetweenToolsParam.

Attributes:

Name Type Description
type Literal['between_tools']

Always between_tools.

ThinkingDisabled

Bases: TypedDict

No thinking, on the models that allow it.

Mirrors ThinkingConfigDisabledParam.

Attributes:

Name Type Description
type Literal['disabled']

Always disabled.

ThinkingEnabled

Bases: TypedDict

Thinking with a fixed budget, on the models that take one.

Mirrors ThinkingConfigEnabledParam.

Attributes:

Name Type Description
type Literal['enabled']

Always enabled.

budget_tokens int

Tokens the model may spend on thinking.

display NotRequired[Literal['summarized', 'omitted'] | None]

Whether a summary of the thinking comes back.

CitationsDelta

Bases: BaseAPITypeExtra

CitationsDelta from the Anthropic Messages API.

Delta

Bases: BaseAPITypeExtra

Delta from the Anthropic Messages API (upstream: Delta).

Attributes:

Name Type Description
container Container | None

Information about the container used in the request (for the code execution tool)

stop_details RefusalStopDetails | None

Structured information about a refusal.

InputJSONDelta

Bases: BaseAPITypeExtra

InputJSONDelta from the Anthropic Messages API.

RawContentBlockDeltaEvent

Bases: BaseAPITypeExtra

RawContentBlockDeltaEvent from the Anthropic Messages API.

RawContentBlockStartEvent

Bases: BaseAPITypeExtra

RawContentBlockStartEvent from the Anthropic Messages API.

Attributes:

Name Type Description
content_block Annotated[Annotated[Annotated[TextBlock, Tag('0')] | Annotated[ThinkingBlock, Tag('1')] | Annotated[RedactedThinkingBlock, Tag('2')] | Annotated[ToolUseBlock, Tag('3')] | Annotated[ServerToolUseBlock, Tag('4')] | Annotated[WebSearchToolResultBlock, Tag('5')] | Annotated[WebFetchToolResultBlock, Tag('6')] | Annotated[CodeExecutionToolResultBlock, Tag('7')] | Annotated[BashCodeExecutionToolResultBlock, Tag('8')] | Annotated[TextEditorCodeExecutionToolResultBlock, Tag('9')] | Annotated[ToolSearchToolResultBlock, Tag('10')] | Annotated[ContainerUploadBlock, Tag('11')] | Annotated[UnknownVariant, Tag(UNKNOWN)], Discriminator(by_type({'text': '0', 'thinking': '1', 'redacted_thinking': '2', 'tool_use': '3', 'server_tool_use': '4', 'web_search_tool_result': '5', 'web_fetch_tool_result': '6', 'code_execution_tool_result': '7', 'bash_code_execution_tool_result': '8', 'text_editor_code_execution_tool_result': '9', 'tool_search_tool_result': '10', 'container_upload': '11'}))], Field(title='Content Block')]

Response model for a file uploaded to the container.

RawContentBlockStopEvent

Bases: BaseAPITypeExtra

RawContentBlockStopEvent from the Anthropic Messages API.

RawMessageDeltaEvent

Bases: BaseAPITypeExtra

RawMessageDeltaEvent from the Anthropic Messages API.

RawMessageStartEvent

Bases: BaseAPITypeExtra

RawMessageStartEvent from the Anthropic Messages API.

RawMessageStopEvent

Bases: BaseAPITypeExtra

RawMessageStopEvent from the Anthropic Messages API.

SignatureDelta

Bases: BaseAPITypeExtra

SignatureDelta from the Anthropic Messages API.

TextDelta

Bases: BaseAPITypeExtra

TextDelta from the Anthropic Messages API.

ThinkingDelta

Bases: BaseAPITypeExtra

ThinkingDelta from the Anthropic Messages API.

ContainerUploadBlock

Bases: BaseAPITypeExtra

Response model for a file uploaded to the container.

DeletedFile

Bases: BaseAPITypeExtra

DeletedFile from the Anthropic Messages API.

Attributes:

Name Type Description
type Annotated[Literal['file_deleted'], Field(description='Deleted object type. For file deletion, this is always `"file_deleted"`.')]

Deleted object type. For file deletion, this is always "file_deleted".

id Annotated[str, Field(description='ID of the deleted file.')]

ID of the deleted file.

FileMetadata

Bases: BaseAPITypeExtra

FileMetadata from the Anthropic Messages API.

Attributes:

Name Type Description
type Annotated[Literal['file'], Field(description='Object type. For files, this is always `"file"`.')]

Object type. For files, this is always "file".

id Annotated[str, Field(description='Unique object identifier. The format and length of IDs may change over time.')]

Unique object identifier. The format and length of IDs may change over time.

created_at Annotated[AwareDatetime, Field(description='RFC 3339 datetime string representing when the file was created.')]

RFC 3339 datetime string representing when the file was created.

filename Annotated[str, Field(description='Original filename of the uploaded file.', max_length=500, min_length=1)]

Original filename of the uploaded file.

mime_type Annotated[str, Field(description='MIME type of the file.', max_length=255, min_length=1)]

MIME type of the file.

size_bytes Annotated[int, Field(description='Size of the file in bytes.', ge=0)]

Size of the file in bytes.

downloadable Annotated[bool, Field(description='Whether the file can be downloaded.')]

Whether the file can be downloaded.

expires_at Annotated[AwareDatetime | None, Field(description='RFC 3339 datetime string representing when the file will expire and become unavailable for download. Null if the file does not expire. For files uploaded with `expires_in_seconds`, this is the upload time plus that value.')]

RFC 3339 datetime string representing when the file will expire and become unavailable for download. Null if the file does not expire. For files uploaded with expires_in_seconds, this is the upload time plus that value.

ListFilesResponse

Bases: BaseAPITypeExtra

ListFilesResponse from the Anthropic Messages API.

Attributes:

Name Type Description
data Annotated[list[FileMetadata], Field(description='List of file metadata objects.')]

List of file metadata objects.

next_page Annotated[str | None, Field(description='Opaque cursor for the next page. Supply as `?page=` to fetch the next page; null when there are no more results.')]

Opaque cursor for the next page. Supply as ?page= to fetch the next page; null when there are no more results.

CacheMissMessagesChanged

Bases: BaseAPITypeExtra

CacheMissMessagesChanged from the Anthropic Messages API.

A cache_miss_reason for a request whose messages differ from the previous request's in an earlier entry, instead of only having entries appended. The model, system, and tools match.

See the cache diagnostics guide to learn what to change for each reason.

CacheMissModelChanged

Bases: BaseAPITypeExtra

CacheMissModelChanged from the Anthropic Messages API.

A cache_miss_reason for a request whose model or speed differs from the previous request's.

See the cache diagnostics guide to learn what to change for each reason.

CacheMissPreviousMessageNotFound

Bases: BaseAPITypeExtra

CacheMissPreviousMessageNotFound.

A cache_miss_reason for when the API doesn't have a stored record of the request that diagnostics.previous_message_id references.

This doesn't mean that this request changed.

See the cache diagnostics guide to learn what to change for each reason.

CacheMissSystemChanged

Bases: BaseAPITypeExtra

CacheMissSystemChanged from the Anthropic Messages API.

A cache_miss_reason for a request whose system differs from the previous request's.

See the cache diagnostics guide to learn what to change for each reason.

CacheMissUnavailable

Bases: BaseAPITypeExtra

A cache_miss_reason for when the API can't give a diagnosis.

The request itself was processed normally.

This includes a request whose model, system, and tools match the previous request's but whose other prompt-affecting parameters, such as thinking or tool_choice, differ.

See the cache diagnostics guide to learn what to change for each reason.

CitationContentBlockLocation

Bases: BaseAPITypeExtra

CitationContentBlockLocation from the Anthropic Messages API.

Diagnostics

Bases: BaseAPITypeExtra

Diagnostics from the Anthropic Messages API.

Request-level diagnostics: why the prompt cache could not fully reuse the prefix of the request named by diagnostics.previous_message_id.

Message

Bases: BaseAPITypeExtra

Message from the Anthropic Messages API (upstream: Message).

Attributes:

Name Type Description
container Container | None

Information about the container used in the request (for the code execution tool)

content Annotated[list[Annotated[Annotated[TextBlock, Tag('0')] | Annotated[ThinkingBlock, Tag('1')] | Annotated[RedactedThinkingBlock, Tag('2')] | Annotated[ToolUseBlock, Tag('3')] | Annotated[ServerToolUseBlock, Tag('4')] | Annotated[WebSearchToolResultBlock, Tag('5')] | Annotated[WebFetchToolResultBlock, Tag('6')] | Annotated[CodeExecutionToolResultBlock, Tag('7')] | Annotated[BashCodeExecutionToolResultBlock, Tag('8')] | Annotated[TextEditorCodeExecutionToolResultBlock, Tag('9')] | Annotated[ToolSearchToolResultBlock, Tag('10')] | Annotated[ContainerUploadBlock, Tag('11')] | Annotated[UnknownVariant, Tag(UNKNOWN)], Discriminator(by_type({'text': '0', 'thinking': '1', 'redacted_thinking': '2', 'tool_use': '3', 'server_tool_use': '4', 'web_search_tool_result': '5', 'web_fetch_tool_result': '6', 'code_execution_tool_result': '7', 'bash_code_execution_tool_result': '8', 'text_editor_code_execution_tool_result': '9', 'tool_search_tool_result': '10', 'container_upload': '11'}))]], Field(title='Content')]

Response model for a file uploaded to the container.

diagnostics Diagnostics | None

Request-level diagnostics: why the prompt cache could not fully reuse the prefix of the request named by diagnostics.previous_message_id.

stop_details RefusalStopDetails | None

Structured information about a refusal.

RefusalStopDetails

Bases: BaseAPITypeExtra

Structured information about a refusal.

TextBlock

Bases: BaseAPITypeExtra

TextBlock from the Anthropic Messages API.

CitationCharLocation

Bases: BaseAPITypeExtra

CitationCharLocation from the Anthropic Messages API.

CitationPageLocation

Bases: BaseAPITypeExtra

CitationPageLocation from the Anthropic Messages API.

CitationsSearchResultLocation

Bases: BaseAPITypeExtra

CitationsSearchResultLocation from the Anthropic Messages API.

CitationsWebSearchResultLocation

Bases: BaseAPITypeExtra

CitationsWebSearchResultLocation.

Container

Bases: BaseAPITypeExtra

Container from the Anthropic Messages API.

Information about the container used in the request (for the code execution tool)

Attributes:

Name Type Description
skills Annotated[list[ContainerSkill] | None, Field(title='Skills')]

A skill that was loaded in a container (response model).

ContainerSkill

Bases: BaseAPITypeExtra

A skill that was loaded in a container (response model).

RedactedThinkingBlock

Bases: BaseAPITypeExtra

RedactedThinkingBlock from the Anthropic Messages API.

ThinkingBlock

Bases: BaseAPITypeExtra

ThinkingBlock from the Anthropic Messages API.

Base64PDFSource

Bases: BaseAPITypeExtra

Base64PDFSource from the Anthropic Messages API.

BashCodeExecutionOutputBlock

Bases: BaseAPITypeExtra

BashCodeExecutionOutputBlock from the Anthropic Messages API.

BashCodeExecutionResultBlock

Bases: BaseAPITypeExtra

BashCodeExecutionResultBlock from the Anthropic Messages API.

BashCodeExecutionToolResultBlock

Bases: BaseAPITypeExtra

BashCodeExecutionToolResultBlock.

BashCodeExecutionToolResultErrorObject

Bases: BaseAPITypeExtra

BashCodeExecutionToolResultErrorObject.

CacheMissToolsChanged

Bases: BaseAPITypeExtra

CacheMissToolsChanged from the Anthropic Messages API.

A cache_miss_reason for a request whose tools differ from the previous request's, for example because tools were added, removed, or reordered.

See the cache diagnostics guide to learn what to change for each reason.

CitationsConfig

Bases: BaseAPITypeExtra

CitationsConfig from the Anthropic Messages API.

CodeExecutionOutputBlock

Bases: BaseAPITypeExtra

CodeExecutionOutputBlock from the Anthropic Messages API.

CodeExecutionResultBlock

Bases: BaseAPITypeExtra

CodeExecutionResultBlock from the Anthropic Messages API.

CodeExecutionToolResultBlock

Bases: BaseAPITypeExtra

CodeExecutionToolResultBlock from the Anthropic Messages API.

Attributes:

Name Type Description
content Annotated[Annotated[Annotated[CodeExecutionToolResultErrorObject, Tag('0')] | Annotated[CodeExecutionResultBlock, Tag('1')] | Annotated[EncryptedCodeExecutionResultBlock, Tag('2')] | Annotated[UnknownVariant, Tag(UNKNOWN)], Discriminator(by_type({'code_execution_tool_result_error': '0', 'code_execution_result': '1', 'encrypted_code_execution_result': '2'}))], Field(title='Content')]

The output and exit code of Python code that Claude ran with the code execution tool, with standard output in encrypted form.

CodeExecutionToolResultErrorObject

Bases: BaseAPITypeExtra

CodeExecutionToolResultErrorObject.

DirectCaller

Bases: BaseAPITypeExtra

Tool invocation directly from the model.

DocumentBlock

Bases: BaseAPITypeExtra

DocumentBlock from the Anthropic Messages API.

EncryptedCodeExecutionResultBlock

Bases: BaseAPITypeExtra

EncryptedCodeExecutionResultBlock.

The output and exit code of Python code that Claude ran with the code execution tool, with standard output in encrypted form.

The API returns this block in place of code_execution_result when the code called the web search tool.

See the programmatic tool calling guide to learn more about programmatic tool calling.

PlainTextSource

Bases: BaseAPITypeExtra

PlainTextSource from the Anthropic Messages API.

ServerToolCaller

Bases: BaseAPITypeExtra

Tool invocation generated by a server-side tool.

ServerToolCaller20260120

Bases: BaseAPITypeExtra

ServerToolCaller20260120 from the Anthropic Messages API.

ServerToolUseBlock

Bases: BaseAPITypeExtra

ServerToolUseBlock from the Anthropic Messages API.

TextEditorCodeExecutionCreateResultBlock

Bases: BaseAPITypeExtra

TextEditorCodeExecutionCreateResultBlock.

TextEditorCodeExecutionStrReplaceResultBlock

Bases: BaseAPITypeExtra

TextEditorCodeExecutionStrReplaceResultBlock.

TextEditorCodeExecutionToolResultBlock

Bases: BaseAPITypeExtra

TextEditorCodeExecutionToolResultBlock.

TextEditorCodeExecutionToolResultErrorObject

Bases: BaseAPITypeExtra

TextEditorCodeExecutionToolResultErrorObject.

TextEditorCodeExecutionViewResultBlock

Bases: BaseAPITypeExtra

TextEditorCodeExecutionViewResultBlock.

ToolReferenceBlock

Bases: BaseAPITypeExtra

ToolReferenceBlock from the Anthropic Messages API.

ToolSearchToolResultBlock

Bases: BaseAPITypeExtra

ToolSearchToolResultBlock from the Anthropic Messages API.

ToolSearchToolResultErrorObject

Bases: BaseAPITypeExtra

ToolSearchToolResultErrorObject.

ToolSearchToolSearchResultBlock

Bases: BaseAPITypeExtra

ToolSearchToolSearchResultBlock.

ToolUseBlock

Bases: BaseAPITypeExtra

ToolUseBlock from the Anthropic Messages API.

WebFetchBlock

Bases: BaseAPITypeExtra

WebFetchBlock from the Anthropic Messages API.

WebFetchToolResultBlock

Bases: BaseAPITypeExtra

WebFetchToolResultBlock from the Anthropic Messages API.

WebFetchToolResultErrorBlock

Bases: BaseAPITypeExtra

WebFetchToolResultErrorBlock from the Anthropic Messages API.

WebSearchResultBlock

Bases: BaseAPITypeExtra

WebSearchResultBlock from the Anthropic Messages API.

WebSearchToolResultBlock

Bases: BaseAPITypeExtra

WebSearchToolResultBlock from the Anthropic Messages API.

WebSearchToolResultErrorObject

Bases: BaseAPITypeExtra

WebSearchToolResultErrorObject from the Anthropic Messages API.

CacheCreation

Bases: BaseAPITypeExtra

CacheCreation from the Anthropic Messages API.

MessageDeltaUsage

Bases: BaseAPITypeExtra

MessageDeltaUsage from the Anthropic Messages API.

OutputTokensDetails

Bases: BaseAPITypeExtra

OutputTokensDetails from the Anthropic Messages API.

ServerToolUsage

Bases: BaseAPITypeExtra

ServerToolUsage from the Anthropic Messages API.

Usage

Bases: BaseAPITypeExtra

Usage from the Anthropic Messages API (upstream: Usage).