run_code / run_cmd, the attached secrets become environment variables — without putting keys in your source or prompts.
Manage Identity providers in Identity → Providers on the platform, or via
client.identity.providers / /v1/identity/providers. Create secrets under a provider there. Secret values are write-only — list/get return masked placeholders only.Why Identity providers?
Secrets are resolved at execution time. They are not stored in the runtime’s persisted env record.
Behavior
- Secret keys become env var names (
OPENAI_API_KEY). - Same key under an Identity provider overwrites the previous value.
- Attach secrets when creating a sandbox (
providers=[...]) or later withclient.identity.providers.attach(...). - After detach, the next execution no longer receives those secrets.
- Interactive terminal/SSH does not auto-inherit secrets — use
run_codeorrun_cmd.
Create an Identity provider and secrets
Multiple secrets
One Identity provider can hold several keys:Attach secrets when creating a sandbox
Pass the Identity provider ID so its secrets are attached to the sandbox:Attach secrets to a running sandbox
Use credentials in code
Detach secrets
SDK reference
All Identity provider operations live underclient.identity.providers (maps to /v1/identity/providers).
CLI
Security best practices
Identity providers keep secrets out of your source tree and make rotation easier — but attaching secrets still injects those values into the sandbox as environment variables onrun_code / run_cmd. Isolation from the host does not stop a context-injected agent from reading os.environ, writing files, or sending data over the network.
Safer patterns
- Authenticate outside the sandbox — your app or a host-side tool holds the API key; the sandbox only receives non-sensitive results.
- Narrow Identity secrets — one provider per integration, keys scoped to the minimum API surface, rotate often, detach when unused.
- Limit what can leave the box — use Network Policies to allowlist or block outbound destinations; monitor for unexpected destinations.
- Human review for risky actions — require approval before tool calls that spend money, change production data, or leave the sandbox.
- Treat sandbox I/O as hostile — validate outputs, redact secrets from logs, and never trust agent-generated commands blindly.
Next
Create Runtime
Create a sandbox and attach secrets
Network Policies
Limit where secrets can be used over the network