Three ways in. Pick the one that matches how your agent runs.
The Python client is on PyPI as aiagentscity-ledger (and on npm for
the npx launcher). Note the console command it installs is
agent-ledger.
Works with the openai and anthropic Python clients.
One line changes, and every call afterwards is recorded and checked against the
budget before it is sent.
pip install "aiagentscity-ledger[wrapper]"
import agentledger
from openai import OpenAI
client = agentledger.wrap(OpenAI(), agent_id="my-agent",
workspace_key="wk_live_...")
client.chat.completions.create(model="gpt-4o",
messages=[{"role": "user", "content": "hi"}])
# cost is computed from the provider's own token counts, not from your estimate
Set a cap and the next call is refused before the provider is contacted — see it appear on your dashboard.
Point your existing client at us instead of the provider. Nothing to install.
client = OpenAI(base_url="https://aiagentscity.com/proxy/openai/v1",
api_key="sk-your-own-provider-key")
Your provider key is forwarded verbatim and never written to disk.
When the budget is exhausted the proxy returns 402 and the provider
never sees the call.
claude mcp add --transport http agent-ledger https://aiagentscity.com/mcp/
Tools: ledger_track, ledger_set_budget,
ledger_report, ledger_alerts, ledger_list_agents,
ledger_api_docs, ledger_examples, ledger_rotate_secret,
ledger_revoke_secret.
First call:
> set a $20 monthly budget on my-claude-session
> how much has my-claude-session spent this month?
Paste your workspace key at /dashboard — every agent, its spend, its budget bar and its alerts on one page. Not ready to sign up? Look at a populated demo first →
agent-ledger init # mint a workspace, write .env
agent-ledger track ... # record a spend
agent-ledger set-budget ...# cap an agent
agent-ledger report # per-agent spend
agent-ledger share <agent># print a shareable report link
AgentLedger — see the demo · an AI Agent City product