A CLI tool that reports on the cost per model on AWS Bedrock
Project description
aws-bedrock-cost-tool
A CLI tool for analyzing AWS Bedrock model costs using the Cost Explorer API.
Features
- Flexible time periods: days (7d), weeks (2w), months (1m), up to 365 days
- Multiple output formats: JSON, tables, ASCII plots, matplotlib plots (iTerm2), summary
- Three detail levels: basic, standard, full (with regional breakdown)
- Token usage and cache statistics
- AWS profile support
- Importable as Python library
Installation
Requirements: Python 3.14+, AWS CLI configured, uv
git clone https://github.com/dnvriend/aws-bedrock-cost-tool.git
cd aws-bedrock-cost-tool
uv sync
uv build
uv tool install dist/aws_bedrock_cost_tool-0.1.0-py3-none-any.whl
Configuration
AWS Credentials
# Option 1: AWS profile
aws configure --profile my-profile
aws-bedrock-cost-tool --profile my-profile
# Option 2: Environment variables
export AWS_PROFILE=my-profile
Required IAM Permission
{
"Version": "2012-10-17",
"Statement": [{
"Effect": "Allow",
"Action": "ce:GetCostAndUsage",
"Resource": "*"
}]
}
Cost Explorer must be enabled in AWS Console.
Usage
# JSON output (default), last 30 days
aws-bedrock-cost-tool
# Summary with all models, tokens, and cache stats
aws-bedrock-cost-tool --summary
# Table output
aws-bedrock-cost-tool --table
# Specific period and profile
aws-bedrock-cost-tool --period 7d --profile production
# Time series plot
aws-bedrock-cost-tool --plot-time
# Bar chart by model
aws-bedrock-cost-tool --plot-models
# All visualizations (ASCII)
aws-bedrock-cost-tool --all-visual
# High-quality matplotlib plots (iTerm2 only)
aws-bedrock-cost-tool --plot-image
# Full detail with regional breakdown
aws-bedrock-cost-tool --detail full --table
Output Examples
Summary:
Total: ~$1015.85
Models:
Claude Sonnet 4.5: ~$962.35 (~24M tokens, cache read: ~1410M tokens, cache write: ~95M tokens)
Claude Haiku 4.5: ~$35.92 (~24M tokens, cache read: ~20M tokens, cache write: ~5M tokens)
Claude Sonnet 4: ~$16.95 (~4M tokens)
Claude Opus 4.5: ~$0.63 (~0.006M tokens)
JSON (pipe to jq):
aws-bedrock-cost-tool | jq '.models[] | select(.model_name | contains("Sonnet"))'
Options
| Option | Description |
|---|---|
--period |
Time period (7d, 2w, 1m, 3m). Default: 30d, Max: 365d |
--profile |
AWS profile name |
--detail |
basic, standard (default), full |
--table |
Table output |
--plot-time |
Time series plot (ASCII) |
--plot-models |
Bar chart by model (ASCII) |
--all-visual |
All ASCII visualizations |
--plot-image |
Matplotlib plots inline in iTerm2 |
--summary |
Summary with tokens and cache stats |
-v |
Verbose logging (-vv for debug, -vvv for trace) |
-q |
Quiet mode |
Library Usage
from aws_bedrock_cost_tool import (
create_cost_explorer_client,
query_bedrock_costs,
analyze_cost_data,
parse_period,
calculate_date_range,
format_date_for_aws,
)
days = parse_period("30d")
start_date, end_date = calculate_date_range(days)
client = create_cost_explorer_client(profile_name="my-profile")
response = query_bedrock_costs(client, format_date_for_aws(start_date), format_date_for_aws(end_date))
cost_data = analyze_cost_data(response, start_date, end_date, detail="standard")
print(f"Total: ${cost_data['total_cost']:.2f}")
for model in cost_data['models']:
print(f"{model['model_name']}: ${model['total_cost']:.2f}")
Development
make install # Install dependencies
make check # Run lint + typecheck + test + security
make pipeline # Full pipeline including build
License
MIT License - see LICENSE
Author
Dennis Vriend - @dnvriend
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file aws_bedrock_cost_tool-0.1.0.tar.gz.
File metadata
- Download URL: aws_bedrock_cost_tool-0.1.0.tar.gz
- Upload date:
- Size: 470.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
71d8bc93f5e193ef5191f8f12bf7658becac93c2cb5a7c41c492fecfb66cbcb2
|
|
| MD5 |
40b874635421c7d34be5c7897161fdd7
|
|
| BLAKE2b-256 |
1a0116848e62a4f864303b9d40eea852d78de92012d101b61ab1ef4a8bfaa823
|
Provenance
The following attestation bundles were made for aws_bedrock_cost_tool-0.1.0.tar.gz:
Publisher:
publish.yml on dnvriend/aws-bedrock-cost-tool
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
aws_bedrock_cost_tool-0.1.0.tar.gz -
Subject digest:
71d8bc93f5e193ef5191f8f12bf7658becac93c2cb5a7c41c492fecfb66cbcb2 - Sigstore transparency entry: 742675250
- Sigstore integration time:
-
Permalink:
dnvriend/aws-bedrock-cost-tool@6fac514e48e477c3644170f543b21e83ffbcaa14 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/dnvriend
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@6fac514e48e477c3644170f543b21e83ffbcaa14 -
Trigger Event:
push
-
Statement type:
File details
Details for the file aws_bedrock_cost_tool-0.1.0-py3-none-any.whl.
File metadata
- Download URL: aws_bedrock_cost_tool-0.1.0-py3-none-any.whl
- Upload date:
- Size: 24.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
962bc451964c5fbbc6fc63063bb59af95dec42cb2b3129fdbb252e713fc0a471
|
|
| MD5 |
5a83fea85c9be085953b98d0de7e09d9
|
|
| BLAKE2b-256 |
273d60e0117572e44b83a14f06e09e7d39d3fe32a6321b066c028f0992ff96c9
|
Provenance
The following attestation bundles were made for aws_bedrock_cost_tool-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on dnvriend/aws-bedrock-cost-tool
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
aws_bedrock_cost_tool-0.1.0-py3-none-any.whl -
Subject digest:
962bc451964c5fbbc6fc63063bb59af95dec42cb2b3129fdbb252e713fc0a471 - Sigstore transparency entry: 742675252
- Sigstore integration time:
-
Permalink:
dnvriend/aws-bedrock-cost-tool@6fac514e48e477c3644170f543b21e83ffbcaa14 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/dnvriend
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@6fac514e48e477c3644170f543b21e83ffbcaa14 -
Trigger Event:
push
-
Statement type: