Updated
On this page
AnthropicProvider: Provider implementation for the Anthropic Messages API -- builds streaming requests, parses SSE deltas and tool_use blocks, formats tool results for Claude models.
#transport.src.orxtra.transport.providers._anthropic
#transport.src.orxtra.transport.providers._anthropic
#AnthropicProvider
#build_request
python
def build_request(self, messages: list[dict[str, Any]], tools: list[dict[str, Any]], system: str, model: str) -> dict[str, Any]#parse_response
python
def parse_response(self, response: dict[str, Any]) -> list[ContentBlock]#parse_stream
python
async def parse_stream(self, byte_stream: AsyncIterator[bytes]) -> AsyncIterator[TransportEvent]#extract_usage
python
def extract_usage(self, response: dict[str, Any]) -> Usage#format_tool_result
python
def format_tool_result(self, tool_use_id: str, content: str, is_error: bool) -> dict[str, Any]#wrap_tool_results
python
def wrap_tool_results(self, results: list[dict[str, Any]]) -> list[dict[str, Any]]#format_assistant_message
python
def format_assistant_message(self, blocks: list[ContentBlock]) -> dict[str, Any]#_format_anthropic_tool
python
def _format_anthropic_tool(tool: dict[str, Any]) -> dict[str, Any]Format a tool spec for the Anthropic API.
Deferred tools get defer_loading: true which tells Anthropic to exclude them from prompt token counting until they are called. Non-deferred tools are passed through with the deferred key stripped.