> ## Documentation Index
> Fetch the complete documentation index at: https://docs.castari.com/llms.txt
> Use this file to discover all available pages before exploring further.

# cast secrets

> Manage agent secrets and environment variables

# cast secrets

Manage secrets for your agents. Secrets are injected as environment variables when the agent runs.

## cast secrets list

List all secrets for an agent.

### Usage

```bash theme={null}
cast secrets list <slug>
```

### Example

```bash theme={null}
cast secrets list my-agent
```

### Output

```
KEY                  CREATED
OPENAI_API_KEY       2024-01-15 10:30:00
DATABASE_URL         2024-01-15 10:30:00
```

<Note>
  Secret values are never displayed. Only the keys and creation dates are shown.
</Note>

***

## cast secrets set

Set a secret for an agent.

### Usage

```bash theme={null}
cast secrets set <slug> <key> <value>
```

### Arguments

| Argument | Description                         |
| -------- | ----------------------------------- |
| `slug`   | Agent slug                          |
| `key`    | Secret name (uppercase recommended) |
| `value`  | Secret value                        |

### Examples

```bash theme={null}
# Set an API key
cast secrets set my-agent OPENAI_API_KEY sk-abc123...

# Set a database URL
cast secrets set my-agent DATABASE_URL postgres://user:pass@host/db
```

### Output

```
✓ Secret 'OPENAI_API_KEY' set for agent 'my-agent'
```

<Warning>
  Setting a secret with an existing key will overwrite the previous value.
</Warning>

### Interactive Mode

To avoid exposing secrets in shell history:

```bash theme={null}
cast secrets set my-agent OPENAI_API_KEY
```

When no value is provided, you'll be prompted to enter it securely:

```
Enter value for OPENAI_API_KEY: ********
✓ Secret 'OPENAI_API_KEY' set for agent 'my-agent'
```

***

## cast secrets delete

Delete a secret from an agent.

### Usage

```bash theme={null}
cast secrets delete <slug> <key>
```

### Example

```bash theme={null}
cast secrets delete my-agent OPENAI_API_KEY
```

### Output

```
✓ Secret 'OPENAI_API_KEY' deleted from agent 'my-agent'
```

***

## Using Secrets in Agents

Secrets are available as environment variables in your agent code:

```typescript theme={null}
// Access secrets in your agent
const openaiKey = process.env.OPENAI_API_KEY;
const databaseUrl = process.env.DATABASE_URL;
```

## Built-in Secrets

Castari automatically provides these environment variables:

| Variable            | Description                         |
| ------------------- | ----------------------------------- |
| `ANTHROPIC_API_KEY` | Your Anthropic API key (for Claude) |

<Tip>
  You don't need to set `ANTHROPIC_API_KEY` manually. Castari injects it automatically so your agents can use Claude.
</Tip>

## Best Practices

1. **Use uppercase names** — `DATABASE_URL` not `database_url`
2. **Don't commit secrets** — Never put secrets in your agent code or git
3. **Use descriptive names** — `STRIPE_SECRET_KEY` not `KEY1`
4. **Rotate regularly** — Update secrets periodically for security

## See Also

* [Secrets Concept](/concepts/secrets) — How secrets work
* [cast deploy](/cli/deploy) — Deploy with secrets
