apicost
Know your AI API costs before you spend.
Calculate and compare LLM pricing from the terminal. 25+ models, all major providers.
Install
pip install apicost
Usage
Calculate cost for a specific model
$ 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
Compare costs across ALL models
$ 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
List all models and pricing
$ apicost list
Use as a Python library
from 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}")
Supported Models
| 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) |
Commands
apicost calc <model> [-i INPUT] [-o OUTPUT] # Calculate cost
apicost compare [-i INPUT] [-o OUTPUT] # Compare all models
apicost list # Show all models + pricing
Why?
Every 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.
Contributing
PRs welcome — especially for adding new models and keeping prices up to date.
License
If this saves you money, give it a star.
Also By OuterSpacee
| 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 |
Metadata
Release files for apicost 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| apicost-1.0.0.tar.gz | 6.5 kB | Without provenance | Details for apicost-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| apicost-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for apicost-1.0.0-py3-none-any.whl |
Total release size: 13.8 kB
Release files / apicost-1.0.0.tar.gz
| Download URL | apicost-1.0.0.tar.gz |
|---|---|
| Size | 6.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2f62316e27090e7e0d06ba3f6726d31ae13100f6325e3ff85ae4550adcacbcbd
|
|
BLAKE2b-256 checksum How to use checksums |
3ff474c776c7f29a53abfa2b762961d3e406453d5c745d5db003d2a0b25b84ce
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.3
|
Release files / apicost-1.0.0-py3-none-any.whl
| Download URL | apicost-1.0.0-py3-none-any.whl |
|---|---|
| Size | 7.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
44bb4075fdd6f1be2f1af7f124b236dcf589982113dfe748e4fc1be5f9f94a28
|
|
BLAKE2b-256 checksum How to use checksums |
9ea2e64286d136ea1b3de9ee9b30bbf81113bda8fd0a76ccf475fd1c8cbbe273
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.3
|
Security for apicost 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.