Skip to content

Environment Variables

PRX reads environment variables for API keys, configuration paths, and runtime overrides. Environment variables take precedence over values in config.toml for security-sensitive fields like API keys.

Configuration Paths

VariableDefaultDescription
OPENPRX_CONFIG_DIR~/.openprxOverride the configuration directory. PRX looks for config.toml and config.d/ inside this directory
OPENPRX_WORKSPACE~/.openprx/workspaceOverride the workspace directory (memory, sessions, data)

When OPENPRX_CONFIG_DIR is set, it takes precedence over OPENPRX_WORKSPACE and the active workspace marker.

Resolution order for the config directory:

  1. OPENPRX_CONFIG_DIR (highest priority)
  2. OPENPRX_WORKSPACE
  3. Active workspace marker (~/.openprx/active_workspace.toml)
  4. ~/.openprx/ (default)

Provider API Keys

Each provider has a dedicated environment variable. PRX checks these before falling back to the api_key field in config.toml.

Primary Providers

VariableProvider
ANTHROPIC_API_KEYAnthropic (Claude)
OPENAI_API_KEYOpenAI
GEMINI_API_KEYGoogle Gemini
GOOGLE_API_KEYGoogle Gemini (alternative)
OPENROUTER_API_KEYOpenRouter
OLLAMA_API_KEYOllama (usually not needed)
GLM_API_KEYZhipu GLM
ZAI_API_KEYZ.AI
MINIMAX_API_KEYMinimax
MOONSHOT_API_KEYMoonshot
DASHSCOPE_API_KEYAlibaba Qwen (DashScope)

OAuth Tokens

Some providers support OAuth authentication in addition to (or instead of) API keys:

VariableProviderDescription
ANTHROPIC_OAUTH_TOKENAnthropicClaude Code OAuth token
CLAUDE_CODE_ACCESS_TOKENAnthropicClaude Code access token (alternative)
CLAUDE_CODE_REFRESH_TOKENAnthropicClaude Code refresh token for auto-renewal
MINIMAX_OAUTH_TOKENMinimaxMinimax OAuth access token
MINIMAX_OAUTH_REFRESH_TOKENMinimaxMinimax OAuth refresh token
MINIMAX_OAUTH_CLIENT_IDMinimaxOAuth client ID override
MINIMAX_OAUTH_REGIONMinimaxOAuth region (global or cn)
QWEN_OAUTH_TOKENQwenQwen OAuth access token
QWEN_OAUTH_REFRESH_TOKENQwenQwen OAuth refresh token
QWEN_OAUTH_CLIENT_IDQwenQwen OAuth client ID override
QWEN_OAUTH_RESOURCE_URLQwenQwen OAuth resource URL override

Compatible / Third-Party Providers

VariableProvider
GROQ_API_KEYGroq
MISTRAL_API_KEYMistral
DEEPSEEK_API_KEYDeepSeek
XAI_API_KEYxAI (Grok)
TOGETHER_API_KEYTogether AI
FIREWORKS_API_KEYFireworks AI
PERPLEXITY_API_KEYPerplexity
COHERE_API_KEYCohere
NVIDIA_API_KEYNVIDIA NIM
VENICE_API_KEYVenice
LLAMACPP_API_KEYllama.cpp server
KIMI_CODE_API_KEYKimi Code (Moonshot)
QIANFAN_API_KEYBaidu Qianfan
CLOUDFLARE_API_KEYCloudflare AI
VERCEL_API_KEYVercel AI

Fallback

VariableDescription
API_KEYGeneric fallback used when no provider-specific variable is set

Tool and Channel Variables

VariableDescription
BRAVE_API_KEYBrave Search API key (for [web_search] with provider = "brave")
GITHUB_TOKENGitHub personal access token (used by skills and integrations)
GOOGLE_APPLICATION_CREDENTIALSGoogle Cloud ADC file path (Gemini via service account)

Runtime Variables

VariableDescription
OPENPRX_VERSIONOverride the reported version string
OPENPRX_AUTOSTART_CHANNELSSet to "1" to auto-start channel listeners on boot
OPENPRX_EVOLUTION_CONFIGOverride evolution configuration path
OPENPRX_EVOLUTION_DEBUG_RAWEnable raw evolution debug logging

Variable Substitution in Config

PRX does not natively expand ${VAR_NAME} syntax inside config.toml. However, you can achieve environment variable substitution through these approaches:

1. Use Environment Variables Directly

For API keys, PRX automatically checks the corresponding environment variable. You do not need to reference them in the config file:

toml
# No api_key needed -- PRX checks ANTHROPIC_API_KEY automatically
default_provider = "anthropic"
default_model = "anthropic/claude-sonnet-4-6"

2. Use a Shell Wrapper

Generate config.toml from a template using envsubst or similar:

bash
envsubst < config.toml.template > ~/.openprx/config.toml

3. Use Split Config with Secrets

Keep secrets in a separate file that is generated from environment variables at deploy time:

bash
# Generate secrets fragment
cat > ~/.openprx/config.d/secrets.toml << EOF
api_key = "$ANTHROPIC_API_KEY"

[channels_config.telegram]
bot_token = "$TELEGRAM_BOT_TOKEN"
EOF

.env File Support

PRX does not load .env files automatically. If you need .env file support, use one of these approaches:

With systemd

Add EnvironmentFile to your service unit:

ini
[Service]
EnvironmentFile=/opt/openprx/.env
ExecStart=/usr/local/bin/openprx

With a shell wrapper

Source the .env file before starting PRX:

bash
#!/bin/bash
set -a
source /opt/openprx/.env
set +a
exec openprx

With direnv

If you use direnv, place a .envrc file in your working directory:

bash
# .envrc
export ANTHROPIC_API_KEY="sk-ant-..."
export TELEGRAM_BOT_TOKEN="123456:ABC-DEF..."

Security Recommendations

  • Never commit API keys to version control. Use environment variables or encrypted secrets.
  • PRX's [secrets] subsystem encrypts sensitive fields in config.toml with ChaCha20-Poly1305. Enable it with [secrets] encrypt = true (enabled by default).
  • The .dockerignore shipped with PRX excludes .env and .env.* files from container builds.
  • Audit logs redact API keys and tokens automatically.
  • When using OPENPRX_CONFIG_DIR to point to a shared directory, ensure proper file permissions (chmod 600 config.toml).

Released under the Apache-2.0 License.