Simple and lightweight Python package to track LLM API cost
Project description
🚀 costtracker
Track your LLM API cost in your terminal in real time — with one command.
✨ Why costtracker?
Building with LLMs is easy.
Tracking cost isn’t.
costtracker solves this by giving you:
⚡ Instant cost visibility for every API call
No dashboards. No setup. No complexity.
🔥 Features
- 📊 Real-time cost tracking
- ⚡ One-line integration
- 🧠 Works with OpenAI and Gemini models (present)
- 🪶 Lightweight & zero-config
- 🧱 Built for developers
⚡ Quick Demo
pip install costtracker
costtracker run file.py
⚡ Output
Model: gemini-2.5-flash-lite
Tokens: 13 (input: 4, output: 9)
Cost: $0.000011
⚙️ Setup
Create a .env file in your root directory:
GEMINI_API_KEY=your_api_key_here
🧪 Usage
import os
from dotenv import load_dotenv
from costtracker import track
from google import genai
load_dotenv()
api_key=os.getenv("GEMINI_API_KEY")
client=genai.Client(api_key=api_key)
response=client.models.generate_content(
model="gemini-2.5-flash-lite",
contents="Hello there!"
)
track(response)
💡 Use Cases
- 🧑💻 AI app developers tracking API usage
- 🚀 Startup teams controlling LLM costs
- 📊 Experimentation with prompt optimization
- 🧪 GenAI project building
🤝 Contributing
- Contributions are welcome!
- Feel free to open issues or submit PRs.
⭐ If you like this project
Give it a star
📄 License
MIT License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file costtracker-0.1.1.tar.gz.
File metadata
- Download URL: costtracker-0.1.1.tar.gz
- Upload date:
- Size: 8.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9dea3ea7351e89b11d6c65e8e6200cf981b8505bbcdfdf005aad3644f5e6f6a0
|
|
| MD5 |
16e5ac64389d1aeeab435b824c06d39f
|
|
| BLAKE2b-256 |
db6fa4aa62f4422b14e75cdaa597ee24683d34975ea35e925728e80340b93774
|
File details
Details for the file costtracker-0.1.1-py3-none-any.whl.
File metadata
- Download URL: costtracker-0.1.1-py3-none-any.whl
- Upload date:
- Size: 10.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
87aa27943a2508a9b68390a4c10db8334fb63392db1048a8122e6311d94153e0
|
|
| MD5 |
a14a9c5a0a2dc90fe922dccae3ebb3d5
|
|
| BLAKE2b-256 |
c5715cd4b33001fe858dfa86b4e9b092f1ef15b78df47309025a9ead7887baa4
|