Expand description
Conversion between framework types and the Anthropic Messages API wire format.
Constants§
- DEFAULT_
BETA_ FLAGS - The beta flags upstream’s Python
AnthropicClientunconditionally enables on every request (BETA_FLAGSinagent_framework_anthropic/_chat_client.py~line 54), unioned with any client- or request-level additions and sent via theanthropic-betaheader. Verified against_create_run_options(~line 254-264):"betas": {*BETA_FLAGS, *self.additional_beta_flags, *betas}is built for everybeta.messages.createcall, not only ones that pass hosted tools/MCP servers – there is no conditional gating on tool presence.
Functions§
- build_
cloud_ request - Build an Anthropic Messages-API-shaped request body for the multi-cloud
transports (
crate::bedrock,crate::vertex,crate::foundry). - build_
request - Build a full Anthropic
POST /v1/messagesrequest body. - extract_
system - Split a leading system message (and/or
ChatOptions::instructions) out into Anthropic’s top-levelsystemfield, returning the remaining messages to convert into themessagesarray. - messages_
to_ anthropic - Convert framework messages into Anthropic’s
messagesarray. - parse_
response - Parse a full (non-streaming) Anthropic
Messageresponse. - tools_
to_ anthropic - Convert tool definitions into Anthropic’s request shape.