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

Uploaded Python 3

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

Hashes for adk_cost_tracker-0.1.4.tar.gz
Algorithm Hash digest
SHA256 beba5a6d1b59a97dc187c2e423ce4a54719542037e9f7b31ac30850e4b7ae8e3
MD5 f430da27947ba2ae8af34ec857af6726
BLAKE2b-256 f8457f5e3e1022c87bc41dcf24136fbcd3e21238ff10fa7d75f0f31b34e8c56e

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for adk_cost_tracker-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 aeb061a48a2a0570718040d3898cb9284cd07d7f50047ce0c0c5dc0cb3c87e7b
MD5 cc317907414fade53d457efa6a603c5a
BLAKE2b-256 3f3da09023c8b02d2ac033a4008345922a897b8c4e95dcee6e0a3394de56a832

See more details on using hashes here.

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

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