Codex CLI reference - Environment variables
Codex CLI environment variables
Codex CLI documents 14 environment variables, including CODEX_HOME, CODEX_SQLITE_HOME and CODEX_NON_INTERACTIVE. Codex CLI reads these from your shell environment. Each row gives the docs' description, accepted values and an example where one is documented.
Last verified 2 official pagesFull Codex CLI reference
| Variable | Description | Example |
|---|---|---|
CODEX_HOME | Sets the root for Codex state, including config, auth, logs, sessions, skills, and standalone package metadata. If you set it, the directory must already exist. Default: ~/.codex Docs: CODEX_HOME | CODEX_HOME=$(pwd)/.codex codex exec "List active instruction sources" |
CODEX_SQLITE_HOME | Sets where SQLite-backed state is stored; the Default: CODEX_HOME Docs: CODEX_SQLITE_HOME | -no example |
CODEX_NON_INTERACTIVE | Skip prompts in the standalone install scripts; prompts use their default response, so use it for scripted installs and updates, not first-run setup. Set to 1, true, or yes; default false Docs: CODEX_NON_INTERACTIVE | curl -fsSL https://chatgpt.com/codex/install.sh | CODEX_NON_INTERACTIVE=1 sh |
CODEX_INSTALL_DIR | Changes where the standalone installer puts the visible Default: ~/.local/bin on macOS/Linux; %LOCALAPPDATA%\Programs\OpenAI\Codex\bin on Windows Docs: CODEX_INSTALL_DIR | -no example |
CODEX_API_KEY | Provides an API key to a non-interactive Codex process (exec, review, TypeScript SDK, remote exec-server). Set it inline rather than job-wide when running repository-controlled code. Docs: CODEX_API_KEY | -no example |
CODEX_ACCESS_TOKEN | Provides a ChatGPT or Codex access token for trusted automation (CLI, app-server). For persisted login, pipe it to | printenv CODEX_ACCESS_TOKEN | codex login --with-access-token |
OPENAI_FEDERATION_RULE_ID | Workload identity: selects the federation rule configured for the workload. Docs: OPENAI_FEDERATION_RULE_ID | -no example |
OPENAI_IDENTITY_TOKEN_FILE | Workload identity: points to the absolute path of the file that contains the current OIDC token or SPIFFE JWT-SVID. Docs: OPENAI_IDENTITY_TOKEN_FILE | -no example |
OPENAI_WORKLOAD_IDENTITY_CONTEXT | Workload identity: optionally supplies bounded JSON identifiers for client-reported audit attribution. It does not affect authentication or authorization. Docs: OPENAI_WORKLOAD_IDENTITY_CONTEXT | -no example |
CODEX_CA_CERTIFICATE | Points to a PEM CA bundle for environments with corporate TLS interception or private root certificates. Takes precedence over | -no example |
SSL_CERT_FILE | Fallback PEM CA bundle path for HTTPS, login, and WebSocket clients when | -no example |
RUST_LOG | Controls Rust log filtering and verbosity for the CLI and app-server. error, warn, info, debug, trace, or targeted filters such as codex_core=debug,codex_tui=debug Docs: RUST_LOG | RUST_LOG=debug codex -c log_dir=./.codex-log
tail -F ./.codex-log/codex-tui.log |
VISUAL | Editor opened by | -no example |
EDITOR | Editor opened by | -no example |
The rest of the Codex CLI reference
FAQ
How many environment variables does Codex CLI have?
The official Codex CLI docs list 14 environment variables, including CODEX_HOME, CODEX_SQLITE_HOME and CODEX_NON_INTERACTIVE. All of them are in the table above, in the docs' order.
What does CODEX_HOME do in Codex CLI?
Sets the root for Codex state, including config, auth, logs, sessions, skills, and standalone package metadata. If you set it, the directory must already exist. Values: Default: ~/.codex. Example: CODEX_HOME=$(pwd)/.codex codex exec "List active instruction sources"
Where are Codex CLI environment variables documented?
On 2 official docs pages at learn.chatgpt.com, last read on October 17, 2026. Every row in the table links the exact section it came from.
More on Codex CLI
- Codex CLI in the tools directoryWhat it is, who makes it and how it fits next to other coding agents.
- Codex CLI errors and fixes14 error messages, quoted verbatim, with the documented fix for each.
- Codex and ChatGPT usage limitsPlan and tier limits for this tool, copied from the official docs.
Use other models in Codex CLI
Setup guides from the model-in-tool directory, each with the env vars and base URL from official docs.
Sources
Last verified . Names and examples are copied verbatim from the 2 official pages below, and every row above links the exact section it came from.
Newsletter
Know when your tools change
One email per week. New coding agent releases, the flags and commands they add, and what they mean for how you work.