Installation
1
Check Node.js Version
2
Install Codex CLI
Configure ePhone AI
Codex CLI usesmodel_providers to define custom API providers, and the top-level model_provider key to specify which provider to use by default.
1
Set the API Key Environment Variable
Mac / Linux (zsh)
Mac / Linux (zsh)
Mac / Linux (bash)
Mac / Linux (bash)
Windows (PowerShell)
Windows (PowerShell)
2
Create the Configuration File
~/.codex/config.toml:Getting Started & Approval Modes
Set the default approval mode in
config.toml:
Common Commands
CLI Launch Options
In-Session Commands
Use these slash commands during an interactive session:Recommended Models
Project Configuration: AGENTS.md
Codex automatically readsAGENTS.md files on startup as project context instructions, similar to Claude Code’s CLAUDE.md. Through layered configuration, you can set different rules for different projects and directories.
Discovery Order
- Global:
~/.codex/AGENTS.md— shared defaults for all projects - Project root:
<project-root>/AGENTS.md— project-level rules - Subdirectories:
<subdir>/AGENTS.md— subdirectory overrides
AGENTS.override.md, which takes priority over AGENTS.md in the same directory.
Global Configuration Example
Project Configuration Example
Subdirectory Override Example
Configuration Profiles
Profiles let you quickly switch between different configuration sets — ideal for different projects or scenarios:--profile:
Each profile needs
model_provider = "ephone" — otherwise switching profiles may fall back to the default OpenAI provider.MCP Server Integration
Codex CLI supports MCP (Model Context Protocol) to connect external tools, significantly extending its Agent capabilities.Reasoning Control
For models that support reasoning (e.g.,o4-mini), you can control reasoning depth:
medium for daily tasks and high for complex refactoring.
Web Search
Codex supports web search during conversations to fetch the latest documentation and information:cached: Uses an OpenAI-maintained index (default, fast)live: Fetches live web pages (most current info)disabled: Turns off search entirely
--search:
Sandbox & Security
Codex provides three sandbox levels to protect your system:Usage Examples
Code Refactoring
Bug Fixing with Screenshots
Project Scaffolding
Git Operations
Code Review
Full Configuration Reference
Troubleshooting
WebSocket connecting to api.openai.com
WebSocket connecting to api.openai.com
Cause: Missing
model_provider configuration, causing Codex to route WebSocket connections to OpenAI’s servers instead of ePhone AI.Fix: Ensure model_provider = "ephone" is set at the top level of config.toml. This routes connections to wss://api.ephone.ai/v1/responses.env_key not working
env_key not working
Cause:
env_key should contain the name of the environment variable (e.g., "OPENAI_API_KEY"), not the API key value itself.Fix: Set env_key = "OPENAI_API_KEY" and make sure the variable is exported via export OPENAI_API_KEY="sk-...".Switching profiles falls back to OpenAI
Switching profiles falls back to OpenAI
Cause: The profile doesn’t include
model_provider, so it reverts to the default OpenAI provider.Fix: Add model_provider = "ephone" to every profile section.Important Notes
- Set
disable_response_storage = trueto disable API response storage — required for third-party providers - Use the
/compactcommand to compress overly long conversation history and prevent context window limits - Log files are located at
~/.codex/log/— check them for troubleshooting
Related Resources
Official Codex Docs
OpenAI developer documentation
GitHub Repository
Source code & issues
AGENTS.md Spec
Project configuration spec