Skip to main content

ADK Cost Tracker

PyPI - Version License: Apache-2.0 CI Python 3.10+

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:

  1. Model Key: A string identifier (e.g., "gpt-4o", "gemini-1.5-pro").
  2. 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

Release files for adk-cost-tracker 0.1.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for adk-cost-tracker 0.1.6
File Size Uploaded
adk_cost_tracker-0.1.6.tar.gz 94.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for adk-cost-tracker 0.1.6
File Interpreter ABI Platform
adk_cost_tracker-0.1.6-py3-none-any.whl Python 3 none any Details

Total release size: 115.6 kB

Release files / adk_cost_tracker-0.1.6.tar.gz

Download URL adk_cost_tracker-0.1.6.tar.gz
Size 94.1 kB
Tags Source
SHA-256 checksum
How to use checksums
6020c3ace8dd03acaf7e7a428909d13b5ca282eed28e7916be871a1761366b19
BLAKE2b-256 checksum
How to use checksums
b833292635b08010084b2f44612bffcbd256aeb214d97ef8b2df554ca911bb41
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 16, 2026.

Transparency log

Release files / adk_cost_tracker-0.1.6-py3-none-any.whl

Download URL adk_cost_tracker-0.1.6-py3-none-any.whl
Size 21.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c4b27fbaeb55e5beb3021746b837aa8682e3a74dd52516fcf88204c3404e7b0e
BLAKE2b-256 checksum
How to use checksums
a58a779440a6a4b58bf863412dddc8609fc5912edbca53524e2500fe2d2f191c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 16, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.6 This release

2 release files

0.1.5

2 release files

0.1.4

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page