Secrets

Secrets are a secure and reusable way to add credentials and other sensitive information to your workspace. You can use secrets to store sensitive data, such as passwords, API keys, and tokens, and then reference them in your deployments, jobs, and pods.

Managing Secrets

Navigate to the Secrets tab on the left-hand side of the workspace settings page. You will see a list of all the secrets you have created. You can add, edit, or delete secrets from this page.

secrets list

We provide quick ways to add Github, Hugging Face and OpenAI tokens as secrets to your workspace. Simply hover over the create button and select the token you want to add.

Alternatively, you can create secrets via CLI. For example, to create a secret named MY_SECRET with the value MY_SECRET_VALUE, you can run:

lep secret create -n MY_SECRET -v MY_SECRET_VALUE

Secrets are stored and associated with the workspace in which they are created. For more ways to manage the secrets, please refer to the CLI documentation on secret.

Using Secrets

On dashboard, you can add secrets as environment variables to your deployments, jobs, and pods. They are configurable under advanced settings while creating or editing a deployment, job, or pod.

To use a secret via CLI, you can use the --secret flag when running a photon. For example, to pass the secret MY_SECRET to a photon, you can run:

lep photon run -n my-photon --secret MY_SECRET

To access the secret value in the deployment, you can use the os module:

import os

my_secret_value = os.environ['MY_SECRET']
my_optional_secret_value = os.environ.get('MY_OPTIONAL_SECRET', 'default_value')
Lepton AI

© 2024