Give hosts your harness keys
A harness key is the API key or token
a harness reaches its model with. Keep it as a workspace secret, which every
host of the workspace uses, or on one host. Either way, the sandbox gets the
stand-in spotlight-egress:<NAME>, and the run's egress puts the key in the
requests to the model provider.
Use the variable for your harness:
| Harness | Variable |
|---|---|
| Claude Code, with an API key | ANTHROPIC_API_KEY |
| Claude Code, with a Claude subscription | CLAUDE_CODE_OAUTH_TOKEN |
| Codex | OPENAI_API_KEY or CODEX_API_KEY |
| Cursor | CURSOR_API_KEY |
| OpenCode | the key of the model's provider: ANTHROPIC_API_KEY, OPENAI_API_KEY or OPENROUTER_API_KEY, or OPENCODE_API_KEY for OpenCode Zen |
For a Claude subscription, run claude setup-token on your own computer and
use the token it prints as CLAUDE_CODE_OAUTH_TOKEN.
Use API keys or a token from claude setup-token. Logins that refresh their
own tokens, such as Codex signed in with ChatGPT or Claude signed in through a
browser, do not work through egress. OpenCode signed in with ChatGPT or GitHub
Copilot does not work either.
OPENCODE_API_KEY, and the key of an OpenCode provider other than Anthropic,
OpenAI and OpenRouter, are not keys that egress keeps. They enter the sandbox
as they are, where the agent can read them. Cursor CLI exchanges
CURSOR_API_KEY at api2.cursor.sh for a short-lived token, and the agent
can read that token.
Keep the keys as workspace secrets
A workspace secret whose name is one of the variables above is that
harness's key. Every run of the harness, in tasks, chats and replays, gets the
stand-in, on each host and on each push pool that names an egress. Writing a
secret needs a workspace owner or admin, or a workspace token with the
secrets scope.
Run spotlight host init in a terminal, with no flags. For each harness you
pick whose key the workspace does not hold, it asks for the key and saves it
as a workspace secret. See
Install a host.
When the workspace holds a harness's key, a run of that harness goes only to a runner with an egress: a host, or a push pool that names an egress.
When the workspace holds a new harness key, each host checks its images again, with the key. The models of the harness then show on the Runners page.
Keep the keys on a host
sandbox.env sits beside host.env: /etc/spotlight/sandbox.env for a host
installed as root, ~/.spotlight/sandbox.env for one installed as yourself.
Add one KEY=VALUE line for each key, and make the file readable only by its
owner:
echo 'ANTHROPIC_API_KEY=<your key>' >> ~/.spotlight/sandbox.env
chmod 600 ~/.spotlight/sandbox.envEgress keeps every variable in the table above except OPENCODE_API_KEY. The
key that the host keeps goes first: when the host has a key for a provider's
host, egress does not inject a workspace secret bound to that host, and the
run's harness gets no stand-in for that secret. For example, a host that keeps
OPENAI_API_KEY runs Codex with that key, also when the workspace holds
CODEX_API_KEY.
Keep keys out of host.env: the host does not pass its own settings to the
sandbox. spotlight host init leaves sandbox.env as it is.
Pass keys from the host's environment instead
If you run spotlight host serve under your own supervisor and the keys are already
in its environment, name them in SPOTLIGHT_SANDBOX_PASS instead of writing
them to a file. Set it in the same environment:
SPOTLIGHT_SANDBOX_PASS=ANTHROPIC_API_KEY,OPENAI_API_KEY spotlight host serveThe host passes only the variables its own process has. Egress keeps the known
keys in the same way as keys from sandbox.env.
Reload the host
The host reads the sandbox environment when it starts and when it reloads. After every change, reload it:
spotlight host reloadSandboxes the host starts after the reload get the new environment. Running sandboxes keep the one they started with.
If a push pool provisions the runners
Keep the keys as workspace secrets, and let the pool name an egress, as in Send push pool runs through an egress. The egress injects them as it injects every secret of the run.
A key that your provisioner puts in the environment of each runner it starts, as in Provision runners from your own platform, enters the sandbox as it is, where the agent can read it.
If you limit where sandboxes connect
If you have limited where sandboxes connect with egress-allow, the list must
allow the provider's host, such as api.anthropic.com, or egress does not add
the key. See Limit where sandboxes can connect.
Related
- Harnesses: what each harness installs and reads.
- Harness keys, for the keys egress keeps on a host and the host each one is sent to.
- spotlight_secret, for the bindings of harness keys kept as workspace secrets.
- The sandbox is the security boundary