How to cap AI spend per task

To cap AI spend per task, enforce a hard dollar limit at the proxy, before the request leaves your machine, scoped to that one job rather than the whole account. RelayPlane does this for free with a single request header: set X-RelayPlane-Run-Cap-Usd on a run and the proxy returns a 429 the moment that run would cross the limit, instead of letting one runaway loop drain the budget.

It also supports caps per request, per session, and per day, plus a one-command kill switch that halts every routed request across every task at once.

npm install -g @relayplane/proxy
relayplane start
relayplane cap set --day 50
# Or per-run, via request header:
curl http://localhost:4100/v1/messages \
  -H "X-RelayPlane-Run-Cap-Usd: 2.00" \
  -H "X-RelayPlane-Run: nightly-backfill"

Per-task spend caps, compared

How each tool scopes and enforces a spend limit for a single task or run.

FeatureRelayPlaneLiteLLMOpenRouterPortkey
Cap scopePer request, per run, per session, per dayPer virtual key, team, or user (org-level)Per API key, account-levelPer virtual key, config-level
Enforced before the request leavesYes, at the proxyYes, at their cloudYes, at their gateway
One header caps a single jobX-RelayPlane-Run-Cap-UsdRequires a pre-provisioned virtual key with a budgetNot per-call, account or key level onlyRequires a pre-provisioned config
Kill switch, halt all traffic instantlyBlock a virtual key via admin APIDisable a config
Runs locally, no account needed to set a cap
Cost to set up a capFree, MITFree (OSS) + paid enterprise tierFreeFree tier, paid for team budgets

Sources: RelayPlane budget cap docs, LiteLLM budgets docs, OpenRouter limits docs, Portkey budget limits docs.

Frequently asked questions

How do I cap AI spend per task?

Set a hard dollar limit that the proxy checks before forwarding the request, not a limit you find out you hit after the invoice arrives. RelayPlane exposes this as a request header, X-RelayPlane-Run-Cap-Usd, so a single job or agent run can carry its own budget. Once that run would cross the cap, the proxy returns a 429 with budget_exceeded instead of letting the call through.

Can I cap spend for a single agent run without capping the whole account?

Yes. RelayPlane supports caps at multiple scopes at once: per request, per run, per session, and per day. A per-run cap stops one runaway job without throttling everything else on the machine.

Is there a free way to cap LLM spend per task?

RelayPlane is free and MIT licensed with per-run caps included, no paid tier required. LiteLLM also supports budgets for free when self-hosted, scoped to virtual keys rather than a single header per call. OpenRouter and most hosted gateways cap at the API key or account level, not per individual task.

What happens when a task hits its spend cap?

With RelayPlane the proxy can block the request (429 budget_exceeded), downgrade it to a cheaper model, or just warn, depending on the onBreach policy you set. The kill switch is separate: one command halts all routed traffic immediately across every task, with an audit trail of what was stopped.

Cap your first run for free

MIT licensed. No credit card, no account required to set a cap.

Read the budget cap docs