Install
openclaw skills install token-booksSee where your AI money goes. Track spending across OpenAI, Anthropic, Google, and more. Per-provider breakdowns, per-model costs, budget tracking, waste detection.
openclaw skills install token-booksSee where your AI money goes. Track spending across OpenAI, Anthropic, Google, and more. Per-provider breakdowns, per-model costs, budget tracking, waste detection.
See where your AI money goes. Track spending across OpenAI, Anthropic, Google, and more. Find waste. Stay under budget.
TokenBooks imports billing data from multiple AI providers, aggregates everything into one view, and shows you exactly where every dollar went. Per-provider breakdowns, per-model costs, time series trends, budget tracking, and waste detection — all in one tool, all local, zero cloud dependencies.
You use OpenAI for coding, Anthropic for research, Google for experiments. Each has its own billing dashboard. You have no idea:
Manually exporting CSVs and combining them in Excel is tedious and error-prone.
# 1. Import billing data
python3 token_import.py openai_billing.csv --provider openai --output data.json
# 2. Analyze spending
python3 token_books.py data.json --budget 100
# 3. Generate HTML dashboard
python3 token_report.py data.json --output dashboard.html --budget 100
Open dashboard.html in a browser to see:
From OpenAI:
# Download CSV from OpenAI usage dashboard
python3 token_import.py openai_usage.csv --provider openai --output data.json
From Anthropic:
# Download JSON from Anthropic console
python3 token_import.py anthropic_usage.json --provider anthropic --output data.json
From Custom CSV:
# Provide column mapping
python3 token_import.py my_billing.csv --provider custom --column-map mapping.json --output data.json
Column mapping format (mapping.json):
{
"timestamp": "Date",
"provider": "API_Provider",
"model": "Model_Name",
"input_tokens": "Prompt_Tokens",
"output_tokens": "Response_Tokens",
"cost": "Cost_USD"
}
# Basic analysis
python3 token_books.py data.json
# With budget tracking
python3 token_books.py data.json --budget 100
# JSON output for scripting
python3 token_books.py data.json --output json > analysis.json
# Generate HTML dashboard
python3 token_report.py data.json --output dashboard.html
# With budget status
python3 token_report.py data.json --output dashboard.html --budget 100
You use OpenAI, Anthropic, and Google. Import all billing data into TokenBooks, see total spend in one place.
Set a $100/month budget. TokenBooks tells you when you've spent $80 (warning) or $95 (critical). Avoid surprise bills.
See which models cost the most. If GPT-4 is 80% of your spend but only used for simple tasks, switch to GPT-3.5 Turbo.
Tag API calls with task names. See that "code_review" costs $30/month while "documentation" costs $5. Optimize accordingly.
Generate monthly HTML dashboards for your team. Share spending trends and optimization opportunities.
Compare costs across providers for similar workloads. Maybe Anthropic is cheaper for your use case than OpenAI.
See config_example.json for reference constants and example values
# Set monthly budget
MONTHLY_BUDGET = 100.0
# Update pricing for accurate cost calculation
MODEL_PRICING = {
'gpt-4': {'input': 30.0, 'output': 60.0},
'claude-3-opus': {'input': 15.0, 'output': 75.0},
}
# Budget alert thresholds
ALERT_THRESHOLDS = {
'warning': 80, # 80% utilization
'critical': 95 # 95% utilization
}
# Waste detection threshold
WASTE_THRESHOLD = 0.10 # $0.10 per 1k tokens
# Number of top models to show
TOP_MODELS_LIMIT = 10
See config_example.json for full options.
# Import January data
python3 token_import.py openai_jan.csv --provider openai --output jan.json
# Check budget status
python3 token_books.py jan.json --budget 100
# Output:
# Total cost: $87.42
# 📊 Budget Analysis:
# Monthly budget: $100.00
# Spent this month: $87.42
# Remaining: $12.58
# Utilization: 87.4%
python3 token_books.py data.json
# Output:
# 💡 Potential Waste Detected:
# gpt-4: $45.23 (127 requests)
# → Consider using a cheaper model for simple tasks
# Import from multiple providers
python3 token_import.py openai.csv --provider openai --output combined.json
python3 token_import.py anthropic.json --provider anthropic --output temp.json
# Merge manually or import again (appends)
# ... (or use custom tooling to merge JSON files)
# Generate unified dashboard
python3 token_report.py combined.json --output dashboard.html
| File | Purpose |
|---|---|
token_books.py | Main aggregation engine (CLI + library) |
token_import.py | Import parsers for OpenAI, Anthropic, custom CSV |
token_report.py | HTML dashboard generator |
config_example.json | Configuration template |
README.md | This file |
LIMITATIONS.md | What it doesn't do |
LICENSE | MIT License |
Use TokenBooks in your own scripts:
from token_import import ImportManager, UsageRecord
from token_books import CostAggregator
from token_report import DashboardGenerator
# Import data
manager = ImportManager()
manager.import_openai('openai.csv')
records = manager.get_all_records()
# Analyze
aggregator = CostAggregator(records)
print(f"Total cost: ${aggregator.get_total_cost():.2f}")
print(f"Total tokens: {aggregator.get_total_tokens():,}")
# By provider
by_provider = aggregator.by_provider()
for provider, breakdown in by_provider.items():
print(f"{provider}: ${breakdown.total_cost:.2f}")
# Generate dashboard
html = DashboardGenerator.generate(records, monthly_budget=100.0)
with open('dashboard.html', 'w') as f:
f.write(html)
Q: Does it work with Google Cloud billing?
A: Not directly. Google Cloud billing CSVs can be imported via custom CSV parser with column mapping. See config_example.json for mapping format.
Q: Can it track API calls in real-time?
A: No. TokenBooks analyzes exported billing data, not live API usage. Export from your provider, then import.
Q: Does it send data anywhere?
A: No. Everything runs locally. Zero network calls.
Q: How do I tag API calls with task names?
A: Add a "task" field to your billing exports. If your provider doesn't support this, manually add it to the CSV before importing.
Q: Can I combine multiple months of data?
A: Yes. Import each month's data into the same JSON file, or merge JSON files manually.
Q: Does it support non-USD currencies?
A: Not directly. Convert to USD before importing, or manually adjust cost values.
MIT — See LICENSE file.
Shadow Rose
Built for people who want to understand and control their AI spending without enterprise-grade analytics platforms.
This software is provided "AS IS", without warranty of any kind, express or implied.
USE AT YOUR OWN RISK.
By downloading, installing, or using this software, you acknowledge that you have read this disclaimer and agree to use the software entirely at your own risk.
| 🐛 Bug Reports | TheShadowyRose@proton.me |
| ☕ Ko-fi | ko-fi.com/theshadowrose |
| 🛒 Gumroad | shadowyrose.gumroad.com |
| @TheShadowyRose | |
| 🐙 GitHub | github.com/TheShadowRose |
| 🧠 PromptBase | promptbase.com/profile/shadowrose |
Built with OpenClaw — thank you for making this possible.
🛠️ Need something custom? Custom OpenClaw agents & skills starting at $500. If you can describe it, I can build it. → Hire me on Fiverr