env_var parameter.
See Manage secrets for information about creating and managing secrets in your W&B account.
Access secrets in a sandbox
Use theSecret class to specify which secrets to include in a sandbox. Pass one or more Secret objects to the secrets parameter of Sandbox.run(). Each Secret object identifies a secret by name. W&B injects the secret value into the sandbox as an environment variable.
The following example makes two existing secrets available in the sandbox: HF_TOKEN and OPENAI_API_KEY.
HF_TOKEN is available as os.environ["HF_TOKEN"], and OPENAI_API_KEY is available as os.environ["OPENAI_API_KEY"].
To customize the environment variable name for a secret, see Use a custom environment variable name.
Use a custom environment variable name
By default, a secret’s environment variable name matches the secret name. To customize a sandbox’s environment variable for a given secret, set theenv_var parameter on Secret (Secret(env_var="CUSTOM_NAME")).
The following example checks that the HF_TOKEN secret is available in the sandbox: