Skip to main content
Secrets store sensitive credentials like API keys, access tokens, and passwords that your models need at runtime. Secrets are encrypted and injected into your model’s environment when it runs.
If your organization uses teams, secrets are scoped to individual teams. Models, Chains, and training projects deployed to a team can only access that team’s secrets.

Create a secret

Create a secret with baseten org secret set:
For a team-scoped secret, pass --team:
List and delete secrets with baseten org secret list and baseten org secret delete:
Secret names follow these rules:
  • Non-alphanumeric characters are normalized (for example, hf_access_token and hf-access-token are treated as the same name).
  • Editing a secret’s value overwrites the previous value.

Use secrets in your model

To use secrets in your Truss model, see Secrets.

Rotate a secret

Rotating a secret replaces its value while keeping its name, so models that reference it keep working without code or configuration changes. For cloud resources and Hugging Face repositories, OpenID Connect (OIDC) gives deployments short-lived tokens, so workloads that use it have nothing to rotate. You can’t read the old value back from Baseten, so keep the old credential active with its provider until your workloads succeed with the new one. Updated values reach running replicas within about a minute, so a model that reads the secret on each request needs no restart. A model that reads the secret when it loads keeps the old value until you redeploy it or restart its replicas. To rotate a secret:
  1. Create a new credential with the provider that issued the current one.
  2. Verify the new credential directly with its provider. Use an operation that requires the same resource access and permissions as your workload.
  3. Update the Baseten secret with the new value. Use the same secret name.
    1. Sign in to your workspace at app.baseten.co and go to Secrets in your workspace settings. If your organization uses teams, open the team’s settings page instead.
    2. Choose Edit secret next to the secret you’re rotating.
    3. For Token, enter the new value.
    4. Choose Save.
  4. Confirm that each workload that reads the secret completes an operation that authenticates with the new credential. Wait for the updated value to reach running replicas first. If your model reads the secret when it loads, redeploy it or restart its replicas before this check. For example, send an inference request that accesses the provider resource and check the deployment’s logs.
  5. Revoke the old credential with its provider.
The audit log records each change as a SECRET_UPDATED event. To rotate a Baseten API key, see rotate a key.

Security recommendations

  • Create secrets through the Baseten CLI or dashboard, not in code.
  • Use descriptive names that indicate the secret’s purpose.
  • Rotate secrets periodically.
  • Delete unused secrets to reduce exposure risk.