Real-time token usage and cost monitoring for AWS Bedrock, because Cost Explorer won't tell you until tomorrow.

When running Bedrock agents, you're flying blind. AWS Cost Explorer has a 24–48 hour lag. CloudWatch has live data, but getting to it requires knowing the log group name, converting dates to epoch milliseconds, parsing deeply nested JSON, and doing the cost math yourself.
There's no bedrock usage command. This is that command.
pip install bedrock-lens
Or with uv:
uv tool install bedrock-lens
bedrock-lens # today's usage (default)
bedrock-lens --yesterday
bedrock-lens --week
bedrock-lens --since 2h # last 2 hours
bedrock-lens --since 30m # last 30 minutes
bedrock-lens --since 1d # last 1 day
bedrock-lens --live # tail mode, refreshes every 5s
bedrock-lens --since 1h --live # live tail for the last hour
bedrock-lens --live --threshold 2 # alert when spend crosses $2
bedrock-lens --setup # one-time setup wizard
# different profile / region
bedrock-lens --profile my-profile --region us-west-2
Bedrock doesn't log invocations by default. Run the setup wizard once per AWS account:
bedrock-lens --setup
This creates the CloudWatch log group, an IAM role for Bedrock to write to it, and enables model invocation logging. Takes about 10 seconds. After that, every Bedrock call shows up within ~30 seconds.
By default, the log group is created with no retention policy (AWS keeps logs forever). Use --retention to control this:
bedrock-lens --setup --retention 90 # expire logs after 90 days
bedrock-lens --setup --retention 0 # remove any existing retention policy
Omitting --retention leaves any existing policy untouched.
If you don't have IAM permissions to create roles, the wizard prints the exact policies and CLI command to hand off to your admin.
Bedrock writes a JSON record to /aws/bedrock/model-invocations in CloudWatch for every model call. Each record contains the model ID, input token counts, and output token count. bedrock-lens reads those records, applies per-model pricing, and renders the table.
Live mode (--live) polls every 5 seconds with a 90-second overlap window to handle CloudWatch's ingestion delay, deduplicating events by ID so nothing gets double-counted.
Prices are fetched from two AWS sources at startup and cached to disk for 24 hours at ~/.config/bedrock-lens/pricing_cache.json, so subsequent runs skip the network fetch entirely. The cache is per-region.
AmazonBedrockFoundationModels price list CSV: the primary source for Anthropic/Claude models (including the latest 4.x releases), Cohere, AI21, and legacy models. Region-specific, using the standard on-demand Global rate rather than the geo-CRIS regional premium.
AmazonBedrock Price List API: covers all other providers: Meta (Llama), Mistral, DeepSeek, Google (Gemma), Amazon Nova, Nvidia, Qwen, and 50+ more. Prices are region-specific and update automatically.
For any model not yet in either source (typically new releases in the days before AWS adds them to the catalogue), the tool prompts you to enter the price once and saves it to ~/.config/bedrock-lens/overrides.json. The entry is removed automatically the next time the model appears in the live pricing data.
Token counts are always accurate for every model regardless of pricing status. They come directly from CloudWatch logs written by Bedrock itself. Unknown models show N/A for cost but token counts are never affected.
logs:FilterLogEvents on /aws/bedrock/model-invocationsbedrock:ListFoundationModels and bedrock:ListInferenceProfiles for live model discoverypricing:ListPriceLists and pricing:GetPriceListFileUrl for live pricing--setup if not)$ claude mcp add bedrock-lens \
-- python -m otcore.mcp_server <graph>