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 capabilitiesgpt-5.1- Advanced GPT-5 modelgpt-5.1-codex- GPT-5 optimized for code
Approval Policies
Control when Codex asks for permission before executing commands: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
untrusted (Default)
untrusted (Default)
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
on-request
on-request
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
never
never
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: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)
Workspace Write Configuration
Customize theworkspace-write sandbox behavior:
Allow network access in workspace-write mode
Additional directories where writes are allowed (absolute paths)
API Authentication
OpenAI API Key
Set your OpenAI API key via environment variable:.env file in your project root:
ChatGPT Login
Alternatively, authenticate with your ChatGPT account:Credential Storage
Configure where Codex stores authentication credentials: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:Enable desktop notifications when terminal is unfocused
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)
Enable welcome screen animations and effects
Notification Command
Run a custom command when Codex completes a turn:History Settings
Configure conversation history persistence:Whether to save conversation history.Options:
"save-all"- Save all history to~/.codex/history.jsonl"none"- Don’t save history to disk
Maximum history file size in bytes. Oldest entries are dropped when exceeded.
Analytics & Telemetry
Enable usage analytics collection
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