Skip to main content

FinOps CLI for LLM API costs: scan code, estimate token spend, and block over-budget PRs.

Project description

TokEnable

PyPI Python License CI

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
Google 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

Development

git clone https://github.com/pardhusrepo/tokenable.git
cd tokenable
pip install -e '.[dev]'
make test

License

Apache-2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tokenable-1.0.0.tar.gz (57.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tokenable-1.0.0-py3-none-any.whl (48.6 kB view details)

Uploaded Python 3

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

Hashes for tokenable-1.0.0.tar.gz
Algorithm Hash digest
SHA256 8bdd7524d506870c13a0d6c3ba80a4ed87d2c7e797c2dfb85490f764e772b9a8
MD5 31fda503a679928551478bcefc9353b6
BLAKE2b-256 847c3ddf740b392d7b2c27f28cee7ee260c751aba31cbbb799a4fd2ee6e84230

See more details on using hashes here.

Provenance

The following attestation bundles were made for tokenable-1.0.0.tar.gz:

Publisher: publish.yml on pardhusrepo/tokenable

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for tokenable-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fd2e805338b65b8a3b016e7388eb4712fef7c8156d3cae16e327c54b6aaedc5e
MD5 8804e3f1f20f98d66fc44ba452a3875a
BLAKE2b-256 24c166f87c44dea2afabdb3e40446eb3db023ae344f0d94ed7bf1b4a95c4627c

See more details on using hashes here.

Provenance

The following attestation bundles were made for tokenable-1.0.0-py3-none-any.whl:

Publisher: publish.yml on pardhusrepo/tokenable

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page