POST
/
v1
/
responses
/
compact
Codex Responses Compact
curl --request POST \
  --url https://coder.api.visioncoder.cn/v1/responses/compact \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "model": "gpt-5.3-codex",
  "messages": [
    {
      "content": "<string>"
    }
  ],
  "temperature": 123,
  "max_tokens": 123,
  "stream": false,
  "tools": [
    {}
  ],
  "tool_choice": "<unknown>"
}
'
{
  "id": "<string>",
  "object": "chat.completion",
  "created": 123,
  "model": "<string>",
  "choices": [
    {
      "index": 123,
      "message": {
        "role": "assistant",
        "content": "<string>"
      },
      "finish_reason": "<string>"
    }
  ],
  "usage": {
    "prompt_tokens": 123,
    "completion_tokens": 123,
    "total_tokens": 123
  }
}

调用示例

请求体结构与 Chat Completions 相同;服务端会先把历史轮次自动压缩,再转发到上游。
curl https://coder.api.visioncoder.cn/v1/responses/compact \
  -H "Authorization: Bearer $VISIONCODER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-5.3-codex",
    "messages": [
      {"role": "user", "content": "Refactor this function"}
    ],
    "stream": true
  }'

响应示例

响应结构与 Chat Completions 完全一致;compact 前缀只影响服务端对历史轮次的压缩处理,不改变响应格式。
{
  "id": "chatcmpl-9zZ8w3rTpQ2V6sHk",
  "object": "chat.completion",
  "created": 1779438767,
  "model": "gpt-5.3-codex",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Here is the refactored function:\n\n```python\ndef sum_pairs(xs):\n    return [a + b for a, b in zip(xs, xs[1:])]\n```"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 412,
    "completion_tokens": 64,
    "total_tokens": 476
  }
}
流式响应的 SSE 格式与 /v1/chat/completions 一致。
专为 Codex CLI 的长会话设计。其它客户端按 /v1/chat/completions 的方式调用即可。

加群 & 客服

AI 技术交流群二维码
专属客服二维码

Authorizations

Authorization
string
header
required

Use the API key created at https://coder.visioncoder.cn/key as the Bearer token. Anthropic clients can pass the same key via the x-api-key header.

Body

application/json

Compact request body used by Codex CLI when wire_api="responses" is enabled. Same structure as Chat Completions.

model
string
required

Model ID. Recommended for Codex: gpt-5.3-codex (Codex-specialized) or gpt-5.5 (general strongest). Other GPT-5 variants also work.

Example:

"gpt-5.3-codex"

messages
object[]
required
temperature
number<float>
max_tokens
integer
stream
boolean
default:false
tools
object[]
tool_choice
any

Response

200 - application/json

A successful response.

Codex Compact response body. Same structure as Chat Completions.

id
string
object
string
Example:

"chat.completion"

created
integer
model
string
choices
object[]
usage
object