Google Gemini token tracker that automatically logs prompts, responses, and token usage
Project description
SuperTokenTracker (Python)
Google Gemini token tracker that automatically logs prompts, responses, and token usage.
Drop-in replacement for google-genai - just change your import!
Installation
pip install supertokentracker
Quick Start
from supertokentracker import genai
client = genai.Client(api_key="YOUR_API_KEY")
response = client.models.generate_content(
model="gemini-2.0-flash-exp",
contents="Why is the sky blue?"
)
print(response.text)
requests = client.get_tracked_requests()
print(f"Total tokens used: {requests[0]['usage']['totalTokens']}")
Migration from google-genai
Simply replace:
from google import genai # Before
With:
from supertokentracker import genai # After
Everything else stays the same!
Features
- Drop-in replacement for
google-genaipackage - Automatic token tracking for all Gemini API calls
- Local JSON file storage or remote tracking
- Tracks errors, metadata, and response times
- Zero-config setup
Configuration
Local Storage (default)
from supertokentracker import genai
client = genai.Client(
api_key="YOUR_API_KEY",
local_storage={
"file_path": "./custom-logs.json",
"auto_save": True
}
)
Remote Storage
from supertokentracker import genai
client = genai.Client(
api_key="YOUR_GEMINI_API_KEY",
storage="remote",
remote_storage={
"api_key": "YOUR_AITRACKER_API_KEY",
"project_name": "my-project"
}
)
View tracked requests at tokentracker.dev
License
MIT
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
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 supertokentracker-0.2.0.tar.gz.
File metadata
- Download URL: supertokentracker-0.2.0.tar.gz
- Upload date:
- Size: 7.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eff7e72c2a50cab48495e8aee97d3283e30fdb14e16222fe05320a62b14142a6
|
|
| MD5 |
e2e9534e5266c494ab8be123aa272e4c
|
|
| BLAKE2b-256 |
da47de700ba5a6e8ad1bdac7762dab068ff3dd906ae51e85db2aad274a236b0b
|
File details
Details for the file supertokentracker-0.2.0-py3-none-any.whl.
File metadata
- Download URL: supertokentracker-0.2.0-py3-none-any.whl
- Upload date:
- Size: 7.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bd38b2f4aca27394bd48c268d49ddb96f2e03e77f714d4f6d26a1f2f7e723873
|
|
| MD5 |
83c0c8ff5dc6b4e9f1a3bf5314dcf46e
|
|
| BLAKE2b-256 |
60bed8278e8f361d73305b1c662c23ec159fad3e9b0609066b4bb65d604f1e1f
|