Skip to main content

Module convert

Module convert 

Source
Expand description

Conversion between framework types and the Anthropic Messages API wire format.

Constants§

DEFAULT_BETA_FLAGS
The beta flags upstream’s Python AnthropicClient unconditionally enables on every request (BETA_FLAGS in agent_framework_anthropic/_chat_client.py ~line 54), unioned with any client- or request-level additions and sent via the anthropic-beta header. Verified against _create_run_options (~line 254-264): "betas": {*BETA_FLAGS, *self.additional_beta_flags, *betas} is built for every beta.messages.create call, 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/messages request body.
extract_system
Split a leading system message (and/or ChatOptions::instructions) out into Anthropic’s top-level system field, returning the remaining messages to convert into the messages array.
messages_to_anthropic
Convert framework messages into Anthropic’s messages array.
parse_response
Parse a full (non-streaming) Anthropic Message response.
tools_to_anthropic
Convert tool definitions into Anthropic’s request shape.