Secrets
Let a sandbox use an API key that never enters the sandbox. The sandbox gets a placeholder. Our gateway, outside the sandbox, adds the real key on the way out.
| One host each | Each secret works for one HTTPS host only. The gateway refuses every other host. |
|---|---|
| Services | Anthropic (api.anthropic.com). |
How it works
- You save your key once. We seal it with an AWS KMS key at once and keep only the sealed copy.
- A sandbox that uses the key gets a placeholder in
ANTHROPIC_API_KEYandANTHROPIC_BASE_URL=https://llm.fdtn.dev. - Claude Code and the Anthropic SDKs send their calls to our gateway.
- The gateway opens your key with AWS KMS, sends the call to
api.anthropic.comand streams the answer back.
The real key never enters the sandbox or the computer that runs it. A prompt injection that prints the environment shows only the placeholder. The placeholder works only from that sandbox, and only while it runs.
1Save your key as a secret
Put the key in a file, not on the command line, so it stays out of shell history.
{
"name": "anthropic",
"value": "sk-ant-...",
"metadata": {
"fdtn.hosts": "api.anthropic.com",
"fdtn.header": "x-api-key",
"fdtn.paths": "/v1",
"fdtn.methods": "POST,GET"
}
}$ fdtn secrets create --input anthropic.json $ rm anthropic.json $ fdtn secrets ls # names and versions, never the value
The fdtn. keys say where the key may go. The gateway refuses every other host, path and method.
2Use it in a sandbox
Claude Code
$ fdtn claude --secret anthropicFrom code
Set the variable to fdtn-secret:// and the key's name. Do not set ANTHROPIC_BASE_URL; we set it.
from fdtn import Sandbox sbx = Sandbox.create("claude", envs={"ANTHROPIC_API_KEY": "fdtn-secret://anthropic"}) r = sbx.commands.run("claude -p 'Say hello'", timeout=300) print(r.stdout) sbx.kill()
import { Sandbox } from '@fdtn/sdk' const sbx = await Sandbox.create('claude', { envs: { ANTHROPIC_API_KEY: 'fdtn-secret://anthropic' } }) const r = await sbx.commands.run("claude -p 'Say hello'", { timeoutMs: 300_000 }) console.log(r.stdout) await sbx.kill()
A sandbox with a secret runs only on computers that we own.
3Rotate or delete
$ echo '{"value": "sk-ant-NEW..."}' > new.json $ fdtn secrets rotate <id> --input new.json; rm new.json $ fdtn secrets delete <id>
- Rotate: running sandboxes use the new key on their next call.
- Delete: running sandboxes lose access within about 15 seconds.
- A killed sandbox loses access at once.
What the gateway sends
| Allowed | POST /v1/messages (streaming too), POST /v1/messages/count_tokens, GET /v1/models |
|---|---|
| Tools | Your own tools, the bash, text editor and memory tools, and web search (at most 3 searches a call) |
| Refused | Other paths, file IDs and URL sources, base64 PDFs, server tools other than web search, MCP servers, priority tiers, and betas outside the list Claude Code uses |
| Billing | Anthropic bills you for tokens, as usual. The gateway also enforces spend caps for your workspace. |
Security
| Storage | Sealed with an AWS KMS key (RSA-4096, us-west-2). We store only the sealed copy. |
|---|---|
| Who can open it | Only the gateway server's AWS role, from the gateway's own address. Our other servers can only seal. |
| When we see it | Our API sees the key once, when you save or rotate it, and seals it at once. |
| Host computers | Never get the key. Sandboxes with secrets run only on our own computers. |
| Logs | AWS logs every use of the KMS key for 365 days, with alerts. No log holds the key. |
| Fails closed | If the key cannot be opened, the call stops. The placeholder never goes to Anthropic. |
Code in the sandbox can still use the key through the gateway while the sandbox runs. Give a sandbox a secret only when its job needs it, and set a spend limit in your Anthropic account.
Errors
At create:
| Status | error_code | Meaning |
|---|---|---|
400 | secret_not_found | No saved key has that name. |
400 | reserved_env | Remove ANTHROPIC_BASE_URL from envs. |
400 | secret_form_not_supported | Use one Anthropic key per sandbox, with no network rules. |
409 | secrets_loading | Wait Retry-After seconds and try again. |
503 | secrets_unavailable | No computer can use the gateway now. Wait Retry-After seconds. |
Inside the sandbox, the gateway answers in the Anthropic error format, with the reason in X-Fdtn-Gateway-Error:
| Status | Reason | Meaning |
|---|---|---|
400 | beta_not_allowed, tool_not_allowed, source_not_allowed, document_not_allowed | The call uses a feature the gateway refuses. See What the gateway sends. |
401 | invalid_key | The placeholder is wrong, or the sandbox is not running. |
404 | not_allowed | A path or method the gateway does not send. |
429 | rate_limited, spend_cap, token_cap | A cap is reached. Wait, or try the next UTC day for spend_cap. |
502 | secret_unavailable, upstream_error | The key could not be opened, or Anthropic failed. Try again. |