Rightshold™ Sign up

Answers · agent payments

How do I give each AI agent its own budget when they call paid APIs?

Last updated

TL;DR: Give every agent its own key, and put the cap on that key or on the project or workspace the key belongs to, not on the whole account. OpenAI caps spend per project: make one project per agent, use that project's keys, and set a monthly spend limit with Enforce a hard limit turned on (requests then fail with 429 project_spend_limit_exceeded). In the Claude Console, put each agent in its own workspace and set a monthly workspace spend limit (not available on the Default Workspace, and never above the organization's limit). OpenRouter caps each API key directly, with a daily, weekly or monthly reset (requests fail with 403 Key limit exceeded). Keep a lower organization-wide limit above all of them, and remember that provider caps are monthly or daily and not instantaneous, so a runaway agent can still spend real money before it stops.

What should I check, step by step?

1. Never let two agents share a key. A shared key makes per-agent caps and per-agent cost reports impossible, and revoking it stops every agent at once.

  1. OpenAI: create a project per agent (or per agent team), issue that agent's keys inside it, then in Project settings > Limits set a Monthly spend limit and turn on Enforce a hard limit. Without that switch, the limit only monitors spend and requests keep going.
  2. OpenAI by API: an Admin API key can set the same cap with POST /v1/organization/projects/{project_id}/spend_limit, where threshold_amount is in cents and only USD and a monthly interval are supported.
  3. Claude: create a workspace per agent and set its Spend limits on the Workspaces page. You can't set a spend limit on the Default Workspace, so don't run agents there, and per-workspace rate limits are a second brake.
  4. OpenRouter: give each agent key its own limit and limit_reset (daily, weekly or monthly, resetting at midnight UTC). If the agent uses your own provider keys through OpenRouter (BYOK), set include_byok_in_limit to true, or that spend never counts toward the cap.
  5. Keep an organization-level cap set lower than the sum you could tolerate losing. Per-agent caps stop one agent; the organization cap stops a mistake that creates many agents.
  6. Handle the refusal in code: treat 429 project_spend_limit_exceeded (OpenAI) or 403 Key limit exceeded (OpenRouter) as a stop-and-tell-a-human signal, not an error to retry.
  7. For paid APIs that have no per-key budget, check each call against a policy of your own before the agent makes it, and keep the running total somewhere the agent can't edit.

What each provider actually enforces

OpenAI's spend limits guide says a hard spend limit can be set for the organization or an individual project, is monthly, and returns a 429 with organization_spend_limit_exceeded or project_spend_limit_exceeded once tracked spend reaches it. Spend alerts only send notifications and never stop traffic.

Why the caps leak a little

OpenAI says enforcement is not instantaneous and recorded spend can slightly exceed the configured amount while the limit state propagates. Plan for overshoot: set the cap below what you can afford, not at it.

How do I ask Rightshold about this (free, no key)?

Add the MCP server https://www.rightshold.com/mcp to Claude, Cursor, ChatGPT, Grok or VS Code, then ask: “Before my research agent calls a paid API, check a $0.40 call to api.example-data.com against its own spending policy ($2 per call, $20 a day) and tell me whether to proceed.”

One-click setup

{
  "tool": "authorize_spend",
  "arguments": {
    "credential_id": "<this agent's credential id>",
    "amount_minor": 40,
    "currency": "USD",
    "merchant_domain": "api.example-data.com",
    "category": "data_api",
    "reference": "<your request id>"
  }
}

Rightshold records spending decisions; it never holds or moves money and doesn't connect to OpenAI, Anthropic or OpenRouter billing. Its policy only covers calls your agent checks with authorize_spend before making them, so keep the provider caps on as well. Not financial advice.

What are the sources?

Related

Not legal advice. JSON · Markdown · All answers

Get a free API key in one call

No card and no email needed. 100 free credits; the license and policy checks stay free without a key.

curl -s -X POST https://www.rightshold.com/v1/accounts/signup -H "Content-Type: application/json" -d '{"accept_terms":true}'
export RIGHTSHOLD_API_KEY=rs_...   # the api_key from the reply (shown once)
curl -s https://www.rightshold.com/v1/licenses/check -H "Authorization: Bearer $RIGHTSHOLD_API_KEY" \
  -H "Content-Type: application/json" -d '{"license":"MIT","intended_use":{"commercial_use":true}}'