ACPpotamia

Advanced guide / Chapter 2 of 7

Budgets and limits.

Most spend alerts arrive after the money is gone. ACPpotamia works the other way round: every call reserves its cost before it is sent. However many agents run at once, together they can't spend more than you allowed.

Budget reservation: each call holds its cost before it is sent, then the real cost replaces itBefore: $55 of $100 spent1 Two calls arrive at once: each holds its estimated cost (gold) before it is sent2 They finish: the real cost (often less than held) is added, the hold is releasedA third call that arrives while money is held sees only what is truly left. If that is not enough for a full answer,its max_tokens is lowered to what the budget can pay for. If nothing is left, it gets HTTP 402 and never reaches the provider.spentheld for calls in progressavailable
Money for calls in progress is held first. When each call ends, the hold is swapped for the real cost.

Four levels, all checked together

How limits stack: organization, team, then key, tenant and sessionOrganizationmodel policy · kill switch for every team · combined exportTeammonthly budget · token limit · requests a minute · model policy · kill switch · fail modeAPI keymonthly budgetrequests a minuteallowed modelstest key or real keyTenant (your customer)X-ControlPlane-Tenant-Idmonthly budgetrequests a minutedefault + per-customer overrideSession (one task)X-ControlPlane-Session-Idrequests a minutetotal spend for the taskloop detection · stop/revive
Limits stack. A call must pass the team's limits and the limits of its API key, its tenant and its session.
LevelLimitsResetsWhere to set it
TeamMonthly budget, monthly tokens, requests a minute1st of each month (UTC)Console → Limits
API keyMonthly budget, requests a minute, allowed models1st of each monthConsole → API keys → Set limits
Tenant (Pro, Enterprise)Monthly budget, requests a minute; a default plus each customer's own1st of each monthConsole → Limits and Tenants, or the Tenant API
SessionRequests a minute, total spend for the taskNever (one session = one task)Console → Limits

A worked example

A company sets a team budget of $500 a month. Its CI pipeline uses its own key capped at $20. Its product gives every customer $25 a month by default, and one large customer $200. Each agent task may spend at most $2 and make 30 requests a minute.

SituationWhat happens
A test suite loops overnight on the CI keyIt stops at $20 with 402 key_budget_exhausted. Production keys are untouched.
Customer 4821 reaches $25Their calls get 402 tenant_budget_exhausted. Every other customer keeps working.
One support task keeps searchingAt $2 it gets 402 session_budget_exhausted; loop detection often stops it earlier.
All of the above at once, near month endThe team cap of $500 still holds over everything.

When a budget is nearly used up

Say a call asks for a long answer but the budget can only cover part of it. ACPpotamia lowers that call's max_tokens to what's left, and the call still succeeds with a shorter answer. Once nothing is left, calls get HTTP 402 and never reach the provider.

Handling limits in your code

TypeScript

try {
  const reply = await client.chat.completions.create({ model: "gpt-5-mini", messages });
} catch (err) {
  const code = err?.error?.code;            // the same shape OpenAI and Anthropic SDKs expose
  if (err.status === 402) {
    // A budget is used up: show a friendly message, offer an upgrade, or wait for the 1st.
  } else if (err.status === 429 && code?.endsWith("rate_limited")) {
    // Back off for err.headers["retry-after"] seconds, then retry.
  } else if (code === "loop_detected" || code === "session_killed") {
    // Do not retry: fix the agent, then revive the session in the console.
  }
}
Good to know. Input tokens are estimated before a call (roughly four characters per token) and corrected when it settles. If many calls are in flight just as a budget runs out, you can go over by a few cents.
Tip. On the Limits page, set output reserved per call close to your typical answer length. Smaller holds mean more calls can run in parallel when a budget is nearly spent.