Product · · 6 min read
Give every AI key a budget
A key that reaches the right service can still be used for the wrong thing, or a thousand times in a loop. Quiet Robot Sandboxes now let you limit each saved key to the calls it needs and give it a budget for each run and each month.

When you hand an AI agent one of your API keys, you are handing it a company credit card. Most of the time it buys what you asked for. The worry is the other times.
An agent can get stuck in a loop and ask the same question five hundred times overnight. A web page or an email it reads can carry hidden instructions that tell it to do something you never wanted, a trick called prompt injection. Or it can simply misread the job and start deleting files with a key that was meant for reading them.
Quiet Robot Sandboxes already keep the key itself out of the agent's reach. We wrote about that in Your keys never enter the sandbox: the agent holds a stand-in, and the real key is added outside the sandbox, for the services you list. That answers "where can this key go?"
This post is about the next two questions: what may the key do there, and how much may it spend?
Two limits on every key
Each key you save can now carry two kinds of limits.
Rules say which calls the key may make. You list them in plain form: a method, such as POST or GET, and a path. Once a key has rules, every other call is refused before it reaches the service. Some examples from our docs:
| Rule | What it allows |
|---|---|
POST /v1/chat/completions |
Chat calls, nothing else |
GET,HEAD /v1/models/* |
Reading one model at a time |
GET /repos/acme/** |
Reading anything in the acme repositories |
So a key for an AI chat service can be held to chat calls. It can't be used to delete your stored files or change account settings, even if an agent is tricked into trying. A code-hosting key can be held to reading your own repositories, and nobody else's.
Budgets say how much the key may use. You set a number of requests, a dollar amount, or both, and you set them at two levels:
- Per run. A run is one sandbox, or one whole Agent Playground run.
- Per month, by calendar month.
A key might get $2 per run and $50 per month. Another might get 200 requests per run and no monthly cap at all. Keys with no rules and no budget keep working as they do today.
What happens near the limit
At 80% of a budget, the owners and admins of your organization get an email. That is your chance to look before anything stops. Maybe the month is busier than usual and the limit should go up. Maybe something is looping and needs a look.
At 100%, the key's calls are refused until the run ends, the month ends, or someone raises the budget. The agent gets a clear refusal instead of a surprise on your bill.
One honest detail from the docs: a call that starts under a dollar budget is allowed to finish. So a run can go past its dollar budget by one call, not by a hundred.
Why this matters for a small team
You don't need a security department to get value from this. Three everyday cases:
The loop at 2 a.m. An agent keeps retrying a step that will never pass. Without a budget, it keeps spending until someone wakes up. With a $2 per run budget, the run stops at $2 and you read about it over coffee.
The planted instruction. An agent reads a customer email that says, in hidden text, "delete everything in the account." If the key's rules allow chat calls and nothing else, the delete call is refused. The limit lives outside the agent, so what the agent was told doesn't change it.
The key you forgot about. A key set up for a test six months ago is still saved. A monthly budget means even a forgotten key has a ceiling.
Tighter for one job, never looser
Sometimes one job deserves less than the key's usual budget. Maybe it's a quick test, or an agent you haven't watched before.
A single sandbox can ask for a tighter per-run budget for a key when it starts. A Playground flow can do the same for its own runs. Either one can lower the key's budget for that run. Neither can raise it.
That matters when agents start their own sandboxes. An agent can't give itself more room than you gave the key. Raising a budget is a person's decision, made on the Policies page.
Every refusal is on the record
When a rule or a budget stops a call, it goes into your audit log, and the entry says which one stopped it. The 80% warning and the moment a budget runs out are logged too. If someone asks "why did the agent stop last night?", the answer is a click away.
Where to set it
In the dashboard. Open Policies, then Secrets. Each saved key has an Edit rules and budget link on its row. Type the allowed calls one per line, fill in the budget boxes you want, and save. The row also shows this month's use, so you can see at a glance which keys are busy.
From code or your AI assistant. The same settings are in the API, the TypeScript SDK, the Python SDK, the command line and the MCP server. From the command line it's one line:
qr secret-limits OPENAI_API_KEY --rule 'POST /v1/chat/completions' --per-run requests=200,usd=2 --per-month usd=50
You don't send the key's value again to change its limits.
For a Playground flow, set policy.keyBudgets to give the flow's runs a tighter budget. The Playground safety page explains how key budgets sit alongside a flow's own limits on time, loops and spend.
How it fits with your other limits
Key budgets sit next to the limits you may already use:
- Spend caps on a sandbox or an API key limit what the sandbox itself costs to run. They are on the Billing and usage page and in Plans and limits.
- Approvals make a risky command wait for a person. See Every AI helper needs a supervisor for why that matters, and the Approvals docs for how.
- Network rules decide which sites a sandbox can reach at all. See Outbound network.
Each one answers a different question. Together they mean an agent has a clear job, a clear allowance and a person in charge of both. If you want to see all of these working in one flow, Let it run without watching walks through it.
Start with one key
Pick the key your agents use most. Give it the two or three calls it really needs and a monthly budget a little above what you spend today. Watch for the 80% email. Then do the next key.