> ## Documentation Index
> Fetch the complete documentation index at: https://boxrouter.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Stand-In Keys

> Keep your real model key out of agent sandboxes by routing catalog agent calls through BoxRouter's credential gateway.

Catalog agents use a **stand-in key** (`bxc_...`) through BoxRouter's **credential gateway**, so your real model key never enters the sandbox. Code in a sandbox, including repository scripts, can read environment variables with `env`. Each stand-in key works for one sandbox and one service until that sandbox ends.

| Mode | Sandbox Holds | BoxRouter Holds |
| - | - | - |
| Stand-in key | Per-sandbox `bxc_...` key and gateway address | Encrypted real key, added per call |
| Real key | Real key in environment | Encrypted real key |

## How a Model Call Works

1. BoxRouter sets the stand-in key in the key's variable and the gateway address in the API-address variable.
2. The agent sends model calls to the gateway with the stand-in key.
3. The gateway checks the key and the call, inserts your real key, and forwards the request.
4. The gateway streams the reply back.

Most agents launched with `ANTHROPIC_API_KEY` see (`opencode` gets `/anthropic/v1`):

```text theme={"theme":"css-variables"}
ANTHROPIC_API_KEY=bxc_...
ANTHROPIC_BASE_URL=https://gw.api.boxrouter.ai/anthropic
```

## Which Secrets and Agents Get Stand-In Keys

