You may want to use API keys, passwords or other sensitive information in your application, but you don’t want it stored in your code. If this is the case, it would be best to make use of our Secrets functionality. Secrets are stored encrypted on our servers and are only decrypted when your model is run.

from cerebrium import get_secret

def predict(item, run_id, logger):
    item = Item(**item)"Run ID: {run_id}")

    my_secret = get_secret('my-secret')"my_secret: " + my_secret)

    return {"result": f"Your secret is {my_secret}"}

Managing Secrets

Secrets are created, updated and deleted in your dashboard.


Secrets are shared across all models in your project.

Local Development

When running your model locally, you can use still make use of Secrets. Store them in a file called secrets.json or secrets.yaml in the root of your project and add them to your .gitignore. These files will not be uploaded to Cerebrium.


"my-yaml-secret": "this value comes from yaml"


  "my-json-secret": "this value comes from json"

Secrets are loaded on model start, you will need to redeploy your model for changes to take effect.