Skip to content
Runtime

What is a spending limit?

A spending limit caps how much a key, a job or a machine can cost. Runtime enforces it before the money is spent, not after the bill arrives.

Runtime has three spending limits, and the outermost one means you can never owe money. Credit is prepaid, so a bill cannot exceed your balance. Each key can have a daily limit. Each sandbox can have a lifetime limit (security). A refused request charges nothing.

Why it matters for AI agents

An agent that loops can start a machine on each iteration, forget to stop them, or retry a failing step all night. A person would notice by morning. A budget alert would notice after the money is gone. A limit checked on each request stops the next create instead, and gives the agent a clear error to act on. This matters most for agents that run unattended: overnight evals, CI, and agents that other people's prompts can steer.

The three layers on Runtime

Layer Scope What happens at the cap
Prepaid balance The account Charges stop at zero; you never owe money
Daily spending limit One key's agent, any 24 hours Create, wake, extension or renewal fails with spending_limit_reached (HTTP 402)
maxTotalCostMicros One sandbox, its whole life The most the sandbox may cost from start to end

The daily limit counts what is already charged. It also counts what running sandboxes are about to use, including renewals and parked storage. Room returns as older spending leaves the window. When the limit is reached, a running sandbox keeps the time it is already funded for. Set the limit above what the agent's paused sandboxes cost in a day. Paused storage that cannot be paid for is treated like storage on an empty balance. Runtime sends a notice, and deletes the storage seven days later.

Amounts are in microdollars, millionths of a dollar: 5_000_000 is $5.

Cap one sandbox

TypeScriptimport { RuntimeError, Sandbox } from "withruntime";try {  await using sbx = await Sandbox.create({    maxTotalCostMicros: 5_000_000, // at most $5 over its life  });  console.log((await sbx.exec("echo ok")).stdout);} catch (error) {  if (error instanceof RuntimeError && error.code === "spending_limit_reached")    console.log("over this key's daily limit; stop and ask");  else throw error;}
Pythonfrom withruntime import Runtime, RuntimeErrorruntime = Runtime()try:    with runtime.sandboxes.create(        max_total_cost_micros=5_000_000    ) as sbx:        print(sbx.exec("echo ok").stdout)except RuntimeError as error:    if error.code != "spending_limit_reached":        raise    print("over this key's daily limit; stop and ask")

The SDKs do not retry spending_limit_reached. An agent that receives this error should stop and tell the person it works for.

What a limit costs you in room

For scale, a 2 vCPU, 4 GiB sandbox costs $0.03125 an hour while it waits on a model. It costs $0.08 an hour with both CPUs busy. A $25 daily limit covers about 313 fully busy sandbox-hours a day at that size (pricing).

Who can set one

Only the member who made a key, or an owner or admin, can set, change or remove that key's daily limit. They do this on the website, on the API keys page. No key can raise, remove or set a limit. Every change is recorded in the audit log.

Facts on this page were checked on 25 October 2026.

100 free hoursin your first 30 days.

of a 1 GB machine

  • No credit card
  • Four sandboxes at once, 2 vCPU and 4 GiB each
  • Then prepaid credit from $10, no plan fee
Start free, no card
Start free, no card