Setting secrets in config.yaml
If your model needs a secret, first add its name in config.yaml with a placeholder value:
config.yaml
Using secrets in model.py
Secrets are passed to your Model class as a keyword argument in init. They can be accessed with:
model/model.py
self._secrets dictionary in the load and predict functions:
model/model.py
Storing secrets on your remote
On your remote host, such as your Baseten account, store both the secret name and value before deploying your model. On Baseten, you can add secrets to your workspace on the secrets workspace settings page. Make sure to use the same name (case sensitive) as used in the Truss on the remote.Deploying with secrets
For additional security, models don’t have access to secrets by default. To deploy a model and give it access to secrets, pass the--trusted flag during truss push as follows: