# Environment Variables

The Roboflow CLI and Python SDK read a small set of environment variables. Setting them in your shell or CI environment removes the need to pass credentials and configuration on every command.

## `ROBOFLOW_API_KEY`

Your Roboflow API key. Used by:

* **CLI** — every command falls back to this when `--api-key` / `-k` isn't passed.
* **Python SDK** — `roboflow.Roboflow()` (with no arguments) and most adapter functions read this when no explicit key is provided.

```bash
export ROBOFLOW_API_KEY=rf_xxxxx
```

```python
import roboflow

rf = roboflow.Roboflow()  # picks up ROBOFLOW_API_KEY automatically
```

Find your key in the [Roboflow web app under Settings → API Key](https://app.roboflow.com/settings/api).

## `ROBOFLOW_CONFIG_DIR`

Override the location where the CLI stores authentication credentials and the configured default workspace. Defaults to `~/.config/roboflow/`.

```bash
export ROBOFLOW_CONFIG_DIR=/etc/roboflow
roboflow login
# credentials saved to /etc/roboflow/config.json
```

Useful in CI, container builds, or when running multiple Roboflow accounts side by side on the same machine.

## `API_URL`

Override the base URL the SDK and CLI send REST API requests to. Defaults to `https://api.roboflow.com`.

You should not need to set this. It exists for Roboflow-internal testing against pre-production environments.

## `DEDICATED_DEPLOYMENT_URL`

Override the base URL for the dedicated-deployments service. Defaults to `https://roboflow.cloud`.

You should not need to set this. It exists for Roboflow-internal testing against pre-production environments.

## Precedence

When the same value can be supplied multiple ways, this is the order of precedence (highest first):

1. **Explicit flag** — e.g. `--api-key` on a CLI command, or the `api_key` argument to a Python function.
2. **Environment variable** — e.g. `ROBOFLOW_API_KEY`.
3. **On-disk config** — e.g. `~/.config/roboflow/config.json` for the CLI's saved credentials.
4. **Built-in default** — only for non-secret values like `API_URL`.

## CI / Agent recommendation

In CI or AI-agent contexts, prefer `ROBOFLOW_API_KEY` over `roboflow login`. The env var path requires no interactive prompts, no on-disk state, and rotates cleanly when you rotate the key in your secrets store.

```yaml
# Example GitHub Actions
env:
  ROBOFLOW_API_KEY: ${{ secrets.ROBOFLOW_API_KEY }}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.roboflow.com/developer/environment-variables.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
