Create a secret
- Baseten UI
- cURL
- Go to the workspace settings and select Secret.
- Enter the name and value of the secret, for example
hf_access_tokenandhf_.... - Select Add secret.
Use secrets in your model
Once you’ve created a secret, declare it in yourconfig.yaml and access it in your model code.
Specify the reference to the secret in config.yaml:
config.yaml
Model class. To access them, store the secrets in __init__:
main.py
load or predict section of your model by accessing the secret using the key:
main.py
Use secrets in custom Docker images
When using custom Docker images, Truss injects secrets into your container at/secrets/{secret_name} instead of
passing them through kwargs.
You must specify the reference to the secret and then access it in your start_command or application code.
Specify the reference to the secret in config.yaml:
config.yaml
Read secrets in your start_command
To read a secret in your start_command:
config.yaml
Read secrets in application code
To read a secret in application code:main.py