AWS Bedrock
Converse is recorded through botocore. Covers bearer-token auth, cross-region inference profiles, and why InvokeModel is unsupported.
Bedrock is recorded through botocore. boto3 clients are generated at runtime, so there
is no Bedrock.converse class to patch. The SDK patches the shared entry point that all
AWS calls pass through and filters to bedrock-runtime.
That filter means calls to S3, DynamoDB, SQS, and every other AWS service pass through
untouched. Only bedrock-runtime operations are inspected.
Coverage
| Operation | Recorded |
|---|---|
converse(...) | Yes |
converse_stream(...) | Patched, not verified against the live service |
invoke_model(...) | No |
invoke_model_with_response_stream(...) | No |
| errors on recorded paths | Yes |
Use converse. It is Bedrock's unified API, returns usage in a consistent shape across
models, and is the path verified against the live service.
invoke_model is unsupported because its request and response bodies are
provider-specific JSON. Extracting token counts would require a parser per model family.
Authentication
The simplest option is a Bedrock API key, generated in the Bedrock console. It is a single bearer token, with no SigV4 key pair:
export AWS_BEARER_TOKEN_BEDROCK="bedrock-api-key-..."
export AWS_REGION="us-east-1"
boto3 1.39 or later reads it natively. Standard credential chains such as profiles, IAM
roles, and AWS_ACCESS_KEY_ID also work. The SDK does not read your credentials.
import boto3
import capsera
capsera.init(api_key=os.environ["CAPSERA_API_KEY"])
client = boto3.client("bedrock-runtime", region_name=os.environ["AWS_REGION"])
response = client.converse(
modelId="anthropic.claude-3-5-sonnet-20241022-v2:0",
messages=[{"role": "user", "content": [{"text": "Summarise this alert."}]}],
inferenceConfig={"maxTokens": 512},
)
Cross-region inference profiles
Bedrock prefixes model IDs with a geography for cross-region inference: us., eu.,
apac., and global.. The SDK strips that prefix before pricing, so
apac.amazon.nova-micro-v1:0 is priced as amazon.nova-micro-v1:0.
Without this, profile-prefixed calls miss the catalog and fall back to a generic estimate. Several regions require inference profiles, because plain model IDs are unavailable there.
Bedrock pricing is separate
Claude on Bedrock is priced separately from Claude direct, and the catalog keys them
separately. anthropic.claude-3-5-sonnet-20241022-v2:0 is a different entry from
claude-3-5-sonnet-20241022. The two will not reconcile against each other.
The catalog covers the Claude family on Bedrock, Amazon Nova (Micro, Lite, Pro), and Llama and Mistral variants.
Limitations
Synchronous only. aioboto3 and async clients are not patched. converse_stream is
patched but unverified against the live service, so treat streamed Bedrock spend as
unconfirmed. Routing and budget enforcement do not apply to Bedrock calls.