Primary navigation

Environment variables

Environment variables supported by Codex

Codex uses config.toml for durable settings. Use environment variables for shell-scoped overrides, automation secrets, installer behavior, or diagnostics.

This page lists stable public environment variables that Codex reads directly. It does not list internal development variables, test variables, or provider-specific secret names you choose yourself with env_key.

Core locations

VariableUsed byDefaultDescription
CODEX_HOMECLI, IDE extension, app-server, installers~/.codexSets the root for Codex state, including config, auth, logs, sessions, skills, and standalone package metadata. If you set it, the directory must already exist.
CODEX_SQLITE_HOMECLI and app-server stateCODEX_HOMESets where SQLite-backed state is stored. The sqlite_home config option takes precedence. Relative paths resolve from the current working directory.

For more about the files stored under CODEX_HOME, see Config and state locations.

Installer variables

These variables apply to the standalone install scripts served from https://chatgpt.com/codex/install.sh and https://chatgpt.com/codex/install.ps1.

VariableDefaultDescription
CODEX_NON_INTERACTIVEfalseSet to 1, true, or yes to skip installer prompts. Prompts use their default response, so use this for scripted installs and updates, not first-run setup.
CODEX_INSTALL_DIR~/.local/bin on macOS/Linux; %LOCALAPPDATA%\Programs\OpenAI\Codex\bin on WindowsChanges where the visible codex command is installed. The standalone package cache still lives under CODEX_HOME/packages/standalone.

For unattended installs, set CODEX_NON_INTERACTIVE=1 on the shell that runs the downloaded installer:

curl -fsSL https://chatgpt.com/codex/install.sh | CODEX_NON_INTERACTIVE=1 sh
$env:CODEX_NON_INTERACTIVE=1; irm https://chatgpt.com/codex/install.ps1 | iex

Authentication and network

VariableUsed byDescription
CODEX_API_KEYcodex execProvides an API key for a single non-interactive run. This is only supported in codex exec; set it inline rather than job-wide when running repository-controlled code.
CODEX_ACCESS_TOKENCLI, app-server, trusted automationProvides a ChatGPT or Codex access token for trusted automation. For persisted login, pipe it to codex login --with-access-token.
CODEX_CA_CERTIFICATEHTTPS, login, and WebSocket clientsPoints to a PEM CA bundle for environments with corporate TLS interception or private root CAs. Takes precedence over SSL_CERT_FILE.
SSL_CERT_FILEHTTPS, login, and WebSocket clientsFallback PEM CA bundle path when CODEX_CA_CERTIFICATE is unset.

For provider API keys, set env_key in the model provider configuration. Codex reads the variable named by that config, so the variable name itself is not a fixed Codex environment variable.

For automation secret handling, see Use API key auth. For access token setup, see Access tokens.

Diagnostics

VariableUsed byDescription
RUST_LOGCLI and app-serverControls Rust log filtering and verbosity. codex exec defaults to error output unless you set a more verbose value.

RUST_LOG accepts values such as error, warn, info, debug, and trace. It also accepts more targeted Rust logging filters, such as codex_core=debug,codex_tui=debug.

The interactive CLI records diagnostics in bounded local stores by default, but the plaintext codex-tui.log file is opt-in. Set log_dir explicitly when you need a plaintext log for troubleshooting:

RUST_LOG=debug codex -c log_dir=./.codex-log
tail -F ./.codex-log/codex-tui.log

In non-interactive mode, codex exec prints messages inline instead of writing to a separate TUI log file.