FinOps CLI for LLM API costs: scan code, estimate token spend, and block over-budget PRs.
Project description
TokEnable
FinOps CLI for LLM API costs. Scan code, estimate token spend, recommend cheaper models, and block over-budget PRs.
Quick Start
pip install tokenable
tokenable estimate .
┌──────────────────────────────────────────────────────────────────────────┐
│ TokEnable Estimate │
├─────────────┬──────┬───────────┬──────────────────┬─────────┬────────────┤
│ File │ Line │ Provider │ Model │ $/call │ $/month │
├─────────────┼──────┼───────────┼──────────────────┼─────────┼────────────┤
│ src/chat.py │ 42 │ anthropic │ claude-opus-4-6 │ $0.0450 │ $45.00 │
│ src/sum.py │ 15 │ openai │ gpt-4o │ $0.0035 │ $3.50 │
└─────────────┴──────┴───────────┴──────────────────┴─────────┴────────────┘
Total estimated monthly cost: $48.50
Features
| Feature | Description |
|---|---|
| Code Scanner | Detects LLM API calls in .py, .ts, .js files |
| Cost Estimation | Projects monthly costs from token counts and pricing data |
| Smart Recommendations | Suggests cheaper models with equivalent capabilities |
| Auto-Fix | Rewrites model IDs in source files automatically |
| Budget Enforcement | Pre-commit hooks and CI gates for cost control |
| MCP Integration | AI agent tools via Model Context Protocol |
| Calibration | Corrects estimates with real provider usage data |
| Multi-Provider | Anthropic, OpenAI, Google, xAI, Perplexity |
CLI Commands
tokenable estimate . # Estimate costs
tokenable check . --max-monthly-cost 500 # CI budget gate
tokenable audit . # Find savings opportunities
tokenable fix . --dry-run # Preview model swaps
tokenable diff . --base main # Cost diff between branches
tokenable price anthropic claude-sonnet-4-6 # Look up pricing
tokenable calibrate . --provider openai # Calibrate from production
tokenable init # Set up config + hooks
tokenable update-pricing # Refresh pricing data (--dynamic for live)
CI Integration
# .github/workflows/tokenable.yml
- run: pip install tokenable
- run: tokenable check . --max-monthly-cost 500
Fails the build if estimated costs exceed your budget. See CI Integration docs.
Pricing Updates
TokEnable ships with bundled pricing data updated each release. For the latest prices:
tokenable update-pricing # Refresh from static provider data
tokenable update-pricing --dynamic # Fetch live prices from LiteLLM community DB
A GitHub Actions workflow runs daily to keep pricing in sync automatically.
MCP for AI Agents
TokEnable runs as an MCP server for Claude Code, Cursor, and other AI agents:
{
"mcpServers": {
"tokenable": {
"command": "python",
"args": ["-m", "tokenable.mcp"]
}
}
}
Tools: suggest_model, estimate_cost, audit, apply_recommendations. See MCP docs.
Configuration
Create tokenable.config.json:
{
"defaultVolume": 1000,
"ignore": ["**/test/**"],
"overrides": [
{ "pattern": "src/batch/**", "volume": 50000 }
],
"budgets": {
"block": 0.05,
"maxMonthlyCost": 500
}
}
Supported Providers
| Provider | Example Models |
|---|---|
| Anthropic | claude-opus-4-6, claude-sonnet-4-6, claude-haiku-3-5 |
| OpenAI | gpt-4o, gpt-4o-mini, o3, o3-mini |
| gemini-3.1-pro-preview, gemini-2.5-flash | |
| xAI | grok-3, grok-3-mini |
| Perplexity | sonar-pro, sonar-reasoning-pro, sonar |
Full list: Supported Models
Documentation
- Installation
- Quick Start
- CLI Reference
- Supported Models
- CI Integration
- MCP Integration
- FAQ
- Contributing
Development
git clone https://github.com/pardhusrepo/tokenable.git
cd tokenable
pip install -e '.[dev]'
make test
License
Apache-2.0
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 tokenable-1.0.0.tar.gz.
File metadata
- Download URL: tokenable-1.0.0.tar.gz
- Upload date:
- Size: 57.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8bdd7524d506870c13a0d6c3ba80a4ed87d2c7e797c2dfb85490f764e772b9a8
|
|
| MD5 |
31fda503a679928551478bcefc9353b6
|
|
| BLAKE2b-256 |
847c3ddf740b392d7b2c27f28cee7ee260c751aba31cbbb799a4fd2ee6e84230
|
Provenance
The following attestation bundles were made for tokenable-1.0.0.tar.gz:
Publisher:
publish.yml on pardhusrepo/tokenable
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tokenable-1.0.0.tar.gz -
Subject digest:
8bdd7524d506870c13a0d6c3ba80a4ed87d2c7e797c2dfb85490f764e772b9a8 - Sigstore transparency entry: 1789421847
- Sigstore integration time:
-
Permalink:
pardhusrepo/tokenable@6cfd96def9cf2ffe183774a91a1c255e08f2a93e -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/pardhusrepo
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@6cfd96def9cf2ffe183774a91a1c255e08f2a93e -
Trigger Event:
push
-
Statement type:
File details
Details for the file tokenable-1.0.0-py3-none-any.whl.
File metadata
- Download URL: tokenable-1.0.0-py3-none-any.whl
- Upload date:
- Size: 48.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fd2e805338b65b8a3b016e7388eb4712fef7c8156d3cae16e327c54b6aaedc5e
|
|
| MD5 |
8804e3f1f20f98d66fc44ba452a3875a
|
|
| BLAKE2b-256 |
24c166f87c44dea2afabdb3e40446eb3db023ae344f0d94ed7bf1b4a95c4627c
|
Provenance
The following attestation bundles were made for tokenable-1.0.0-py3-none-any.whl:
Publisher:
publish.yml on pardhusrepo/tokenable
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tokenable-1.0.0-py3-none-any.whl -
Subject digest:
fd2e805338b65b8a3b016e7388eb4712fef7c8156d3cae16e327c54b6aaedc5e - Sigstore transparency entry: 1789421960
- Sigstore integration time:
-
Permalink:
pardhusrepo/tokenable@6cfd96def9cf2ffe183774a91a1c255e08f2a93e -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/pardhusrepo
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@6cfd96def9cf2ffe183774a91a1c255e08f2a93e -
Trigger Event:
push
-
Statement type: