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.5.tar.gz (67.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.5-py3-none-any.whl (21.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: adk_cost_tracker-0.1.5.tar.gz
  • Upload date:
  • Size: 67.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.5.tar.gz
Algorithm Hash digest
SHA256 f9f2866cfb340d8e11324db1f13e7543e2baef9a8fe20486a9e6c0909b72b792
MD5 8dde437f277cfae15b9eb556bcffafc7
BLAKE2b-256 bf2476f91e767c249add60106e3bbe0ca3ff370ad64a617fec9f3b19a9340ba7

See more details on using hashes here.

Provenance

The following attestation bundles were made for adk_cost_tracker-0.1.5.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.5-py3-none-any.whl.

File metadata

File hashes

Hashes for adk_cost_tracker-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 169979fddc048a91764afeca02678ca8e83c6381526a16d29284195df017d030
MD5 a8a1273c5ec5d2e71cd6781066440ff0
BLAKE2b-256 981474608435b1b7407cb3bd88f96a2f280f6aca2dd4044afefd390a8217545d

See more details on using hashes here.

Provenance

The following attestation bundles were made for adk_cost_tracker-0.1.5-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