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.
A self-hosted Inference server is configured with a separate, much larger set of variables. See Inference Server Environment Variables.
ROBOFLOW_API_KEY
Your Roboflow API key. Used by:
- CLI - every command falls back to this when
--api-key/-kisn't passed. - Python SDK -
roboflow.Roboflow()(with no arguments) and most adapter functions read this when no explicit key is provided.
export ROBOFLOW_API_KEY=rf_xxxxximport roboflow
rf = roboflow.Roboflow() # picks up ROBOFLOW_API_KEY automaticallyFind your key in the Roboflow web app under Settings → API Key.
ROBOFLOW_CONFIG_DIR
Override the location where the CLI stores authentication credentials and the configured default workspace. Defaults to ~/.config/roboflow/.
export ROBOFLOW_CONFIG_DIR=/etc/roboflow
roboflow login
# credentials saved to /etc/roboflow/config.jsonUseful 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):
- Explicit flag - e.g.
--api-keyon a CLI command, or theapi_keyargument to a Python function. - Environment variable - e.g.
ROBOFLOW_API_KEY. - On-disk config - e.g.
~/.config/roboflow/config.jsonfor the CLI's saved credentials. - 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.
# Example GitHub Actions
env:
ROBOFLOW_API_KEY: ${{ secrets.ROBOFLOW_API_KEY }}