OpenAI Codex CLI & Responses API
Codex CLI
Approval Modes
| Mode | Behavior |
|---|---|
| Suggest | Proposes changes, user approves each |
| Auto Edit | Auto-applies file edits, asks for commands |
| Full Auto | Executes everything autonomously |
Sandbox Architecture
| Platform | Technology |
|---|---|
| macOS | Seatbelt (sandbox-exec) |
| Linux | Docker container |
| Windows | WSL2 |
workspace-write(default): Read/edit within workspace onlydanger-full-access: No restrictions
AGENTS.md (Instructions File)
Hierarchical loading:
~/.codex/AGENTS.md— global<project>/AGENTS.md— project-level<project>/.codex/AGENTS.md— alternative location
Multi-Provider Support
10+ providers via OpenAI-compatible API:
- OpenAI, Anthropic, Google Gemini, Mistral, Groq, Ollama, Azure, etc.
Product Variants
| Variant | Description |
|---|---|
| Codex CLI | Terminal agent |
| Codex IDE | VS Code / JetBrains integration |
| Codex Web | Cloud-hosted in GitHub Actions |
Enterprise Admin Controls
- Allowed approval policies and sandbox modes
- Web search behavior restrictions
- MCP server allowlists
- Feature pins and command restrictions
Responses API
New API replacing Chat Completions for agentic use cases.
Built-in Tools
| Tool | Purpose |
|---|---|
web_search |
Search the web |
file_search |
RAG over uploaded files |
code_interpreter |
Python sandbox execution |
computer_use |
Desktop automation |
mcp |
MCP server tools |
image_generation |
DALL-E integration |
State Management
# Auto-chaining with previous_response_id
response1 = client.responses.create(
model="gpt-4o",
input="What's the weather in NYC?"
)
response2 = client.responses.create(
model="gpt-4o",
input="And in London?",
previous_response_id=response1.id # Carries context
)
Conversation State
previous_response_id— chain responsesconversation_id— persistent conversations- Both HTTP and WebSocket transport
OpenAI Guardrails Library
Standalone safety library with 8 built-in checks:
from openai_guardrails import GuardrailsOpenAI
# Drop-in replacement for OpenAI client
client = GuardrailsOpenAI(config_path="guardrails.json")
response = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "..."}]
)
Built-in Guardrails
| Guardrail | Purpose |
|---|---|
| Moderation | Content classification |
| URL Filter | Domain allowlists/blocklists |
| Contains PII | Personal data detection |
| Hallucination | Vector store comparison |
| Jailbreak | Manipulation detection |
| NSFW Text | Inappropriate content |
| Off Topic | Business scope enforcement |
| Custom Prompt | LLM-based custom rules |
Pipeline Configuration (JSON)
{
"stages": {
"preflight": ["moderation", "jailbreak_detection"],
"input": ["pii_detection", "off_topic"],
"output": ["hallucination_detection", "url_filter"]
}
}