Skip to main content
Watch: I Built an AI App Without Leaving Databricks

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

Codex CLI environment variables
VariableDescriptionExample
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 sqlite_home config option takes precedence. Relative paths resolve from the current working directory.

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 codex command. The standalone package cache still lives under CODEX_HOME/packages/standalone.

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 codex login --with-access-token.

Docs: CODEX_ACCESS_TOKEN
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 SSL_CERT_FILE.

Docs: CODEX_CA_CERTIFICATE
-no example
SSL_CERT_FILE

Fallback PEM CA bundle path for HTTPS, login, and WebSocket clients when CODEX_CA_CERTIFICATE is unset.

Docs: SSL_CERT_FILE
-no example
RUST_LOG

Controls Rust log filtering and verbosity for the CLI and app-server. codex exec defaults to error output unless you set a more verbose value.

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 Ctrl + G in the composer for longer prompts.

Docs: VISUAL
-no example
EDITOR

Editor opened by Ctrl + G in the composer when VISUAL is not set.

Docs: EDITOR
-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

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.