Black Friday: 10% off every GPU you launch, no code needed. Until 30 Nov. Rent a GPU

Arrakis / Blog / AI agents

AI Agent Spend Limit for GPUs: Know the Worst Case

An AI agent with a GPU and no spend limit is an open tab at the most expensive bar in town. On Arrakis, the AI agent spend limit for GPUs lives in the API itself: the agent's token carries a spend cap, every rental it makes carries a removal time, and the worst case is a number you can work out before the agent starts. Here is how the limits work, with real prices, and the setup we would use.

The worst case, in one line

Every rental has a worst case:

worst case = price per hour x removal hours

A token with a spend cap adds up the worst cases of every rental it makes. The rental that would push the total past the cap is refused with a 402, before any market is asked for a machine. No partial rentals, no "we'll bill you later".

That makes the cap a hard number. Not an alert, not an email after the fact: the API says no.

Four limits on one token

Create the agent's token under API & agents in the console, or with POST /v1/tokens:

Limit Field What it stops
Spend cap spend_limit_usd Committing more than this, ever, at worst case
Longest rental max_rental_hours Rentals with no removal time, or a longer one
Expiry expires_at A forgotten token that works forever
Scopes read, rent Minting tokens, saving keys, touching billing

Give agents read and rent only. A token can never create a token with scopes it lacks or caps above its own, so an agent without the manage scope cannot mint anything at all.

Do the math before the agent does

Numbers make this concrete. Say an 8x B300 costs $50 an hour (the console shows today's price). Give an agent a $100 cap and a 4-hour longest rental, and watch what happens:

The agent asks for Worst case Answer
8x B300 for 4 hours $200 Refused: passes the $100 cap
8x B300 for 2 hours $100 Rented: the whole cap committed
Another 8x B300 for 1 hour $50 Refused: no cap left
8x B300 for 6 hours $300 Refused: longer than 4 hours

Now the part people miss. Say the agent finishes in 40 minutes and stops the 2-hour machine. Your balance pays one hour, $50, because a started hour counts in full. The cap still counts $100. The cap is a lifetime budget of commitments, not a meter of usage: stopping early saves you money, not cap.

So size the cap per job, not per year, and mint a fresh token for the next one. A cap that runs out is the system working.

Removal times: the second wall

A capped token cannot rent without termination_hours, and never past its longest rental. When the time comes, the machine is removed: billing stops and its disk is deleted. A crashed agent, a lost connection, a model that forgot what it was doing: none of them can leave a GPU running past its removal time.

The agent can end things sooner. schedule_removal moves a removal earlier, and terminate_instance stops a machine now. With a capped token it cannot move a removal later or cancel one. Extending a run is a human decision.

Our advice for prompts: removal hours = the expected run plus a margin. Not a round day "to be safe". The day is not safe; it is up to 24 billed hours.

The balance: the third wall

Arrakis is prepaid. A rental pays its first hour when the machine starts running and each later hour as it begins. When the balance cannot pay a machine's next hour, that machine stops and rentals pause until a person adds funds. An agent cannot add funds: only confirmed payments do that.

One catch. If you turn on auto-recharge, a saved card tops the balance up below your threshold, or once it would last less than 3 hours. Convenient, and it also removes this wall. With auto-recharge on, the token cap is your hard ceiling, so set it like one.

And when you want everything off at once, Stop everything (on Instances or Billing, or POST /v1/billing/stop with a billing-scoped token) stops every machine now and pauses rentals. Volumes are kept. The billing docs have the full order of events.

Retries never rent twice

Agents retry. Networks drop. Without protection, a retried rent call is a second machine on your bill.

  • Send a stable idempotency_key and the same key always returns the same machine.
  • Over MCP, a call without a key that repeats the same machine, name and hours within 10 minutes returns the first machine too.
  • Send max_price_per_gpu_hour with the price the agent showed you. If the live price is higher, nothing is rented and the answer (a 409 over the API) carries the new price.

Watch it without babysitting it

  • get_balance shows the token's cap, what is committed, what remains, its longest rental and its expiry.
  • Every MCP tool result carries the last day's alerts: a host's notice, a host that stopped answering, an eviction. A token with the billing scope also hears when the balance is about to run out or rentals are paused; a read-and-rent agent token does not, which is one more reason to watch the balance yourself.
  • get_events (or GET /v1/events) lists what happened to each machine: ready, ended and why.
  • A webhook under Notifications in the console pushes each event as it happens, signed with Arrakis-Signature.

The setup we would use

One token per agent and job. Read and rent. A cap you would approve without a meeting. A longest rental of the longest job plus an hour. An expiry a week out. Revoke it when the job ships.

Shell
curl -X POST https://arrakis.goodailabs.com/v1/tokens \
  -H "Authorization: Bearer $ARRAKIS_MANAGE_TOKEN" -H "Content-Type: application/json" \
  -d '{"name": "eval-agent", "scopes": ["read", "rent"], "spend_limit_usd": 100,
       "max_rental_hours": 4, "expires_at": "2026-11-22T00:00:00Z"}'

Then hand it to the agent. Claude Code users: the whole setup is in Claude Code GPU over MCP. Pipelines: a GPU runner for CI uses the same caps. Every rule above lives in the API, so it holds for MCP, plain HTTP and anything else that calls it. More on the agent side: Arrakis for agents.

Cap first, then let it run

Make the token before you write the prompt, and the worst case is settled before the agent says a word. Create a capped agent token.

New here? Use code FIRST25 for $25 off your first deposit of $50 or more, until 31 December 2026.

Rent the GPUs in this post

New here? Use code FIRST25 for $25 off your first deposit of $50 or more, until 31 December 2026.

Lowest price now, per GPU-hour. Billed per started hour; stop any time.

Questions

What is the most an AI agent can spend on Arrakis?
Its token's spend cap. Every rental counts at its worst case, the hourly price times its removal hours, and a rental that would pass the cap is refused before anything is rented.
Does stopping a machine early give the cap back?
No. The cap counts what rentals commit at their worst case, not what they end up costing. Stopping early saves money from your balance, not room under the cap.
Can an agent extend its own rental?
Not with a capped token. It can move a removal earlier, never later, and it cannot cancel one.
What happens if the agent crashes with a GPU running?
The machine removes itself at its removal time, so a crashed agent cannot leave a GPU billing. You can also stop it in the console, or stop every machine at once with Stop everything.

More from the blog

Every postRSS feed