Skip to content

Environment Variables (Current Runtime Reference)

This reference is derived from current code paths in:

  • packages/coding-agent/src/**
  • packages/ai/src/** (provider/auth resolution used by coding-agent)
  • packages/utils/src/** and packages/tui/src/** where those vars directly affect coding-agent runtime

It documents only active behavior.

Resolution model and precedence

Most runtime lookups use $env from @oh-my-pi/pi-utils (packages/utils/src/env.ts).

$env loading order:

  1. Existing process environment (Bun.env)
  2. Project .env ($PWD/.env) for keys not already set
  3. Home .env (~/.env) for keys not already set

Additional rule in .env files: OMP_* keys are mirrored to PI_* keys during parse.


1) Model/provider authentication

These are consumed via getEnvApiKey() (packages/ai/src/stream.ts) unless noted otherwise.

Core provider credentials

VariableUsed forRequired whenNotes / precedence
ANTHROPIC_OAUTH_TOKENAnthropic API authUsing Anthropic with OAuth token authTakes precedence over ANTHROPIC_API_KEY for provider auth resolution
ANTHROPIC_API_KEYAnthropic API authUsing Anthropic without OAuth tokenFallback after ANTHROPIC_OAUTH_TOKEN
ANTHROPIC_FOUNDRY_API_KEYAnthropic via Azure Foundry / enterprise gatewayCLAUDE_CODE_USE_FOUNDRY enabledTakes precedence over ANTHROPIC_OAUTH_TOKEN and ANTHROPIC_API_KEY when Foundry mode is enabled
OPENAI_API_KEYOpenAI authUsing OpenAI-family providers without explicit apiKey argumentUsed by OpenAI Completions/Responses providers
GEMINI_API_KEYGoogle Gemini authUsing google provider modelsPrimary key for Gemini provider mapping
GOOGLE_API_KEYGemini image tool auth fallbackUsing gemini_image tool without GEMINI_API_KEYUsed by coding-agent image tool fallback path
GROQ_API_KEYGroq authUsing Groq models
CEREBRAS_API_KEYCerebras authUsing Cerebras models
TOGETHER_API_KEYTogether authUsing together provider
HUGGINGFACE_HUB_TOKENHugging Face authUsing huggingface providerPrimary Hugging Face token env var
HF_TOKENHugging Face authUsing huggingface providerFallback when HUGGINGFACE_HUB_TOKEN is unset
SYNTHETIC_API_KEYSynthetic authUsing Synthetic models
NVIDIA_API_KEYNVIDIA authUsing nvidia provider
NANO_GPT_API_KEYNanoGPT authUsing nanogpt provider
VENICE_API_KEYVenice authUsing venice provider
LITELLM_API_KEYLiteLLM authUsing litellm providerOpenAI-compatible LiteLLM proxy key
LM_STUDIO_API_KEYLM Studio auth (optional)Using lm-studio provider with authenticated hostsLocal LM Studio usually runs without auth; any non-empty token works when a key is required
OLLAMA_API_KEYOllama auth (optional)Using ollama provider with authenticated hostsLocal Ollama usually runs without auth; any non-empty token works when a key is required
LLAMA_CPP_API_KEYOllama auth (optional)Using llama-server with --api-key parameterLocal llama.cpp usually runs without auth; any non-empty token works when a key is configured
XIAOMI_API_KEYXiaomi MiMo authUsing xiaomi provider
MOONSHOT_API_KEYMoonshot authUsing moonshot provider
XAI_API_KEYxAI authUsing xAI models
OPENROUTER_API_KEYOpenRouter authUsing OpenRouter modelsAlso used by image tool when preferred/auto provider is OpenRouter
MISTRAL_API_KEYMistral authUsing Mistral models
ZAI_API_KEYz.ai authUsing z.ai modelsAlso used by z.ai web search provider
MINIMAX_API_KEYMiniMax authUsing minimax provider
MINIMAX_CODE_API_KEYMiniMax Code authUsing minimax-code provider
MINIMAX_CODE_CN_API_KEYMiniMax Code CN authUsing minimax-code-cn provider
OPENCODE_API_KEYOpenCode authUsing OpenCode models
QIANFAN_API_KEYQianfan authUsing qianfan provider
QWEN_OAUTH_TOKENQwen Portal authUsing qwen-portal with OAuth tokenTakes precedence over QWEN_PORTAL_API_KEY
QWEN_PORTAL_API_KEYQwen Portal authUsing qwen-portal with API keyFallback after QWEN_OAUTH_TOKEN
ZENMUX_API_KEYZenMux authUsing zenmux providerUsed for ZenMux OpenAI and Anthropic-compatible routes
VLLM_API_KEYvLLM auth/discovery opt-inUsing vllm provider (local OpenAI-compatible servers)Any non-empty value works for no-auth local servers
CURSOR_ACCESS_TOKENCursor provider authUsing Cursor provider
AI_GATEWAY_API_KEYVercel AI Gateway authUsing vercel-ai-gateway provider
CLOUDFLARE_AI_GATEWAY_API_KEYCloudflare AI Gateway authUsing cloudflare-ai-gateway providerBase URL must be configured as https://gateway.ai.cloudflare.com/v1/<account>/<gateway>/anthropic

GitHub/Copilot token chains

VariableUsed forChain
COPILOT_GITHUB_TOKENGitHub Copilot provider authCOPILOT_GITHUB_TOKENGH_TOKENGITHUB_TOKEN
GH_TOKENCopilot fallback; GitHub API auth in web scraperIn web scraper: GITHUB_TOKENGH_TOKEN
GITHUB_TOKENCopilot fallback; GitHub API auth in web scraperIn web scraper: checked before GH_TOKEN

2) Provider-specific runtime configuration

Anthropic Foundry Gateway (Azure / enterprise proxy)

When CLAUDE_CODE_USE_FOUNDRY is enabled, Anthropic requests switch to Foundry mode:

  • Base URL resolves from FOUNDRY_BASE_URL (fallback remains model/default base URL if unset).
  • API key resolution for provider anthropic becomes: ANTHROPIC_FOUNDRY_API_KEYANTHROPIC_OAUTH_TOKENANTHROPIC_API_KEY.
  • ANTHROPIC_CUSTOM_HEADERS is parsed as comma/newline-separated key: value pairs and merged into request headers.
  • TLS client/server material can be injected from env values: NODE_EXTRA_CA_CERTS, CLAUDE_CODE_CLIENT_CERT, CLAUDE_CODE_CLIENT_KEY. Each accepts either:
    • a filesystem path to PEM content, or
    • inline PEM (including escaped \n sequences).
VariableValue typeBehavior
CLAUDE_CODE_USE_FOUNDRYBoolean-like string (1, true, yes, on)Enables Foundry mode for Anthropic provider
FOUNDRY_BASE_URLURL stringAnthropic endpoint base URL in Foundry mode
ANTHROPIC_FOUNDRY_API_KEYToken stringUsed for Authorization: Bearer <token>
ANTHROPIC_CUSTOM_HEADERSHeader list stringExtra headers; format header-a: value, header-b: value or newline-separated
NODE_EXTRA_CA_CERTSPEM path or inline PEMExtra CA chain for server certificate validation
CLAUDE_CODE_CLIENT_CERTPEM path or inline PEMmTLS client certificate
CLAUDE_CODE_CLIENT_KEYPEM path or inline PEMmTLS client private key (must be paired with cert)

Amazon Bedrock

VariableDefault / behavior
AWS_REGIONPrimary region source
AWS_DEFAULT_REGIONFallback if AWS_REGION unset
AWS_PROFILEEnables named profile auth path
AWS_ACCESS_KEY_ID + AWS_SECRET_ACCESS_KEYEnables IAM key auth path
AWS_BEARER_TOKEN_BEDROCKEnables bearer token auth path
AWS_CONTAINER_CREDENTIALS_RELATIVE_URI / AWS_CONTAINER_CREDENTIALS_FULL_URIEnables ECS task credential path
AWS_WEB_IDENTITY_TOKEN_FILE + AWS_ROLE_ARNEnables web identity auth path
AWS_BEDROCK_SKIP_AUTHIf 1, injects dummy credentials (proxy/non-auth scenarios)
AWS_BEDROCK_FORCE_HTTP1If 1, forces Node HTTP/1 request handler

Region fallback in provider code: options.regionAWS_REGIONAWS_DEFAULT_REGIONus-east-1.

Azure OpenAI Responses

VariableDefault / behavior
AZURE_OPENAI_API_KEYRequired unless API key passed as option
AZURE_OPENAI_API_VERSIONDefault v1
AZURE_OPENAI_BASE_URLDirect base URL override
AZURE_OPENAI_RESOURCE_NAMEUsed to construct base URL: https://<resource>.openai.azure.com/openai/v1
AZURE_OPENAI_DEPLOYMENT_NAME_MAPOptional mapping string: modelId=deploymentName,model2=deployment2

Base URL resolution: option azureBaseUrl → env AZURE_OPENAI_BASE_URL → option/env resource name → model.baseUrl.

Google Vertex AI

VariableRequired?Notes
GOOGLE_CLOUD_PROJECTYes (unless passed in options)Fallback: GCLOUD_PROJECT
GCLOUD_PROJECTFallbackUsed as alternate project ID source
GOOGLE_CLOUD_LOCATIONYes (unless passed in options)No default in provider
GOOGLE_APPLICATION_CREDENTIALSConditionalIf set, file must exist; otherwise ADC fallback path is checked (~/.config/gcloud/application_default_credentials.json)

Kimi

VariableDefault / behavior
KIMI_CODE_OAUTH_HOSTPrimary OAuth host override
KIMI_OAUTH_HOSTFallback OAuth host override
KIMI_CODE_BASE_URLOverrides Kimi usage endpoint base URL (usage/kimi.ts)

OAuth host chain: KIMI_CODE_OAUTH_HOSTKIMI_OAUTH_HOSThttps://auth.kimi.com.

Antigravity/Gemini image compatibility

VariableDefault / behavior
PI_AI_ANTIGRAVITY_VERSIONOverrides Antigravity user-agent version tag in Gemini CLI provider

OpenAI Codex responses (feature/debug controls)

VariableBehavior
PI_CODEX_DEBUG1/true enables Codex provider debug logging
PI_CODEX_WEBSOCKET1/true enables websocket transport preference
PI_CODEX_WEBSOCKET_V21/true enables websocket v2 path
PI_CODEX_WEBSOCKET_IDLE_TIMEOUT_MSPositive integer override (default 300000)
PI_CODEX_WEBSOCKET_RETRY_BUDGETNon-negative integer override (default 5)
PI_CODEX_WEBSOCKET_RETRY_DELAY_MSPositive integer base backoff override (default 500)

Cursor provider debug

VariableBehavior
DEBUG_CURSOREnables provider debug logs; 2/verbose for detailed payload snippets
DEBUG_CURSOR_LOGOptional file path for JSONL debug log output

Prompt cache compatibility switch

VariableBehavior
PI_CACHE_RETENTIONIf long, enables long retention where supported (anthropic, openai-responses, Bedrock retention resolution)

3) Web search subsystem

Search provider credentials

VariableUsed by
EXA_API_KEYExa search provider and Exa MCP tools
BRAVE_API_KEYBrave search provider
PERPLEXITY_API_KEYPerplexity search provider API-key mode
TAVILY_API_KEYTavily search provider
ZAI_API_KEYz.ai search provider (also checks stored OAuth in agent.db)
OPENAI_API_KEY / Codex OAuth in DBCodex search provider availability/auth

Anthropic web search auth chain

packages/coding-agent/src/web/search/auth.ts resolves Anthropic web-search credentials in this order:

  1. ANTHROPIC_SEARCH_API_KEY (+ optional ANTHROPIC_SEARCH_BASE_URL)
  2. models.json provider entry with api: "anthropic-messages"
  3. Anthropic OAuth credentials from agent.db (must not expire within 5-minute buffer)
  4. Generic Anthropic env fallback: provider key (ANTHROPIC_FOUNDRY_API_KEY/ANTHROPIC_OAUTH_TOKEN/ANTHROPIC_API_KEY) + optional ANTHROPIC_BASE_URL (FOUNDRY_BASE_URL when Foundry mode is enabled)

Related vars:

VariableDefault / behavior
ANTHROPIC_SEARCH_API_KEYHighest-priority explicit search key
ANTHROPIC_SEARCH_BASE_URLDefaults to https://api.anthropic.com when omitted
ANTHROPIC_SEARCH_MODELDefaults to claude-haiku-4-5
ANTHROPIC_BASE_URLGeneric fallback base URL for tier-4 auth path

Perplexity OAuth flow behavior flag

VariableBehavior
PI_AUTH_NO_BORROWIf set, disables macOS native-app token borrowing path in Perplexity login flow

4) Python tooling and kernel runtime

VariableDefault / behavior
PI_PYPython tool mode override: 0/bash=bash-only, 1/py=ipy-only, mix/both=both; invalid values ignored
PI_PYTHON_SKIP_CHECKIf 1, skips Python kernel availability checks/warm checks
PI_PYTHON_GATEWAY_URLIf set, uses external kernel gateway instead of local shared gateway
PI_PYTHON_GATEWAY_TOKENOptional auth token for external gateway (Authorization: token <value>)
PI_PYTHON_IPC_TRACEIf 1, enables low-level IPC trace path in kernel module
VIRTUAL_ENVHighest-priority venv path for Python runtime resolution

Extra conditional behavior:

  • If BUN_ENV=test or NODE_ENV=test, Python availability checks are treated as OK and warming is skipped.
  • Python env filtering denies common API keys and allows safe base vars + LC_, XDG_, PI_ prefixes.

5) Agent/runtime behavior toggles

VariableDefault / behavior
PI_SMOL_MODELEphemeral model-role override for smol (CLI --smol takes precedence)
PI_SLOW_MODELEphemeral model-role override for slow (CLI --slow takes precedence)
PI_PLAN_MODELEphemeral model-role override for plan (CLI --plan takes precedence)
PI_NO_TITLEIf set (any non-empty value), disables auto session title generation on first user message
NULL_PROMPTIf true, system prompt builder returns empty string
PI_BLOCKED_AGENTBlocks a specific subagent type in task tool
PI_SUBPROCESS_CMDOverrides subagent spawn command (pisces / pisces.cmd resolution bypass)
PI_TASK_MAX_OUTPUT_BYTESMax captured output bytes per subagent (default 500000)
PI_TASK_MAX_OUTPUT_LINESMax captured output lines per subagent (default 5000)
PI_TIMINGIf 1, enables startup/tool timing instrumentation logs
PI_DEBUG_STARTUPEnables startup stage debug prints to stderr in multiple startup paths
PI_PACKAGE_DIROverrides package asset base dir resolution (docs/examples/changelog path lookup)
PI_DISABLE_LSPMUXIf 1, disables lspmux detection/integration and forces direct LSP server spawning
LM_STUDIO_BASE_URLDefault implicit LM Studio discovery base URL override (http://127.0.0.1:1234/v1 if unset)
OLLAMA_BASE_URLDefault implicit Ollama discovery base URL override (http://127.0.0.1:11434 if unset)
LLAMA_CPP_BASE_URLDefault implicit Llama.cpp discovery base URL override (http://127.0.0.1:8080 if unset)
PI_EDIT_VARIANTIf hashline, forces hashline read/grep display mode when edit tool available
PI_NO_PTYIf 1, disables interactive PTY path for bash tool

Pisces-specific toggles

VariableDefault / behavior
PISCES_LOBSTER_MODEIf 1, enables the lobster extension (messageUser, memorySearch tools)
PISCES_MCP_SOCKETSColon-separated Unix socket paths for shared MCP server pool (e.g., /tmp/mcp.sock:/tmp/mcp2.sock)
PISCES_MAJORDOMO_SOCKETUnix socket path for majordomo-do sidecar (lobster extension)
PISCES_RUN_CHANNEL_KEYPer-run routing key for lobster extension memory searches
MAJORDOMO_SOCKETFallback env var for PISCES_MAJORDOMO_SOCKET
RUN_CHANNEL_KEYFallback env var for PISCES_RUN_CHANNEL_KEY

PI_NO_PTY is also set internally when CLI --no-pty is used.


6) Storage and config root paths

These are consumed via @oh-my-pi/pi-utils/dirs and affect where coding-agent stores data.

VariableDefault / behavior
PI_CONFIG_DIRConfig root dirname under home (default .pisces)
PI_CODING_AGENT_DIRFull override for agent directory (default ~/<PI_CONFIG_DIR or .pisces>/agent)
PWDUsed when matching canonical current working directory in path helpers

7) Shell/tool execution environment

(From packages/utils/src/procmgr.ts and coding-agent bash tool integration.)

VariableBehavior
PI_BASH_NO_CISuppresses automatic CI=true injection into spawned shell env
CLAUDE_BASH_NO_CILegacy alias fallback for PI_BASH_NO_CI
PI_BASH_NO_LOGINIntended to disable login shell mode
CLAUDE_BASH_NO_LOGINLegacy alias fallback for PI_BASH_NO_LOGIN
PI_SHELL_PREFIXOptional command prefix wrapper
CLAUDE_CODE_SHELL_PREFIXLegacy alias fallback for PI_SHELL_PREFIX
VISUALPreferred external editor command
EDITORFallback external editor command

Current implementation note: PI_BASH_NO_LOGIN/CLAUDE_BASH_NO_LOGIN are read, but current getShellArgs() returns ['-l','-c'] in both branches (effectively no-op today).


8) UI/theme/session detection (auto-detected env)

These are read as runtime signals; they are usually set by the terminal/OS rather than manually configured.

VariableUsed for
COLORTERM, TERM, WT_SESSIONColor capability detection (theme color mode)
COLORFGBGTerminal background light/dark auto-detection
TERM_PROGRAM, TERM_PROGRAM_VERSION, TERMINAL_EMULATORTerminal identity in system prompt/context
KDE_FULL_SESSION, XDG_CURRENT_DESKTOP, DESKTOP_SESSION, XDG_SESSION_DESKTOP, GDMSESSION, WINDOWMANAGERDesktop/window-manager detection in system prompt/context
KITTY_WINDOW_ID, TMUX_PANE, TERM_SESSION_ID, WT_SESSIONStable per-terminal session breadcrumb IDs
SHELL, ComSpec, TERM_PROGRAM, TERMSystem info diagnostics
APPDATA, XDG_CONFIG_HOMElspmux config path resolution
HOMEPath shortening in MCP command UI

9) Native loader/debug flags

VariableBehavior
PI_DEVEnables verbose native addon load diagnostics in packages/natives

10) TUI runtime flags (shared package, affects coding-agent UX)

VariableBehavior
PI_NOTIFICATIONSoff / 0 / false suppress desktop notifications
PI_TUI_WRITE_LOGIf set, logs TUI writes to file
PI_HARDWARE_CURSORIf 1, enables hardware cursor mode
PI_CLEAR_ON_SHRINKIf 1, clears empty rows when content shrinks
PI_DEBUG_REDRAWIf 1, enables redraw debug logging
PI_TUI_DEBUGIf 1, enables deep TUI debug dump path

11) Commit generation controls

VariableBehavior
PI_COMMIT_TEST_FALLBACKIf true (case-insensitive), force commit fallback generation path
PI_COMMIT_NO_FALLBACKIf true, disables fallback when agent returns no proposal
PI_COMMIT_MAP_REDUCEIf false, disables map-reduce commit analysis path
DEBUGIf set, commit agent error stack traces are printed

Security-sensitive variables

Treat these as secrets; do not log or commit them:

  • Provider/API keys and OAuth/bearer credentials (all *_API_KEY, *_TOKEN, OAuth access/refresh tokens)
  • Cloud credentials (AWS_*, GOOGLE_APPLICATION_CREDENTIALS path may expose service-account material)
  • Search/provider auth vars (EXA_API_KEY, BRAVE_API_KEY, PERPLEXITY_API_KEY, Anthropic search keys)
  • Foundry mTLS material (CLAUDE_CODE_CLIENT_CERT, CLAUDE_CODE_CLIENT_KEY, NODE_EXTRA_CA_CERTS when it points to private CA bundles)

Python runtime also explicitly strips many common key vars before spawning kernel subprocesses (packages/coding-agent/src/ipy/runtime.ts).