Centralized, provider-agnostic LLM cost tracking and pricing management for Google ADK
Project description
ADK Cost Tracker
Centralized, provider-agnostic LLM cost tracking and pricing management for Google ADK.
ADK Cost Tracker is a lightweight observability layer for Python 3.10+ that intercepts LLM usage and persists it to a shared database. It solves the "distributed pricing" problem by using your database as the Source of Truth for model costs across all your services.
Feature Matrix
| Feature | Description |
|---|---|
| Agnostic Core | Treats providers and models as arbitrary keys-no hard SDK dependencies. |
| Centralized Pricing | Store LLM prices in a shared DB; update once, sync everywhere. |
| Shared Storage | Drop-in support for the same PostgreSQL instance used by ADK's SessionService. |
| Auto-Seeding | Automatically populates new databases with current market pricing. |
| CLI Reporting | Generate cross-app cost summaries directly from your terminal. |
| Zero-Config Plugin | Seamless integration with Google ADK agents via CostTrackerPlugin. |
Installation
# Core only (SQLite + Python 3.10+)
pip install adk-cost-tracker
# With PostgreSQL support (Recommended for production)
pip install "adk-cost-tracker[postgres]"
Agnostic Design
ADK Cost Tracker is designed to be provider-blind. It does not include logic for specific LLM SDKs (like OpenAI or Bedrock). Instead, it provides a clean interface that expects:
- Model Key: A string identifier (e.g.,
"gpt-4o","gemini-1.5-pro"). - Usage Metadata: Token counts (input, output, cached).
This allows the library to stay extremely lightweight and future-proof as new providers emerge.
🚦 Quick Start
1. Integrate with Google ADK
The library provides a first-class plugin for Google ADK that automatically captures usage metadata from model responses.
from adk_cost_tracker import CostTrackerPlugin
from adk_cost_tracker.store import make_store
# Connect to your shared ADK database
store = make_store("postgresql://user:pw@host/mydb")
# Initialize the plugin
plugin = CostTrackerPlugin(
store=store,
app_name="finance_agent",
sync_pricing=True, # Syncs local memory with DB values at startup
verbose=True
)
# Add to your ADK Runner
runner = Runner(
agent=agent,
app_name="finance_agent",
plugins=[plugin]
)
2. Centralized Pricing Management
You can update pricing globally for all your apps by updating the llm_pricing table in your database.
from adk_cost_tracker.pricing import registry
from adk_cost_tracker.store import make_store
async def update_global_prices():
store = make_store("postgresql://user:pw@host/mydb")
# Update a specific model price
await store.update_price(
model_key="gpt-4o",
provider="openai",
input_per_m=2.50,
output_per_m=10.00
)
# All ADK apps will reflect this change on their next sync/restart.
📊 Comparison
| Feature | ADK Cost Tracker | Microsoft Presidio / Others |
|---|---|---|
| Focus | FinOps & Cost Observability | PII Redaction / Content Safety |
| Storage | Self-hosted (Postgres/SQLite) | Cloud-specific or SaaS |
| Pricing | Centralized in YOUR DB | Hardcoded or API-polled |
| Integration | Native ADK Plugin | Generic Wrappers |
Developer Info
Running Tests
# Install dev dependencies
uv sync --dev
# Run pytest
uv run pytest tests
Linting
uv run ruff check src tests
📜 License
Distributed under the Apache License, Version 2.0. See LICENSE for more information.
Copyright © 2026 Sthitaprajna Sahoo
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 adk_cost_tracker-0.1.4.tar.gz.
File metadata
- Download URL: adk_cost_tracker-0.1.4.tar.gz
- Upload date:
- Size: 66.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
beba5a6d1b59a97dc187c2e423ce4a54719542037e9f7b31ac30850e4b7ae8e3
|
|
| MD5 |
f430da27947ba2ae8af34ec857af6726
|
|
| BLAKE2b-256 |
f8457f5e3e1022c87bc41dcf24136fbcd3e21238ff10fa7d75f0f31b34e8c56e
|
Provenance
The following attestation bundles were made for adk_cost_tracker-0.1.4.tar.gz:
Publisher:
release.yml on STHITAPRAJNAS/adk_cost_tracker
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
adk_cost_tracker-0.1.4.tar.gz -
Subject digest:
beba5a6d1b59a97dc187c2e423ce4a54719542037e9f7b31ac30850e4b7ae8e3 - Sigstore transparency entry: 1316162930
- Sigstore integration time:
-
Permalink:
STHITAPRAJNAS/adk_cost_tracker@213f2c9aee8d60d6b94ea7f8c3f590726cc419c3 -
Branch / Tag:
refs/tags/v0.1.4 - Owner: https://github.com/STHITAPRAJNAS
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@213f2c9aee8d60d6b94ea7f8c3f590726cc419c3 -
Trigger Event:
push
-
Statement type:
File details
Details for the file adk_cost_tracker-0.1.4-py3-none-any.whl.
File metadata
- Download URL: adk_cost_tracker-0.1.4-py3-none-any.whl
- Upload date:
- Size: 21.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aeb061a48a2a0570718040d3898cb9284cd07d7f50047ce0c0c5dc0cb3c87e7b
|
|
| MD5 |
cc317907414fade53d457efa6a603c5a
|
|
| BLAKE2b-256 |
3f3da09023c8b02d2ac033a4008345922a897b8c4e95dcee6e0a3394de56a832
|
Provenance
The following attestation bundles were made for adk_cost_tracker-0.1.4-py3-none-any.whl:
Publisher:
release.yml on STHITAPRAJNAS/adk_cost_tracker
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
adk_cost_tracker-0.1.4-py3-none-any.whl -
Subject digest:
aeb061a48a2a0570718040d3898cb9284cd07d7f50047ce0c0c5dc0cb3c87e7b - Sigstore transparency entry: 1316162968
- Sigstore integration time:
-
Permalink:
STHITAPRAJNAS/adk_cost_tracker@213f2c9aee8d60d6b94ea7f8c3f590726cc419c3 -
Branch / Tag:
refs/tags/v0.1.4 - Owner: https://github.com/STHITAPRAJNAS
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@213f2c9aee8d60d6b94ea7f8c3f590726cc419c3 -
Trigger Event:
push
-
Statement type: