ReqLLM.Providers.AmazonBedrock.Anthropic (ReqLLM v1.0.0)
View SourceAnthropic model family support for AWS Bedrock.
Handles Claude models (Claude 3 Sonnet, Haiku, Opus, etc.) on AWS Bedrock.
This module acts as a thin adapter between Bedrock's AWS-specific wrapping and Anthropic's native message format. It delegates to the native Anthropic modules for all format conversion.
Prompt Caching Support
Full Anthropic prompt caching is supported when using the native Bedrock API.
Enable with anthropic_prompt_cache: true option.
Note: Bedrock auto-switches to Converse API when tools are present (including
:object operations which use a synthetic tool). Converse API has limited caching
(only entire system prompts, no granular cache control). For full caching support,
set use_converse: false to force native API with tools/structured output.
Summary
Functions
Extracts usage metadata from the response body.
Formats a ReqLLM context into Anthropic request format for Bedrock.
Parses Anthropic response from Bedrock into ReqLLM format.
Parses a streaming chunk for Anthropic models.
Preserve inference profile prefix for all Anthropic models.
Returns whether this model family supports toolChoice in Bedrock Converse API.
Functions
Extracts usage metadata from the response body.
Delegates to the native Anthropic provider.
Note: AWS Bedrock does not return a separate reasoning_tokens field in its
response structure. Extended thinking tokens are included in output_tokens
and billed accordingly, but Bedrock's API response only provides input_tokens
and output_tokens. This differs from Anthropic's direct API which returns
reasoning_tokens as a separate field.
Formats a ReqLLM context into Anthropic request format for Bedrock.
Delegates to the native Anthropic.Context module and adds Bedrock-specific version parameter.
For :object operations, creates a synthetic "structured_output" tool to leverage Claude's tool-calling for structured JSON output.
Parses Anthropic response from Bedrock into ReqLLM format.
Delegates to the native Anthropic.Response module.
For :object operations, extracts the structured output from the tool call.
Parses a streaming chunk for Anthropic models.
Unwraps the Bedrock-specific encoding then delegates to native Anthropic SSE event parsing.
Preserve inference profile prefix for all Anthropic models.
All Anthropic inference profile models require the region prefix to be preserved in the API request path.
Returns whether this model family supports toolChoice in Bedrock Converse API.