GPT-5.2-Codex
API guide
Chat completion
Standard chat completions β works with the OpenAI SDK by swapping baseURL to api.therouter.ai/v1. Supports all GPT-5.2-Codex parameters including reasoning_effort, tools, and response_format.
curl https://api.therouter.ai/v1/chat/completions \
-H "Authorization: Bearer $THEROUTER_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "openai/gpt-5.2-codex",
"messages": [
{"role": "system", "content": "You are an expert software engineer."},
{"role": "user", "content": "Write a Python function to merge two sorted lists in place."}
]
}'Streaming
For long-running coding sessions, streaming lets you see intermediate results without waiting for the full response. GPT-5.2-Codex supports standard SSE-based streaming via the chat completions endpoint.
curl https://api.therouter.ai/v1/chat/completions \
-H "Authorization: Bearer $THEROUTER_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "openai/gpt-5.2-codex",
"messages": [{"role": "user", "content": "Explain the visitor pattern with a TypeScript example."}],
"stream": true
}'Function calling / tools
GPT-5.2-Codex excels at agentic tool use β the model can orchestrate parallel tool calls and maintain state across multi-step tool-using sessions, making it ideal for coding agents that need to read files, run tests, or query databases.
curl https://api.therouter.ai/v1/chat/completions \
-H "Authorization: Bearer $THEROUTER_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "openai/gpt-5.2-codex",
"messages": [
{"role": "user", "content": "Find all pending-review comments in the /src directory"}
],
"tools": [{
"type": "function",
"function": {
"name": "search_files",
"description": "Search for text patterns in files",
"parameters": {
"type": "object",
"properties": {
"pattern": {"type": "string"},
"path": {"type": "string"}
},
"required": ["pattern", "path"]
}
}
}],
"tool_choice": "auto"
}'Reasoning effort
GPT-5.2-Codex supports configurable reasoning effort. The model inherits GPT-5.2's reasoning depth β matching GPT-5.2-Thinking on benchmarks β while adding Codex-specific optimizations for long-horizon agentic tasks.
curl https://api.therouter.ai/v1/chat/completions \
-H "Authorization: Bearer $THEROUTER_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "openai/gpt-5.2-codex",
"messages": [
{"role": "user", "content": "Design a distributed cache eviction strategy for a multi-region deployment."}
],
"reasoning_effort": "high"
}'JSON mode
GPT-5.2-Codex supports response_format for structured JSON output. Useful for extracting structured data from code, generating typed interfaces, or producing machine-readable analysis results.
curl https://api.therouter.ai/v1/chat/completions -H "Authorization: Bearer $THEROUTER_API_KEY" -H "Content-Type: application/json" -d '{
"model": "openai/gpt-5.2-codex",
"messages": [
{"role": "user", "content": "Analyze this code and return a structured summary of potential bugs: function add(a,b){return a+b}"}
],
"response_format": { "type": "json_object" }
}'Vision / image input
GPT-5.2-Codex accepts images as input for interpreting screenshots, technical diagrams, design mocks, and UI surfaces. The model can translate design mockups into functional prototypes and analyze UI bugs from screenshots.
curl https://api.therouter.ai/v1/chat/completions -H "Authorization: Bearer $THEROUTER_API_KEY" -H "Content-Type: application/json" -d '{
"model": "openai/gpt-5.2-codex",
"messages": [
{
"role": "user",
"content": [
{"type": "text", "text": "Convert this UI mockup to HTML/CSS code."},
{"type": "image_url", "image_url": {"url": "https://therouter.ai/assets/vision-sample.png"}}
]
}
],
"max_tokens": 4000
}'Fact ledger β every claim on this page traces here
| source | URL | retrieved | |
|---|---|---|---|
| Release date | openai.com β | 2026-05-28 | verified |
| Knowledge cutoff | simonwillison.net β | 2026-05-28 | verified |
| Architecture | β | β | unknown |
| Context compaction | platform.openai.com β | 2026-05-28 | verified |
| Windows support | openai.com β | 2026-05-28 | verified |
| Successor | openai.com β | 2026-05-28 | verified |
| SWE-Bench Pro | openai.com β | 2026-05-28 | verified |
| Terminal-Bench 2.0 | openai.com β | 2026-05-28 | verified |
| SWE-Bench Verified (Python) | nxcode.io β | 2026-05-28 | to verify |
| CVE-Bench | nxcode.io β | 2026-05-28 | to verify |
| AIME 2025 | digitalapplied.com β | 2026-05-28 | to verify |
| OpenAI releases GPT-5.3-Codex, successor to GPT-5.2-Codex | openai.com β | 2026-05-28 | verified |
| OpenAI launches GPT-5.2-Codex | openai.com β | 2026-05-28 | verified |
| What is the difference between GPT-5.2-Codex and GPT-5.2? | openai.com β | 2026-05-28 | to verify |
| Should I use GPT-5.2-Codex or GPT-5.3-Codex? | openai.com β | 2026-05-28 | to verify |
| Can I use GPT-5.2-Codex through the standard OpenAI SDK on TheRouter? | openai.com β | 2026-05-28 | to verify |
| What cybersecurity capabilities does GPT-5.2-Codex have? | openai.com β | 2026-05-28 | to verify |
| Is GPT-5.2-Codex still available on TheRouter? | openai.com β | 2026-05-28 | to verify |