Codex CLI is OpenAI’s official command-line AI coding agent. It lets you complete code generation, refactoring, debugging, file editing, and system command execution directly from your terminal using natural language. Compared to other AI coding tools, Codex CLI features full sandbox isolation and fine-grained permission control.Documentation Index
Fetch the complete documentation index at: https://docs.rixapi.com/docs/llms.txt
Use this file to discover all available pages before exploring further.
Installation
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.
Getting Started & Approval Modes
| Mode | Config Value | Description |
|---|---|---|
| Suggest | untrusted | Default. Codex can only read files — all writes and commands require your confirmation |
| Auto Execute | on-request | Safe sandbox operations run automatically; only privilege escalation requires confirmation |
| Full Auto | never | No confirmation needed. Codex acts autonomously — best for trusted dev environments |
config.toml:
Common Commands
CLI Launch Options
| Command | Description |
|---|---|
codex | Start an interactive session |
codex "task description" | Run a one-off task directly |
codex --model gpt-4o "task" | Run a task with a specific model |
codex --image screenshot.png "fix this bug" | Attach an image as context |
codex --search "task description" | Enable web search for the task |
codex --profile fast "quick task" | Use a preset configuration profile |
In-Session Commands
Use these slash commands during an interactive session:| Command | Description |
|---|---|
/status | View current model, token usage, and config info |
/model | Switch the active model |
/approvals | Adjust the approval policy for the current session |
/compact | Compress conversation history to free context window |
/clear | Clear the current conversation history |
/init | Create an AGENTS.md template in the current directory |
/feedback | Submit feedback |
Recommended Models
| Use Case | Recommended Model | Notes |
|---|---|---|
| Everyday coding | gpt-4o | Good balance of speed and capability |
| Complex refactoring | o4-mini | Strong reasoning for deep analysis tasks |
| Quick lightweight tasks | gpt-4o-mini | Fast response, lower cost |
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:| Mode | Description |
|---|---|
read-only | Read-only mode — cannot modify files or run write commands |
workspace-write | Can modify files within the workspace directory (default) |
danger-full-access | Full access with no restrictions (use with caution) |
Usage Examples
Code Refactoring
Bug Fixing with Screenshots
Project Scaffolding
Git Operations
Code Review
Full Configuration Reference
Troubleshooting
401 Unauthorized — still connecting to api.openai.com
401 Unauthorized — still connecting to api.openai.com
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