Codex: Codex Model Selection
Last updated: 2026-08-31
Codex supports multiple AI models with different capabilities, speeds, and costs. Choosing the right model makes all the difference.
📋 Prerequisites: Understanding Codex basic operations
1. What You Will Learn
- Available model list
- Model characteristics and comparison
- Model selection strategies
- Cost optimization tips
2. Available Models
(1) OpenAI Models
| Model | Context | Strength | Best For |
|---|---|---|---|
| o3 | 200K | Strongest reasoning | Complex architecture, algorithm design |
| gpt-5-codex | 128K | Code-specialized | Daily development (default) |
| gpt-4o | 128K | Balanced value | General tasks |
| o4-mini | 128K | Fast & economical | Simple tasks, batch operations |
(2) Third-Party Models (via API)
| Model | Provider | Strength |
|---|---|---|
| deepseek-coder | DeepSeek | Strong code, low cost |
| deepseek-chat | DeepSeek | Good Chinese, general-purpose |
| claude-sonnet | Anthropic | Strong reasoning (requires compatible API) |
3. Model Comparison
(1) Capability Comparison
| Dimension | o3 | gpt-5-codex | gpt-4o | o4-mini | deepseek-coder |
|---|---|---|---|---|---|
| Code Generation | ⭐⭐⭐⭐⭐ | ⭐⭐⭐⭐⭐ | ⭐⭐⭐⭐ | ⭐⭐⭐ | ⭐⭐⭐⭐⭐ |
| Complex Reasoning | ⭐⭐⭐⭐⭐ | ⭐⭐⭐⭐ | ⭐⭐⭐⭐ | ⭐⭐⭐ | ⭐⭐⭐⭐ |
| Multi-file Refactoring | ⭐⭐⭐⭐⭐ | ⭐⭐⭐⭐⭐ | ⭐⭐⭐⭐ | ⭐⭐⭐ | ⭐⭐⭐⭐ |
| Chinese Understanding | ⭐⭐⭐⭐ | ⭐⭐⭐⭐ | ⭐⭐⭐⭐ | ⭐⭐⭐ | ⭐⭐⭐⭐⭐ |
| Response Speed | ⭐⭐ | ⭐⭐⭐ | ⭐⭐⭐ | ⭐⭐⭐⭐⭐ | ⭐⭐⭐⭐ |
(2) Cost Comparison
| Model | Input/1M tokens | Output/1M tokens | Relative Cost |
|---|---|---|---|
| o3 | $15.00 | $60.00 | Most expensive |
| gpt-5-codex | $2.50 | $10.00 | Medium |
| gpt-4o | $2.50 | $10.00 | Medium |
| o4-mini | $0.15 | $0.60 | Cheap |
| deepseek-coder | ¥1.00 | ¥2.00 | Cheapest |
4. Model Selection Strategy
(1) By Task Complexity
| Complexity | Recommended Model | Reason |
|---|---|---|
| Simple (fix lint, add comments) | o4-mini / deepseek-coder | Low cost, fast |
| Medium (add feature, fix bug) | gpt-5-codex | Balance of ability and cost |
| Complex (architecture design, large refactoring) | o3 | Strongest reasoning |
(2) By Task Type
| Task Type | Recommended Model | Reason |
|---|---|---|
| Code generation | gpt-5-codex | Code-specialized |
| Code review | gpt-4o / deepseek-coder | Review doesn't need strongest reasoning |
| Architecture design | o3 | Requires deep reasoning |
| Documentation generation | gpt-4o / deepseek-chat | General capability sufficient |
| Batch operations | o4-mini | Cost priority |
▶ Example 1: Alice's Model Selection
PYTHON
def choose_model(task):
if task.type == "architecture":
return "o3"
elif task.type == "daily_dev":
return "gpt-5-codex"
elif task.type == "batch_fix":
return "o4-mini"
elif task.type == "chinese_doc":
return "deepseek-coder"
else:
return "gpt-5-codex"
5. Switching Models
(1) CLI Switching
BASH
# Specify at launch
codex --model o3
# Switch to DeepSeek
export OPENAI_API_KEY="sk-deepseek-xxx"
export OPENAI_BASE_URL="https://api.deepseek.com"
codex --model deepseek-coder
(2) App Switching
Select from the model dropdown in the top toolbar.
(3) Configuration Files
TOML
# ~/.codex/config.toml
model = "gpt-5-codex"
# Or project-level
# .codex/config.toml
model = "deepseek-coder"
6. Cost Optimization
(1) Strategy Matrix
| Strategy | Description | Savings |
|---|---|---|
| Tiered Usage | Simple tasks use cheaper models | 50-70% |
| DeepSeek Alternative | Daily tasks use DeepSeek | 80-90% |
| Precise Context | Reduce unnecessary files | 20-30% |
| Batch Execution | Merge small tasks | 10-20% |
(2) Cost Estimation
TEXT
📖 Display only
# Alice's monthly cost estimate
Daily development (gpt-5-codex): $50/month
Code review (deepseek-coder): ¥100/month ≈ $14/month
Architecture design (o3): $30/month
Batch fixes (o4-mini): $5/month
Total: ~$99/month
If all o3: ~$500/month
Savings: 80%
❓ FAQ
Q Is the default model gpt-5-codex sufficient?
A For most scenarios, yes. Only complex architecture design and algorithm problems need o3.
Q How much weaker is o4-mini?
A Small gap for simple tasks, noticeable gap for complex reasoning and multi-file refactoring. Try it first, upgrade if unsatisfied.
Q How does DeepSeek perform on English projects?
A English code generation and review perform well, comparable to gpt-5-codex. English documentation and architecture reasoning are slightly weaker.
Q Can I switch models within the same session?
A No. You need to end the current session, switch models, and restart.
Q Does model selection affect the context window?
A Yes. o3 supports 200K, most others 128K. Large projects may need a larger context window.
📖 Summary
- Default gpt-5-codex, complex tasks use o3, simple tasks use o4-mini
- DeepSeek is cheapest with strong Chinese-language advantages
- Choose models by task complexity: simple → cheap model, complex → powerful model
- Cost optimization: tiered usage + DeepSeek alternative + precise context
📝 Exercises
- Basic (⭐): Complete the same task using three different models, compare output quality.
- Intermediate (⭐⭐): Design a cost optimization plan — analyze your task type distribution, select the optimal model for each.
- Advanced (⭐⭐⭐): Write an automatic model selection script that judges task complexity from the description and selects the appropriate model.