Skip to main content
Code in a sandbox often needs a secret: a model provider’s API key for an agent, a token to clone a private repository, a password for a test database. You could paste the value into every request, but then it lives in your code, in your scripts and in your shell history. Instead, store the secret in Fibre once, under a name such as OPENAI_API_KEY, and give it to a sandbox by name. Fibre keeps the value encrypted and adds it as an environment variable only where you ask for it: A sandbox that names no secret gets none. A stored value is write-only: once it is set, Fibre never shows it again, not in the API, the SDKs or the CLI. You can only replace it or delete it.

Store a secret

Give it a name in UPPER_SNAKE_CASE, which becomes the name of the environment variable, and the value. In the CLI, fibre secret set OPENAI_API_KEY asks for the value without showing it, or reads it from a pipe, so the value never appears on the command line:
response
The answer has the name, a version and two times. It never has the value.

Give a secret to one command

This is the safest way to use a secret, and the one to reach for first: only the command that needs the secret gets it, and nothing else that runs in the sandbox before or after can read it. First, a sandbox to work in. It names no secrets:
Now run a command that names the secret. Inside the sandbox it is an ordinary environment variable. This program only reports how long the key is, because output is the one place a secret could leak by accident:
output
In the API, secrets works on Start a command, alongside env. A name cannot be both in secrets and in env.

Give a secret to a whole sandbox

Some programs run for a long time and need a secret the whole time, such as a server you start in the background or an agent that runs many commands. Name the secret when you create the sandbox, and every command in it gets the value. The sandbox’s details list the secrets it uses, by name only:
response
Fibre stores only the names with the sandbox. It reads the values each time the sandbox starts, so they are never saved with it.
A snapshot keeps a sandbox’s memory, and memory includes what its running programs hold. If a program in the sandbox had a secret when you saved a snapshot, copies of that snapshot start with that program and its secret. Save snapshots before your programs load secrets, or from a sandbox that never had them, and name secrets on the copies instead.

Change or delete a secret

To change a value, set it again with the same name. Its version goes up, and from then on:
  • Commands that name it get the new value straight away.
  • New sandboxes that name it start with the new value.
  • A sandbox that got it when it was created keeps the value it started with. Create a new sandbox, or name the secret on its commands, to use the new one.
You can list your secrets at any time. You see names, versions and times, never values:
response
When you no longer need a secret, delete it. Commands that name it from then on are refused with secret_not_found, and sandboxes that named it start without it. Here we also clean up the two sandboxes:
response

Who can use secrets

Naming a secret puts its value into a sandbox, so Fibre treats it like reading the secret: The last row matters for agents. An agent working inside a sandbox should hold a key for that one sandbox. With it, the agent can run its own commands, but it cannot pull any of your secrets into its sandbox. Give the agent the secrets it needs yourself, when you create its sandbox or start its commands, from your own code.

Good practice

  • Name secrets on the command that needs them, rather than on the whole sandbox, so that nothing else in the sandbox can read them.
  • Never print a secret. Command output is returned to whoever runs the command and may end up in logs, and in a model’s context when an agent runs it.
  • Remember that code in a sandbox can send what it can read. For untrusted or model-written code that uses a secret, also limit the sandbox’s network to the services the secret is for, such as api.openai.com.
  • Use a separate key per purpose, such as one model key for your agents and another for evals, so you can change or revoke one without touching the others.
  • Change secrets from time to time, and at once if one may have leaked: set the new value, then revoke the old one at its provider.

Limits

See the API reference for every field.