返回模型列表
GPT-5.2-Codex
openaiopenai/gpt-5.2-codex
API 使用指南
Chat 调用
标准 Chat 补全——将 baseURL 改为 api.therouter.ai/v1 即可用 OpenAI SDK 调用。支持所有 GPT-5.2-Codex 参数,包括 reasoning_effort、tools 和 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."}
]
}'流式输出
对于长程编程会话,流式输出让你无需等待完整响应就能看到中间结果。GPT-5.2-Codex 支持基于 SSE 的标准流式输出。
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
}'函数调用 / 工具
GPT-5.2-Codex 擅长 agentic 工具调用——该模型可编排并行工具调用并在多步骤工具使用会话中维护状态,非常适合需要读文件、跑测试或查询数据库的编程 agent。
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"
}'推理强度
GPT-5.2-Codex 支持可配置的推理强度。该模型继承了 GPT-5.2 的推理深度——在基准测试上与 GPT-5.2-Thinking 持平——同时增加了 Codex 专有的长程 agent 任务优化。
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 模式
GPT-5.2-Codex 支持 response_format 实现结构化 JSON 输出。适用于从代码中提取结构化数据、生成类型接口或产生机器可读的分析结果。
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" }
}'视觉 / 图片输入
GPT-5.2-Codex 支持图片输入,可解读截图、技术图、设计稿和 UI 界面。该模型可将设计原型转化为功能代码,并能从截图中分析 UI 错误。
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
}'事实档案 — 本页每条断言可在此回溯来源
| 来源 | URL | 采集于 | |
|---|---|---|---|
| 发布日期 | openai.com ↗ | 2026-05-28 | 已核实 |
| 知识截止日期 | simonwillison.net ↗ | 2026-05-28 | 已核实 |
| 架构 | — | — | 未知 |
| 上下文压缩 | platform.openai.com ↗ | 2026-05-28 | 已核实 |
| Windows 支持 | openai.com ↗ | 2026-05-28 | 已核实 |
| 后继模型 | openai.com ↗ | 2026-05-28 | 已核实 |
| SWE-Bench Pro | openai.com ↗ | 2026-05-28 | 已核实 |
| Terminal-Bench 2.0 | openai.com ↗ | 2026-05-28 | 已核实 |
| SWE-Bench Verified (Python) | nxcode.io ↗ | 2026-05-28 | 待核实 |
| CVE-Bench | nxcode.io ↗ | 2026-05-28 | 待核实 |
| AIME 2025 | digitalapplied.com ↗ | 2026-05-28 | 待核实 |
| OpenAI 发布 GPT-5.3-Codex,GPT-5.2-Codex 的后继模型 | openai.com ↗ | 2026-05-28 | 已核实 |
| OpenAI 发布 GPT-5.2-Codex | openai.com ↗ | 2026-05-28 | 已核实 |
| GPT-5.2-Codex 和 GPT-5.2 有什么区别? | openai.com ↗ | 2026-05-28 | 待核实 |
| 应该用 GPT-5.2-Codex 还是 GPT-5.3-Codex? | openai.com ↗ | 2026-05-28 | 待核实 |
| 我能在 TheRouter 上通过标准 OpenAI SDK 使用 GPT-5.2-Codex 吗? | openai.com ↗ | 2026-05-28 | 待核实 |
| GPT-5.2-Codex 有哪些网络安全能力? | openai.com ↗ | 2026-05-28 | 待核实 |
| GPT-5.2-Codex 在 TheRouter 上还可以使用吗? | openai.com ↗ | 2026-05-28 | 待核实 |