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

# Set environment variables for your Dolphinclaw agent

> Access API keys and configuration values in your agent code using standard Node.js process.env, set securely through the DolphinClaw dashboard.

Your agent runs inside an isolated Docker container managed by the DolphinClaw platform. Because it is a standard Node.js process, the normal `process.env` mechanism works exactly as you would expect — any environment variable set for the container is available to your code at runtime. This is how you pass API keys, webhook URLs, and other configuration without embedding them directly in your source.

## Setting environment variables

Configure environment variables for your agent through the DolphinClaw dashboard:

<Steps>
  <Step title="Open your agent settings">
    Navigate to your agent in the dashboard and open the **Settings** tab.
  </Step>

  <Step title="Add your variables">
    Under the **Environment Variables** section, add each key-value pair. Values are stored as secrets and are never exposed in the dashboard UI after saving.
  </Step>

  <Step title="Redeploy or restart">
    Changes take effect the next time your agent starts. Restart a running agent to pick up new values.
  </Step>
</Steps>

## Accessing variables in code

Read environment variables with `process.env.YOUR_VARIABLE_NAME`. The value is always a string (or `undefined` if the variable was not set).

```javascript theme={null}
const apiKey = process.env.MY_API_KEY;
```

Provide a fallback for local development using the `||` operator, as shown in the official Groq Discord Agent example:

```typescript theme={null}
const client = new OpenAI({
  apiKey: process.env.OPENAI_API_KEY || "YOUR_API_KEY_HERE",
  baseURL: "https://api.groq.com/openai/v1",
});
```

When the agent runs on the platform, `process.env.OPENAI_API_KEY` resolves to the secret you configured in the dashboard. The fallback string is only used when you run the file locally without the variable set.

<Warning>
  Do not hardcode real API keys or secrets directly in your agent source code. Even though every agent's source is kept in a private Git repository, treating secrets as environment variables is a security best practice — it keeps credentials out of version history and makes rotation easy without a code change.
</Warning>

<Note>
  Common variables to configure through the dashboard include API keys for external services (OpenAI, Groq, etc.), webhook URLs for notification endpoints (Discord, Slack, etc.), and any configuration flags that may differ between test and production runs.
</Note>
