Track Agent Spend
ledger_trackRecord a spend entry for an AI agent on any payment rail, with optional token counts.
Claiming a brand-new agent_id requires your workspace_key (get one via x402 at POST /v1/billing/x402 — no human, no login — or at /start). That first call mints an agent_secret and returns it in the response — save it, every later call for that same agent_id must pass it back (no workspace_key needed again) or the write is rejected. Amounts are capped at $100,000/entry and must be >= 0. If a budget is set for this agent, an entry that would cross the monthly/daily cap is blocked, not just logged. Include tokens_in/tokens_out + model on every LLM call so token burn shows up in the /v1/tokens report.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| rail | Yes | payment rail used — one of "mpp", "x402", "api_key", "manual" | |
| model | No | model name (e.g. "gpt-4o") — token burn is reported per model | |
| service | Yes | what was purchased (e.g. "search_query", "data_export") | |
| agent_id | Yes | unique agent identifier (e.g. "research-agent-v2") | |
| tokens_in | No | prompt tokens consumed (0 if unknown) | |
| tokens_out | No | completion tokens consumed (0 if unknown) | |
| agent_secret | No | required for every call after the first for this agent_id | |
| amount_cents | Yes | spend amount in cents (100 = $1.00), 0-10000000 | |
| workspace_key | No | required when claiming a brand-new agent_id; not needed once the agent_id has been claimed |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||