Use the W&B Secrets Manager with the W&B Python SDK to access sensitive information such as API keys and tokens in a sandbox. To use a secret in a sandbox, first add it to your team’s Secrets Manager. Then reference that secret by name when you create the sandbox. Do not include the secret’s value directly in your code or in the sandbox configuration. W&B injects each requested secret into the sandbox as an environment variable. By default, the environment variable name matches the secret name. You can customize the environment variable name with theDocumentation Index
Fetch the complete documentation index at: https://wb-21fd5541-john-wbdocs-2044-rename-serverless-products.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
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: