Skip to main content
This guide covers the most common configuration options you’ll need to get started with Codex CLI.

Model Selection

Choose which AI model Codex uses for conversations:
The default model is o4-mini. Run codex --model <model-name> to override for a single session.

Available Models

Common model options:
  • o4-mini - Fast, cost-effective reasoning model (default)
  • gpt-4.1 - Latest GPT-4 with enhanced capabilities
  • gpt-5.1 - Advanced GPT-5 model
  • gpt-5.1-codex - GPT-5 optimized for code

Approval Policies

Control when Codex asks for permission before executing commands:
approval_policy
string
default:"untrusted"
Determines when the user is consulted to approve operations.Options:
  • "untrusted" - Only auto-approve safe read operations; ask for everything else
  • "on-request" - The model decides when to ask for approval
  • "on-failure" - DEPRECATED: Auto-approve sandboxed commands, escalate on failure
  • "never" - Never ask; failures return immediately to the model

Approval Policy Details

Under this policy, only “known safe” commands that only read files are auto-approved. Everything else will ask the user to approve.Best for: Interactive use when you want visibility into all operations
The AI model decides when to ask the user for approval based on the operation’s risk and context.Best for: Balanced interactive use with intelligent approval prompting
Commands are never escalated to the user for approval. Failures are immediately returned to the model to handle programmatically.Best for: Fully automated workflows, CI/CD pipelines

Sandbox Mode

Define execution boundaries for safety:
sandbox_mode
string
default:"workspace-write"
Controls where Codex can read and write files.Options:
  • "read-only" - Can only read files, no writes allowed
  • "workspace-write" - Can read anywhere, write only in workspace
  • "danger-full-access" - Full filesystem access (use with caution)
danger-full-access mode disables safety restrictions. Only use in trusted environments.

Workspace Write Configuration

Customize the workspace-write sandbox behavior:
sandbox_workspace_write.network_access
boolean
default:"false"
Allow network access in workspace-write mode
sandbox_workspace_write.writable_roots
array
default:"[]"
Additional directories where writes are allowed (absolute paths)

API Authentication

OpenAI API Key

Set your OpenAI API key via environment variable:
Or store it in a .env file in your project root:

ChatGPT Login

Alternatively, authenticate with your ChatGPT account:

Credential Storage

Configure where Codex stores authentication credentials:
cli_auth_credentials_store
string
default:"auto"
Where to store CLI authentication credentials.Options:
  • "file" - Store in ~/.codex/auth.json
  • "keyring" - Use OS keyring (most secure)
  • "auto" - Prefer keyring, fall back to file
  • "ephemeral" - Memory only (current process)

System Instructions

Customize Codex’s behavior with custom instructions:
For project-specific guidance, use AGENTS.md files instead of global instructions. See Custom Instructions.

TUI Settings

Customize the terminal interface:
tui.notifications
boolean
default:"true"
Enable desktop notifications when terminal is unfocused
tui.alternate_screen
string
default:"auto"
Controls whether the TUI uses alternate screen buffer.Options:
  • "auto" - Disable in Zellij, enable elsewhere
  • "always" - Always use alternate screen
  • "never" - Never use alternate screen (preserves scrollback)
tui.animations
boolean
default:"true"
Enable welcome screen animations and effects

Notification Command

Run a custom command when Codex completes a turn:
The notification hook receives a JSON payload on stdin with turn details.

History Settings

Configure conversation history persistence:
history.persistence
string
default:"save-all"
Whether to save conversation history.Options:
  • "save-all" - Save all history to ~/.codex/history.jsonl
  • "none" - Don’t save history to disk
history.max_bytes
integer
Maximum history file size in bytes. Oldest entries are dropped when exceeded.

Analytics & Telemetry

analytics.enabled
boolean
default:"true"
Enable usage analytics collection
feedback.enabled
boolean
default:"true"
Enable feedback prompts in the UI

Example Basic Configuration

Here’s a complete basic configuration:

Next Steps

Advanced Configuration

Explore profiles, reasoning effort, and more

Custom Providers

Use alternative AI providers