Skip to main content
Both are injected as standard environment variables. The CLI flags take KEY=VALUE and can repeat.
  • Environment variables are stored in plain text and visible when you inspect the sandbox.
  • Secrets are encrypted at rest, never returned in API responses, and obfuscated in CLI output. Use them for API keys, passwords, and anything you wouldn’t want in logs.
For a single command, pass env vars on the command instead: see Run a command.

Inject secrets into request headers

Give a sandbox a credential that it can use without ever being able to see it. Store the credential once as a secret. Then add a header rule for a host to the sandbox’s network policy. The platform adds the secret to HTTPS request headers for that host, outside the sandbox. The value never goes into the sandbox’s environment, files, or configuration.
The rule refers to the secret by name: ${prime.secrets.INFERENCE_KEY}. When the sandbox sends an HTTPS request to api.pinference.ai, the platform resolves the reference outside the sandbox, sets the header, and sends the request on. If the sandbox sends a header with the same name, the platform replaces it.
The destination host receives the header, so it can read the credential. A response can also send the value back into the sandbox. Add header rules only for hosts that you trust.
A header rule does not give network access. The sandbox’s allowlist or denylist must also allow the rule host.

Which secrets you can use

Header rules use your global secrets: the secrets that you create with prime secret create or under Keys & Secrets. These are the same secrets that you can link to Environments Hub environments, so one secret can serve both. Secrets set directly on one environment are not available to header rules. The secret must belong to the same user or team as the sandbox.

Rule syntax and limits

  • A rule host is an exact host name (api.pinference.ai) or a wildcard for one label (*.example.com). *.example.com matches api.example.com, but not example.com or a.b.example.com. Ports, paths, and IP addresses are not permitted.
  • Host names are not case-sensitive. An exact host has priority over a wildcard. The platform does not combine rules.
  • A header value is text that contains zero or more ${prime.secrets.<NAME>} references. Other ${...} forms are not permitted.
  • Header names are not case-sensitive. A rule cannot set the same header two times, for example Authorization and authorization.
  • You cannot set these headers: Host, :authority, Content-Length, Transfer-Encoding, Connection, Upgrade, Keep-Alive, TE, Trailer, and headers that start with Proxy-.

Update rules on a running sandbox

Header rules are part of the network policy. Each update replaces the full policy, as for allowlists and denylists.
For many rules, put the policy in a JSON file and use --network-policy. You can use it when you create or update a sandbox:
If you replace the policy without rules, the platform removes all header rules.

Errors

If the platform cannot add a secret, it does not send the request. The sandbox gets a 502 response with the body request blocked: header substitution unavailable. A partial credential never goes to the destination. Requests to hosts without a rule are not affected.

TLS trust inside the sandbox

To add headers, the platform must terminate TLS for rule hosts. Clients in the sandbox must therefore trust the Prime Intellect root certificate. The sandbox includes this certificate at /mnt/sandboxd/platform-ca.pem.
  • Most clients work with no changes. At boot, the platform adds the root to the sandbox’s system trust store. It also sets SSL_CERT_FILE, REQUESTS_CA_BUNDLE, and NODE_EXTRA_CA_CERTS, unless you set them. This covers curl, openssl, Python requests and urllib, and Node.js.
  • If the image does not include the ca-certificates package, install it in the image. You can also install it while the sandbox runs.
  • If a client uses its own trust store, add the root to that store, as in the example below.
Add the root to the existing certificates. Do not replace them. Do not turn off certificate verification. Connections to hosts without a rule keep end-to-end TLS, so they do not need the root.

Known limits

  • Clients that use certificate pinning cannot connect to rule hosts.
  • Clients that use Encrypted Client Hello (ECH) cannot connect to rule hosts. Browsers that send GREASE ECH, such as Chromium, work normally.