Most agents will require access to sensitive information, such as API keys, passwords, and other secrets. To keep this information secure, we recommend using Pipecat Cloud’s secret management feature.

Secrets are created as “sets” of key-value pairs, and defined at the user / organization level. This means that secrets can be shared across all agent deployments within the same user workspace or organization.

To access secrets, your deployment must specify the secret set to use.

Working with secrets

Secrets can be managed via either the CLI or the Dashboard .

Creating a secret set and adding secrets

pcc secrets set my-secret-set SECRET_NAME secret-value SECRET_NAME_2 secret-value-2

This command will create or modify the secret set with the name my-secret-set, and add or update the key-value pairs SECRET_NAME and SECRET_NAME_2.

You can add additional secrets to the set by specifying more key-value pairs.

pcc secrets set my-secret-set SECRET_NAME_3 secret-value-3

Whenever a secret is added or updated in an existing set, any deployments using that set will need to be redeployed to access the new values.

Special characters

There are several ways to specify key-value pairs:

  1. Simple values (no spaces or special characters):

    pcc secrets set my-secrets KEY1=simple KEY2=value
    
  2. Values with spaces:

    pcc secrets set my-secrets KEY1="value with spaces"
    # or
    pcc secrets set my-secrets "KEY1=value with spaces"
    
  3. Values containing equals signs:

    pcc secrets set my-secrets KEY1="value=with=equals"
    # or
    pcc secrets set my-secrets KEY1==value=with=equals
    
  4. Values containing quotes:

    pcc secrets set my-secrets KEY1="value with \"quotes\""
    # or
    pcc secrets set my-secrets 'KEY1=value with "quotes"'
    
  5. Values containing backslashes:

    pcc secrets set my-secrets 'KEY1=value with \backslashes'
    # or
    pcc secrets set my-secrets "KEY1=value with \\backslashes"
    

Important Notes

  • Keys must contain only alphanumeric characters, underscores, and hyphens ([a-zA-Z0-9_-])
  • Keys must not exceed 64 characters in length
  • Values are preserved exactly as entered, including any spaces, quotes, or special characters
  • If a value contains spaces, you must either:
    • Enclose the value in quotes: KEY="value with spaces"
    • Enclose the entire key-value pair in quotes: "KEY=value with spaces"
  • When using quotes within values, you can either:
    • Use single quotes around the pair containing double quotes: 'KEY=value "quoted" here'
    • Use escaped double quotes: KEY="value \"quoted\" here"

List secret sets

You can view a list of available secret sets in your currently selected workspace or organization.

pcc secrets list

You can pass an optional secret set name to view the secret keys within that set. Values are not displayed.

pcc secrets list my-secret-set

Removing a secret

To remove a secret from a set, use the unset command.

pcc secrets unset my-secret-set SECRET_NAME

To remove a secret-set entirely, use the delete command:

pcc secrets delete my-secret-set

Image pull secrets

Image pull secrets are used to authenticate with private Docker registries when deploying agents.

They can be passed as part of the deploy command.

pcc secrets image-pull-secret my-image-pull-secret https://index.docker.io/v1/

Running this command will prompt you for account credentials. You can optionally encode your credentials in base64 with the --base64encode flag.

Unlike secret sets, image pull secrets can not be updated. You must delete and recreate the secret if you need to change the credentials.

Accessing secrets in your agent code

Secrets are mounted as environment variables in your agent process.

For example, if you define a secret with the key MY_SECRET, you can access it in your agent code like so:

import os

secret_value = os.environ.get('MY_SECRET')

When deploying, you have two options to specify which secret set to use:

  1. Specify a secret set as part of your deploy command:
pcc deploy my-agent my-image --secrets my-secret-set
  1. Specify a secret_set key in your pcc-deploy.toml file:
agent_name = "my-agent"
image = "my-agent-image"
secret_set = "my-secret-set"

With either approach, the CLI will automatically inject the secrets from the specified set into your agent deployment as environment variables.

Other methods

If you prefer to manage secrets outside of Pipecat Cloud, you can use environment variables or other secret management tools.

You could, for example, set environment variables in your Dockerfile:

FROM dailyco/pipecat-base:latest

ENV MY_SECRET=secret-value

COPY ./requirements.txt requirements.txt
RUN pip install --no-cache-dir --upgrade -r requirements.txt
COPY ./bot.py bot.py

We recommend using Pipecat Cloud’s built-in management for the most secure and versatile method of managing secrets.