Authentication
How to sign in, where credentials live, and which environment variables override what.
Both the CLI and the Python SDK authenticate with the same API key. There are three ways to supply it; the first one found wins.
Resolution order
- An explicit flag or constructor argument (
--api-key,api_key=...) - The
REFLEX_API_KEYenvironment variable - The credentials file written by
reflex login
If none are set, commands and SDK calls fail with:
Error: API key is required. Run `reflex login` or set REFLEX_API_KEY.Recommended: reflex login
reflex loginThis opens your browser, prompts you to approve the device, and writes an API key to a local credentials file. Subsequent CLI commands and SDK calls pick it up automatically.
If a browser cannot open (headless server, SSH session), the CLI prints the approval URL — open it on a machine where you can sign in:
reflex login --timeout 0
# Prints the approval URL and exits.
# Approve in a browser, then run `reflex login` again on the headless host.API keys for CI and scripts
For non-interactive environments, set the key as an environment variable
instead of running reflex login:
export REFLEX_API_KEY=rfx_...You can mint additional keys from the dashboard at app.tryreflex.ai. Treat keys as secrets — they grant full access to your organization's runs, datasets, and deployments.
Credentials file
reflex login writes to:
~/.config/reflex/credentials.jsonPermissions are set to 0600 (owner read/write only). The file contains the
API key and the platform URL that was used at login time.
Override the location with:
| Variable | Effect |
|---|---|
REFLEX_CONFIG_DIR | Directory that holds credentials.json. |
REFLEX_CONFIG_FILE | Full path to the credentials file. Wins over _DIR. |
Remove the file (and revoke the local session) with:
reflex logoutVerifying the active identity
reflex whoamiPrints the account and organization the current key belongs to. Useful for
sanity-checking which key a script will use when both REFLEX_API_KEY and a
saved credentials file are present.
Environment variable reference
| Variable | Used by | Purpose |
|---|---|---|
REFLEX_API_KEY | CLI, SDK | API key. Takes precedence over the credentials file. |
REFLEX_PLATFORM_URL | CLI | Override the dashboard URL used by signup and login. |
REFLEX_CONFIG_DIR | CLI | Directory containing credentials.json. |
REFLEX_CONFIG_FILE | CLI | Full path to credentials.json. Overrides REFLEX_CONFIG_DIR. |
RFX_API_KEY is accepted as a legacy alias for REFLEX_API_KEY.