Skip to main content

CLI tool for TokTab LLM pricing data

Project description

TokTab CLI

LLM pricing data at your fingertips

A command-line interface for accessing TokTab, a free API providing pricing data for 2000+ LLM models. Powered by LiteLLM and updated nightly.

Installation

# Using uvx (recommended)
uvx toktab gpt-4o

# Or install with pip
pip install toktab

Usage

Get pricing info for a specific model

toktab gpt-4o
toktab claude-3-opus
toktab gemini-1-5-flash

Output:

╭──────────────────────────────────────────────────────────────────────────────╮
│ gpt-4o (openai)                                                               │
╰──────────────────────────────────────────────────────────────────────────────╯

Pricing
 Type    Cost / 1M tokens 
 Input              $2.50 
 Output            $10.00 

Context Window
 Limit       Tokens 
 Max input      128K 
 Max output      16K 

Capabilities
✓ Vision · ✓ Functions · ✓ Tool choice · ✓ System msgs

Search for models

toktab search claude
toktab search "gemini 3"
toktab search provider:anthropic

JSON output

All commands support --json for machine-readable output:

toktab --json gpt-4o
toktab search --json claude

Options

Options:
  --json     Output raw JSON
  --version  Show version
  --help     Show this message and exit.

AI Agent Integration

TokTab CLI is designed to work well with AI agents and automated pipelines.

Auto-detection

When stdout is not a TTY (e.g. piped to another process), output switches to JSON automatically — no flags needed.

# Human at a terminal gets rich tables
toktab gpt-4o

# Piped to another process gets JSON
toktab gpt-4o | jq .input_cost_per_token

Environment variable

Set OUTPUT_FORMAT to force a specific format:

export OUTPUT_FORMAT=json  # Always JSON
export OUTPUT_FORMAT=text  # Always rich tables

Schema introspection

Agents can discover CLI capabilities at runtime:

toktab schema

This outputs a machine-readable JSON description of all commands, arguments, options, and API endpoints.

Structured errors

When JSON output is active, errors are written to stderr as structured JSON:

{"error": true, "message": "Model 'nonexistent' not found"}

Model Slugs

Model identifiers are derived from LiteLLM model names with special characters replaced by hyphens.
For example:

  • gemini/gemini-progemini-gemini-pro
  • anthropic/claude-3-opusanthropic-claude-3-opus

Use the search command to find the exact slug for a model.

Features

  • 🚀 Fast: Lightweight CLI with minimal dependencies
  • 📊 Rich output: Beautiful tables with cost color-coding (green=cheap, yellow=medium, red=expensive)
  • 🔍 Fuzzy search: Find models by name or provider
  • 💰 Cost per million tokens: Easy-to-read pricing format
  • 🎨 JSON output: Perfect for scripting and automation
  • 🆓 Free: No API key required

Development

# Clone the repo
gh repo clone tomdyson/toktab-cli
cd toktab-cli

# Install with dev dependencies
uv venv
source .venv/bin/activate
uv pip install -e ".[dev]"

# Run tests
pytest

# Test locally
toktab gpt-4o

Publishing a New Release

  1. Update the version in pyproject.toml:

    version = "0.2.0"  # Bump version number
    
  2. Commit and push your changes:

    git add pyproject.toml
    git commit -m "Bump version to 0.2.0"
    git push
    
  3. Create and push a git tag:

    git tag v0.2.0
    git push origin v0.2.0
    
  4. Create a GitHub release:

    gh release create v0.2.0 --title "v0.2.0 - Release Title" --notes "Release notes here"
    
  5. Done! GitHub Actions will automatically build and publish to PyPI.

The package will be live at pypi.org/project/toktab within 1-2 minutes.

License

MIT License - see LICENSE for details.

Credits

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

toktab-0.2.0.tar.gz (13.2 kB view details)

Uploaded Source

Built Distribution

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

toktab-0.2.0-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file toktab-0.2.0.tar.gz.

File metadata

  • Download URL: toktab-0.2.0.tar.gz
  • Upload date:
  • Size: 13.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for toktab-0.2.0.tar.gz
Algorithm Hash digest
SHA256 f6c59f4e5acc030430f542ff5ea67f549d0a067ef5cf90311dbf5fd47e4666a0
MD5 993677351402b58843a5f485ba0731bd
BLAKE2b-256 3b8d63a0652ba5be163c93dcf9ae9b23d04a4443d6ccd72a99cebd932b3d086e

See more details on using hashes here.

Provenance

The following attestation bundles were made for toktab-0.2.0.tar.gz:

Publisher: publish.yml on tomdyson/toktab-cli

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

File details

Details for the file toktab-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: toktab-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 9.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for toktab-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8c9aa48ea01c504914d69f530e54db6e0f622698076fb13a09cb888549f365ea
MD5 ca02f7e2713ce5f0d20dc7cd80df6d35
BLAKE2b-256 fbb43fe58c2ea3e22c5823ee871a94d28f2887fac8cc862754deba3042ea08bb

See more details on using hashes here.

Provenance

The following attestation bundles were made for toktab-0.2.0-py3-none-any.whl:

Publisher: publish.yml on tomdyson/toktab-cli

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