Catalog PyPI
PACKAGE EXPLORERView in registry

agentbills

PyPI

LLM cost intelligence + budget enforcement for AI agent fleets

Versions collected1
Direct dependencies5From release 0.2.0
Last observed20 Oct, 21:33 UTC

README

Version 0.2.0 documentation

agentbills

LLM cost intelligence + budget enforcement for AI agent fleets.

The Python SDK for AgentBills. Drop one line at the top of your agent and every OpenAI / Anthropic / Bedrock call reports a cost event to your dashboard.

Install

pip install agentbills[all]

Provider-specific installs are available if you only use one:

pip install agentbills[openai]      # only the OpenAI library
pip install agentbills[anthropic]   # only the Anthropic library
pip install agentbills[bedrock]     # only boto3 / Bedrock

Quick start — auto-instrument

from agentbills import instrument

instrument()  # patches openai/anthropic/bedrock libs at import time

# nothing else changes — your existing client calls now report events
import openai
client = openai.OpenAI()
client.chat.completions.create(model="gpt-4o-mini", messages=[...])

Set AGENTBILLS_API_KEY in the environment and you're done:

export AGENTBILLS_API_KEY=blaze_sk_...

Or pass it explicitly: instrument(api_key="blaze_sk_...").

Tag events with custom metadata

set_metadata() attaches a dict to every event generated in the current context (works across await boundaries):

from agentbills import set_metadata

set_metadata({"feature": "summarize", "user_id": "u123"})
response = openai_client.chat.completions.create(...)
# the event for this call carries feature=summarize, user_id=u123

To pin the agent name for a specific call instead of relying on fleet_name:

set_metadata({"agent_id": "researcher"})

Explicit-wrap pattern

If you'd rather not monkey-patch globally, wrap a specific client:

import openai
from agentbills import AgentBillsClient, wrap_openai_client

ab = AgentBillsClient(api_key="blaze_sk_...")
openai_client = wrap_openai_client(openai.OpenAI(), ab, agent_name="researcher")

Decorator pattern (for explicit fleets)

from agentbills import Fleet

fleet = Fleet(api_key="blaze_sk_...")

@fleet.agent("researcher")
def run(query: str):
    ...

print(fleet.dashboard_url)

Flushing before exit

The SDK buffers events and flushes in batches. For short-lived scripts, flush explicitly:

client = instrument()
# ... your agent code ...
client.flush()

For long-running services this isn't necessary — the buffer flushes automatically on every batch_size events.

Migrating from blaze-agents 0.1

The old package was blaze-agents with imports like from blaze import …. v0.2 renames to agentbills and adds the instrument() entry point.

# OLD
from blaze import Fleet, BlazeClient

# NEW
from agentbills import Fleet, AgentBillsClient   # BlazeClient is a back-compat alias

The from blaze import … path no longer works — update your imports.

License

MIT.

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Versions 1

Collected releases
VersionPublishedDirect dependenciesOpen version
0.2.023 May 20265

Package advisories

0
No matching advisories collected

This describes our collected data; it is not a security assessment.

Repository

PENDING
vivekreddy99/blaze-api

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 21:33 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package:e7c13e2d1e72259dc837d511d92ac67a72103cab2ef077a7570a93530a9dfb19