Know your AI API costs before you spend.
Calculate and compare LLM pricing from the terminal. 25+ models, all major providers.
pip install apicost$ apicost calc gpt-4o -i 10000 -o 2000
Model: gpt-4o (OpenAI)
Input: 10,000 tokens → $0.0250
Output: 2,000 tokens → $0.0200
─────────────────────────────────
Total: $0.0450$ apicost compare -i 10000 -o 2000
Cost comparison: 10,000 input + 2,000 output tokens
Model Provider Input Output Total
───────────────────────── ─────────────── ──────────── ──────────── ────────────
ollama Local (Ollama) $0.00 (free) $0.00 (free) $0.00 (free)
mistral-nemo Mistral $0.000200 $0.000040 $0.000240
llama-3.3-70b Meta (Groq) $0.000600 $0.000120 $0.000720
deepseek-v3 DeepSeek $0.0028 $0.000840 $0.0036
gpt-4o-mini OpenAI $0.0015 $0.0012 $0.0027
...
claude-opus-4-6 Anthropic $0.0500 $0.0500 $0.10$ apicost listfrom apicost import calculate_cost, estimate_cost
# Exact token count
result = calculate_cost("gpt-4o", input_tokens=5000, output_tokens=1000)
print(f"Total: ${result['total_cost']:.4f}")
# Estimate from text
result = estimate_cost("claude-sonnet-4-6", input_text="Your prompt here...", output_tokens=500)
print(f"Estimated: ${result['total_cost']:.6f}")| Provider | Models |
|---|---|
| Anthropic | Claude Opus 4.6, Sonnet 4.6, Haiku 4.5 |
| OpenAI | GPT-5.2, GPT-5.2 Mini, GPT-4o, GPT-4o Mini, o3, o3-mini |
| Gemini 3.1 Pro, 3 Flash, 2.5 Pro, 2.0 Flash, 2.0 Flash-Lite | |
| DeepSeek | V3, R1 |
| Mistral | Large, Small, Nemo |
| Meta | Llama 4 Maverick, Scout, 3.3 70B (via Groq) |
| Cohere | Command R+, Command R |
| Local | Ollama, any local model ($0) |
apicost calc <model> [-i INPUT] [-o OUTPUT] # Calculate cost
apicost compare [-i INPUT] [-o OUTPUT] # Compare all models
apicost list # Show all models + pricingEvery AI developer asks "how much will this cost?" before making API calls. This tool answers that instantly, from your terminal or Python code, without looking up pricing pages.
PRs welcome — especially for adding new models and keeping prices up to date.
If this saves you money, give it a star.
| Project | Description |
|---|---|
| Awesome AI Tools | 200+ AI tools across 22 categories |
| Build Your Own AI | 150+ tutorials for building AI projects from scratch |
| AI Engineering Handbook | Everything you need to build production AI apps |
| Free AI APIs | 100+ free AI APIs for developers |
| aimsg | AI-powered git commit messages — free with Ollama |