Set up
Wrap an instance ofBedrockRuntimeClient from @aws-sdk/client-bedrock-runtime. The SDK recognizes it automatically.
- Use the Converse API.
ConverseCommandandConverseStreamCommandare checked and metered, for every model Bedrock serves. Other commands sent through the same client, such asInvokeModelCommand, go through without a check and are not metered.InvokeModelreturns each model vendor’s own response format, so the SDK cannot read its usage. - Set the
stiggContextinwrap(). A Bedrock call takes a command object rather than a parameter object, so it has no place for astiggContext. To serve several customers, wrap a client for each. - A streamed call is reported once, when the stream finishes. Iterate the
streamproperty of the response withfor await. - Credentials come from the standard AWS credential chain, as for any AWS SDK client.
estimate, for example from the call’s maxTokens:
What is reported
Every Converse response includes ausage 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
modeldimension. 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 definestotalTokensas 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.
raw. prefix. See How usage is reported.