Skip to main content

Centralized, provider-agnostic LLM cost tracking and pricing management for Google ADK

Project description

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

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

adk_cost_tracker-0.1.6.tar.gz (94.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

adk_cost_tracker-0.1.6-py3-none-any.whl (21.5 kB view details)

Uploaded Python 3

File details

Details for the file adk_cost_tracker-0.1.6.tar.gz.

File metadata

  • Download URL: adk_cost_tracker-0.1.6.tar.gz
  • Upload date:
  • Size: 94.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for adk_cost_tracker-0.1.6.tar.gz
Algorithm Hash digest
SHA256 6020c3ace8dd03acaf7e7a428909d13b5ca282eed28e7916be871a1761366b19
MD5 c1fc372f55f0cb7ce9c9cb0fea2b2f86
BLAKE2b-256 b833292635b08010084b2f44612bffcbd256aeb214d97ef8b2df554ca911bb41

See more details on using hashes here.

Provenance

The following attestation bundles were made for adk_cost_tracker-0.1.6.tar.gz:

Publisher: release.yml on STHITAPRAJNAS/adk_cost_tracker

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file adk_cost_tracker-0.1.6-py3-none-any.whl.

File metadata

File hashes

Hashes for adk_cost_tracker-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 c4b27fbaeb55e5beb3021746b837aa8682e3a74dd52516fcf88204c3404e7b0e
MD5 7773b07dedf5e1c2e808c30ee8181033
BLAKE2b-256 a58a779440a6a4b58bf863412dddc8609fc5912edbca53524e2500fe2d2f191c

See more details on using hashes here.

Provenance

The following attestation bundles were made for adk_cost_tracker-0.1.6-py3-none-any.whl:

Publisher: release.yml on STHITAPRAJNAS/adk_cost_tracker

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page