Contents

Chapter 1

Features

This chapter covers the core features and capabilities of LLM Cost Tracker.

Features

  • Cost calculation — Automatic per-request cost from token counts and model pricing
  • Pricing table — Built-in pricing for 14+ models (GPT-4o, Claude, Llama, Mixtral, etc.)
  • Budget alerts — Real-time budget monitoring with ok/warning/critical/exceeded levels
  • Usage reports — Per-model breakdown, daily cost charts, and top expensive requests
  • Cost forecasting — Predict future costs based on recent usage patterns
  • JSONL database — Append-only log for durability and easy integration
  • Prefix matching — Automatically matches model versions (e.g., "gpt-4o-2025-01-01" → "gpt-4o")
  • CLI interface — Log requests, check budgets, generate reports from the terminal

Quick Start

bash
# Run demo with simulated API calls
python src/llm_cost_tracker.py --demo

# Show pricing table
python src/llm_cost_tracker.py --pricing

# Log a request
python src/llm_cost_tracker.py --log '{"model":"gpt-4o","input_tokens":500,"output_tokens":200}'

# Check budget
python src/llm_cost_tracker.py --budget 50.00 --db costs.jsonl

# Generate usage report
python src/llm_cost_tracker.py --report --db costs.jsonl

# Forecast next 30 days
python src/llm_cost_tracker.py --forecast 30 --db costs.jsonl
Chapter 2

Project Structure

Follow this guide to get LLM Cost Tracker up and running in your environment.

Project Structure

llm-cost-tracker/
├── README.md
├── LICENSE
├── src/
│   └── llm_cost_tracker.py    # Core engine (~420 lines)
└── examples/
    ├── basic_usage.py          # Programmatic usage example
    └── sample_costs.jsonl      # Sample cost data

CLI Reference

FlagDescription
--demoRun demo with simulated data
--pricingShow pricing table
--db FILEPath to cost database (default: llm_costs.jsonl)
--log JSONLog a request with model, input_tokens, output_tokens
--reportGenerate usage report
--days NLimit report to last N days
--budget USDCheck spending against budget
--forecast DAYSForecast costs for N days
--export FILEExport report to JSON
Chapter 3
🔒 Available in full product

Usage Examples

Chapter 4
🔒 Available in full product

License

You’ve reached the end of the free preview

Get the full LLM Cost Tracker and unlock everything.

All Chapters

Get the complete guide with every chapter unlocked, including code samples, diagrams, and best practices.

Full Tool Suite

Access all interactive tools with complete data, all workload profiles, and the full scenario library.

Source Files

Downloadable source code, configuration files, and working examples from every chapter.

Lifetime Updates

Free updates for life. Every new chapter, tool, and improvement included.

Buy Now — $19 →
📦 Free sample included — download another copy for the full product.
LLM Cost Tracker v1.0.0 — Free Preview