ByteRun Docs
Projects and the Studio

Variables and secrets

Settings and API keys your code reads from the environment.

A project can carry variables (plain settings such as a region or a batch size) and secrets (API keys, tokens and passwords). Your code reads both the same way:

import os

token = os.environ["HF_TOKEN"]

Adding one

Open Variables & secrets in the Studio's left column, under Data connections, and choose + Variable or + Secret. Give it a name in capital letters, digits and underscores (HF_TOKEN, WANDB_API_KEY), and a value.

VariableSecret
Shown after savingYes, to people who can edit the projectNever. It shows as dots
Can be changedEdit the valueReplace the value, or remove it
Maximum value1,000 characters4 KB
StoredWith the projectEncrypted in AWS Secrets Manager; ByteRun keeps only a reference

People who can only view the project see the names, not the values.

When a change takes effect

Variables and secrets are set when compute starts. A change you make while compute is running does not reach the running kernel. The panel then says so and offers Restart compute, which saves your notebook, stops the compute and starts it again with the same template and size. Restarting clears the kernel's memory (variables and loaded data), so pick a good moment.

If no compute is running, nothing needs restarting: the next start picks the change up.

How a secret reaches your code

When you save a secret, ByteRun passes the value to AWS Secrets Manager and keeps only a reference. It has no permission to read the value back. When compute starts, AWS hands the value to the project's container as an environment variable, so it is not part of the request that starts the compute and does not show in the compute's settings.

Anything your code prints is saved in the notebook's output. Don't print a secret. ByteRun does not yet hide secret values in output.

Names you can't use

ByteRun sets some variables itself, and a project can't override them: OPENAI_API_KEY, OPENAI_BASE_URL, ANTHROPIC_API_KEY, ANTHROPIC_BASE_URL, PATH, HOME, and names starting with BYTERUN_, AWS_, ECS_, JUPYTER_ or NB_. The AI keys carry ByteRun's own short-lived credential for the AI assistant, not a provider key.

A name can be a variable or a secret, not both. To turn a variable into a secret, remove the variable and add the secret.

Database passwords

For databases, use a data connection instead of a secret. Your code then never holds the password at all.

On this page