Only `ANTHROPIC_API_KEY`, `OPENAI_API_KEY`, `OPENROUTER_API_KEY`, and `CLAUDE_CODE_OAUTH_TOKEN` (the Claude subscription token) get stand-in keys. Stand-in keys apply only to [catalog agents](https://boxrouter.ai/docs/launch/agents.md), including [copies](https://boxrouter.ai/docs/launch/copies.md), under the same name. Other [secrets](https://boxrouter.ai/docs/launch/secrets.md) (`MY_ANTHROPIC_KEY`, `GITHUB_TOKEN`, or `CURSOR_API_KEY`) enter the sandbox as real values.

| Agent | Stand-In Key | Real Key Only |
| - | - | - |
| `claude-code` | `ANTHROPIC_API_KEY`, `CLAUDE_CODE_OAUTH_TOKEN`, `OPENROUTER_API_KEY` | |
| `codex` | `OPENAI_API_KEY`, `OPENROUTER_API_KEY` | |
| `cursor` | | `CURSOR_API_KEY` |
| `hermes` | | `OPENROUTER_API_KEY` |
| `junie` | `OPENROUTER_API_KEY` | |
| `kilocode` | `OPENROUTER_API_KEY` | |
| `openclaw` | `ANTHROPIC_API_KEY`, `OPENROUTER_API_KEY` | |
| `opencode` | `OPENROUTER_API_KEY`, `ANTHROPIC_API_KEY`, `OPENAI_API_KEY` | |
| `pi` | `ANTHROPIC_API_KEY`, `OPENAI_API_KEY`, `OPENROUTER_API_KEY` | |
| `t3code` | `ANTHROPIC_API_KEY`, `OPENAI_API_KEY`, `OPENROUTER_API_KEY` | |

`hermes` needs the real `OPENROUTER_API_KEY` because it connects directly. Your own agents (manifests or repositories) receive real values and need [real-key delivery](#allow-real-key-delivery).

`cursor` always receives your real `CURSOR_API_KEY`, which every command can read. Cursor's agent cannot redirect calls, and Cursor has no per-sandbox key API.

Use a separate, revocable key from **API Keys** in the Cursor dashboard and revoke it if exposed. Deleting it in BoxRouter does not revoke it at Cursor; `CURSOR_API_KEY` has no setting.

## Check What Your Sandbox Received

* Run `boxrouter agents` to read each agent's `key_delivery` map (`stand_in` or `real_key`).
* Check `credential_delivery` in the launch result for each secret's `mode`.
* Inside the sandbox, verify the `bxc_` prefix:

```bash theme={"theme":"css-variables"}
echo "${ANTHROPIC_API_KEY:0:4}"
```

Output

```text theme={"theme":"css-variables"}
bxc_
```

## Allow Real-Key Delivery

Standard-name secrets are stand-in only by default. To allow real keys, tick **Allow Real-Key Delivery** in the Secrets drawer, set `real_key_allowed` on `PUT /secrets/{name}`, or pass `--real-key`.

```python Python theme={"theme":"css-variables"}
import os

from boxrouter import BoxRouter
from boxrouter.models import PutSecret

with BoxRouter() as client:
    client.api.secrets.put(
        "ANTHROPIC_API_KEY",
        body=PutSecret(value=os.environ["ANTHROPIC_API_KEY"], real_key_allowed=True),
    )
```

```typescript TypeScript theme={"theme":"css-variables"}
import { BoxRouter } from '@boxrouter/sdk';

const value = process.env.ANTHROPIC_API_KEY;
if (!value) throw new Error('Set ANTHROPIC_API_KEY in your environment');

const client = new BoxRouter();
try {
  await client.api.secrets.put({
    path: { name: 'ANTHROPIC_API_KEY' },
    body: { value, real_key_allowed: true },
  });
} finally {
  await client.close();
}
```

```bash CLI theme={"theme":"css-variables"}
printf '%s' "$ANTHROPIC_API_KEY" | boxrouter secrets set ANTHROPIC_API_KEY --real-key
```

Re-saving without the flag keeps the setting; `false` (`--no-real-key`) turns it off. `boxrouter secrets ls` prints a `true` or `false` fourth column. Only re-saving changes the setting; launches never widen it or fall back to real keys.

Catalog agents that support stand-in keys still get them. Only `hermes`, your own agent, or a renamed secret gets the real key, which every command there can read.

Turning real-key delivery off leaves keys already in sandboxes; rotate them at their service. Standard-name secrets saved before stand-in keys launched also become stand-in only. Re-save keys for `hermes` or your own agent; running sandboxes keep theirs.

## Spending and Allowed Calls

Stand-in keys are free; they use no Credits and carry no fee.

Credits and BoxRouter's [spend limit](https://boxrouter.ai/docs/spend-limits.md) cover sandbox compute only; your model account bills model calls ([Choose a Catalog Agent](https://boxrouter.ai/docs/launch/agents.md#give-an-agent-model-access)). Because sandboxes share the real key, your service shows one combined total.

The gateway forwards agent calls: messages, token counts, model listings, and tools such as web search. It refuses batch jobs, file uploads, fine-tuning, realtime sessions, background requests, and key, credit, and admin calls. It strips some Anthropic betas (Files API, MCP connector, and code execution) and limits concurrent and per-minute calls.

## Key Lifecycle and Rotation

Stand-in keys end when their sandbox ends or you delete the secret; streaming replies finish. [Saving a replacement](https://boxrouter.ai/docs/launch/secrets.md#save-a-secret) updates running stand-in sandboxes. Changes apply within 5 seconds; snapshot restores need a fresh launch.

Deleting or rotating a secret does not revoke it at its service, and sandboxes with the real key keep it. Destroy the sandbox if its stand-in key leaks. Rotate a leaked real key at its service, then [save the replacement](https://boxrouter.ai/docs/launch/secrets.md#save-a-secret).

## Errors

Gateway errors use the model service's format; launch refusals return before any sandbox exists.

| Status | Message | Cause | Fix |
| - | - | - | - |
| `400` | `<agent or manifest name> needs the real key of the secret <NAME>, which is saved for stand-in keys only.` | Launch needs real key; secret is stand-in only. | `Save <NAME> again with real-key delivery allowed, then retry.` |
| `400` or `403` | `BoxRouter's credential gateway does not allow this call (<reason>).` | Endpoint or feature is refused. | Use a call that the gateway forwards. |
| `401` | `This BoxRouter stand-in key is not active. Its sandbox may have ended, or this sandbox was restored from a snapshot. Start a new launch; each sandbox gets its own keys.` | Key is unknown, ended, malformed, or restored. | Start a fresh launch. |
| `429` | `BoxRouter's gateway limits concurrent and per-minute calls; slow down and retry.` | Concurrency or per-minute limit reached. | Slow down and retry. |
| `503` | `BoxRouter's credential gateway is unavailable. The model provider is not at fault; try again shortly.` | Gateway cannot reach a required service. | Retry shortly. |

Stand-in agents rely on the single-region gateway. BoxRouter never retries with your real key; agents with the real key are unaffected.

## What Stand-In Keys Do Not Protect

* While its sandbox runs, an agent can make any allowed call up to your model service limit.
* A copied stand-in key works from any address until its sandbox ends; the gateway logs source addresses without blocking them.
* Stand-in keys do not restrict network access; data can leave over the internet or via web search.
* In-sandbox sign-ins (such as ChatGPT in `codex` or `/login`) stay in the sandbox outside stand-in keys.
* Repository scripts can read the stand-in key. Wired agents block repository settings from redirecting calls.
* In `opencode`, a repository can run plugin code that reads the key. In `codex`, a trusted folder can pass the key to a tool server.
* `junie` cannot read environment keys. BoxRouter also writes its stand-in key to a home-folder file readable only by the sandbox user. No agent writes a real key to a file.

## Gateway Security and Logging

Every stand-in call passes through the gateway. Operators can read one log line per call: sandbox, workspace, secret name, model service, path, status, model, duration, and source address. Logs never store token counts, cost, keys, prompts, or replies.

A gateway break-in would expose real keys used during that time. Audit records list decrypted keys; we tell each owner how to rotate within 24 hours of confirming an exposure.

An API break-in could issue stand-in keys. It could also read secrets saved during the break-in and any that allow real-key delivery. Every change to the gateway's deployment or permissions, including which services may decrypt saved secrets, sends an alarm to BoxRouter.

> [!NOTE]
>
> BoxRouter sets no spending limit on stand-in keys. Set one at your model service: an OpenRouter key credit limit, an Anthropic workspace limit, or an OpenAI project budget.
>
> Pausing a sandbox does not stop its stand-in keys. They work until the sandbox ends or you delete the secret.

## Next Steps

* [Supply an Agent's Secrets](https://boxrouter.ai/docs/launch/secrets.md): Save, list, and delete workspace secrets.
* [Choose a Catalog Agent](https://boxrouter.ai/docs/launch/agents.md): See which model keys each catalog agent accepts.
* [Cap Your Spend](https://boxrouter.ai/docs/spend-limits.md): Cap workspace spending on BoxRouter-billed sandbox compute.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.