Table of Contents
- What API Tracker Is
- Features
- Installation
- Starting the Application
- SDK Usage
- Database Location
- Configuration
- Development Setup
- Contributing
- License
What API Tracker Is
llmapi-tracker is a local-first API usage and cost observability platform for LLM applications. It records request counts, token usage, latency, errors, and versioned pricing for provider models such as OpenAI and Gemini.
The project is designed to keep data local by default. It stores usage and pricing in a local SQLite database and does not persist prompts, responses, or raw API keys in the application database.
Features
| Category | Capability |
|---|---|
| 🖥️ Backend | Local FastAPI backend with SQLite storage |
| 💰 Pricing | Versioned pricing records for historical cost tracking |
| 📈 Usage | Capture for input, output, thinking, cached, and total tokens |
| 🧮 Cost | Request-level and analytics-level cost calculation |
| 📊 Dashboard | React + Vite dashboard for usage, analytics, providers, models, and pricing |
| 🔌 SDKs | Wrappers for OpenAI and Gemini |
| 🚀 Launcher | Packaged launcher command that starts the local app and opens the browser |
| 🧪 Quality | Open-source repository with tests, CI, and release automation |
Installation
Prerequisites
- Python 3.10 or newer
- Node.js 20 or newer for frontend development
Local Development Install
python -m venv .venv
.venv\Scripts\activate
pip install -r requirements.txt
cd frontend
npm install
Package Install
pip install llmapi-tracker
Optional provider SDK support:
pip install "llmapi-tracker[openai]"
pip install "llmapi-tracker[gemini]"
pip install "llmapi-tracker[all]"
Starting the Application
Backend Only
uvicorn backend.app.main:app --reload
Frontend Only
cd frontend
npm run dev
Packaged App
After the frontend assets are built and packaged into the backend static directory:
api-tracker
The launcher starts the backend server and opens the browser to the local dashboard.
SDK Usage
Initialize the SDK
import os
from api_tracker import APITracker
tracker = APITracker(
project="Pharmacy-AI",
backend_url=os.getenv("TRACKER_BACKEND_URL", "http://localhost:8000"),
openai_api_key=os.getenv("OPENAI_API_KEY"),
gemini_api_key=os.getenv("GEMINI_API_KEY"),
)
OpenAI
response = tracker.openai.chat(
model="gpt-5",
messages=[{"role": "user", "content": "Analyze this prescription"}],
)
Gemini
response = tracker.gemini.generate(
model="gemini-2.5-flash",
contents="Analyze this prescription",
)
The SDK reads usage metadata from the provider response and sends it to the local backend automatically.
Database Location
By default, the SQLite database is stored in a stable user data directory so it survives uninstall and reinstall.
The path is resolved in this order:
API_TRACKER_DB_PATHif setDATABASE_URLif set- A user-data location based on the operating system
Typical defaults
| OS | Path |
|---|---|
| Windows | %LOCALAPPDATA%\APITracker\api_tracker.db |
| macOS / Linux | ~/.local/share/APITracker/api_tracker.db |
If the preferred user-data directory cannot be created, the app falls back to a writable local
.api-tracker-data/directory in the current workspace.
Configuration
Environment variables:
| Variable | Description |
|---|---|
DATABASE_URL |
Overrides the database connection string |
API_TRACKER_DATA_DIR |
Sets the user-data root used for SQLite storage |
API_TRACKER_DB_PATH |
Points directly to a specific SQLite file |
API_TRACKER_HOST |
Host the backend binds to (default 127.0.0.1) |
API_TRACKER_PORT |
Port the backend binds to (default 8000) |
API_TRACKER_OPEN_BROWSER |
Set to false to disable browser auto-open for the launcher |
OPENAI_API_KEY |
API key used by the OpenAI SDK wrapper |
GEMINI_API_KEY |
API key used by the Gemini SDK wrapper |
TRACKER_BACKEND_URL |
Backend URL used by the SDK client |
VITE_API_BASE_URL |
Backend URL used by the frontend dashboard |
Example .env:
DATABASE_URL=sqlite:///./api_tracker.db
API_TRACKER_DATA_DIR=
API_TRACKER_DB_PATH=
API_TRACKER_HOST=127.0.0.1
API_TRACKER_PORT=8000
API_TRACKER_OPEN_BROWSER=true
OPENAI_API_KEY=
GEMINI_API_KEY=
TRACKER_BACKEND_URL=http://localhost:8000
VITE_API_BASE_URL=http://localhost:8000
Development Setup
Backend
python -m compileall backend sdk tests
pytest -q
Frontend
cd frontend
npm run build
Packaging Assets
cd frontend
npm run build
cd ..
python scripts/package_frontend_assets.py
python scripts/verify_frontend_assets.py
Contributing
llmapi-tracker is intended to be open source and contributor friendly.
Contribution files
Contribution expectations
- ✅ Open changes through pull requests
- ✅ Require review before merge
- ✅ Keep the app local-first
- 🚫 Avoid storing prompts, responses, or raw API keys
- ✅ Add tests for behavior changes
License
llmapi-tracker is released under the MIT License. See LICENSE.
Metadata
Release files for llmapi-tracker 1.0.8
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 |
|---|---|---|---|---|
| llmapi_tracker-1.0.8.tar.gz | 115.5 kB | Without provenance | Details for llmapi_tracker-1.0.8.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| llmapi_tracker-1.0.8-py3-none-any.whl | Python 3 | none | any | Details for llmapi_tracker-1.0.8-py3-none-any.whl |
Total release size: 232.2 kB
Release files / llmapi_tracker-1.0.8.tar.gz
| Download URL | llmapi_tracker-1.0.8.tar.gz |
|---|---|
| Size | 115.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
08d23f60af4c169b94948a73b37017b8687d3df790ec464f2fc61135a65374dc
|
|
BLAKE2b-256 checksum How to use checksums |
34970e608445b7a4cc2bd0a45ff7ee8ec01b0079944e38b335ae52cd5a217f3c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.1
|
Release files / llmapi_tracker-1.0.8-py3-none-any.whl
| Download URL | llmapi_tracker-1.0.8-py3-none-any.whl |
|---|---|
| Size | 116.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9c2f480abb65c439ea99ff983ac9666433c678fb747f135b1e656f98a5dae10a
|
|
BLAKE2b-256 checksum How to use checksums |
05c4b84f677a0e71310efa1a1154ac4ca4925a8e02ef3706e94fa0140509898a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.1
|
Security for llmapi-tracker 1.0.8
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.