Skip to main content
Amazon Bedrock serves models from many vendors, such as Anthropic, Amazon, Meta and Mistral, through one AWS API.

Set up

Wrap an instance of BedrockRuntimeClient from @aws-sdk/client-bedrock-runtime. The SDK recognizes it automatically.
  • Use the Converse API. ConverseCommand and ConverseStreamCommand are checked and metered, for every model Bedrock serves. Other commands sent through the same client, such as InvokeModelCommand, go through without a check and are not metered. InvokeModel returns each model vendor’s own response format, so the SDK cannot read its usage.
  • Set the stiggContext in wrap(). A Bedrock call takes a command object rather than a parameter object, so it has no place for a stiggContext. To serve several customers, wrap a client for each.
  • A streamed call is reported once, when the stream finishes. Iterate the stream property of the response with for await.
  • Credentials come from the standard AWS credential chain, as for any AWS SDK client.
To check against an estimate of the call’s usage rather than 1, pass the recipe with an estimate, for example from the call’s maxTokens:
See Requested usage.

What is reported

Every Converse response includes a usage object with the number of tokens the call consumed, in the same format for every model. The wrapper reads it and reports it to Stigg as the metrics below. For details, see AWS’s Converse API reference.
  • No cost. Unlike OpenRouter and LiteLLM, Bedrock does not return a price, so you can bill tokens but not what the call cost. The price appears only on your AWS bill.
  • No model dimension. Bedrock serves exactly the model you name and does not fall back to another, so there is no routing drift to track.
  • Cache tokens are separate. Like Anthropic, Bedrock counts cache reads and writes separately from inputTokens. AWS defines totalTokens as the input and output tokens, so on a call that uses the prompt cache it can be lower than the sum of the four counters. Price the total or the parts, never both.
The idempotency key is the AWS request ID, which stays the same when the AWS SDK retries the call, so a retried call is not counted twice. Every usage field the vendor returns is also included, with a raw. prefix. See How usage is reported.