Back to Models

GPT-5.2-Codex

openaiopenai/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
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
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
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
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
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
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
sourceURLretrieved
Release dateopenai.com β†—2026-05-28verified
Knowledge cutoffsimonwillison.net β†—2026-05-28verified
Architectureβ€”β€”unknown
Context compactionplatform.openai.com β†—2026-05-28verified
Windows supportopenai.com β†—2026-05-28verified
Successoropenai.com β†—2026-05-28verified
SWE-Bench Proopenai.com β†—2026-05-28verified
Terminal-Bench 2.0openai.com β†—2026-05-28verified
SWE-Bench Verified (Python)nxcode.io β†—2026-05-28to verify
CVE-Benchnxcode.io β†—2026-05-28to verify
AIME 2025digitalapplied.com β†—2026-05-28to verify
OpenAI releases GPT-5.3-Codex, successor to GPT-5.2-Codexopenai.com β†—2026-05-28verified
OpenAI launches GPT-5.2-Codexopenai.com β†—2026-05-28verified
What is the difference between GPT-5.2-Codex and GPT-5.2?openai.com β†—2026-05-28to verify
Should I use GPT-5.2-Codex or GPT-5.3-Codex?openai.com β†—2026-05-28to verify
Can I use GPT-5.2-Codex through the standard OpenAI SDK on TheRouter?openai.com β†—2026-05-28to verify
What cybersecurity capabilities does GPT-5.2-Codex have?openai.com β†—2026-05-28to verify
Is GPT-5.2-Codex still available on TheRouter?openai.com β†—2026-05-28to verify
Help & contact