Skip to main content
POST
/
v1
/
responses
/
compact
curl -X POST https://gogogotoken.ai/v1/responses/compact \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-5.2-codex",
    "input": [
      {
        "role": "user",
        "content": "Summarize the current coding session for continuation."
      }
    ]
  }'
{
  "id": "resp_abc123",
  "object": "response",
  "model": "gpt-5.2-codex",
  "status": "completed",
  "output": [
    {
      "type": "message",
      "role": "assistant",
      "content": [
        {
          "type": "output_text",
          "text": "The session focused on refactoring API documentation pages..."
        }
      ]
    }
  ],
  "usage": {
    "input_tokens": 1800,
    "output_tokens": 260,
    "total_tokens": 2060
  }
}
使用 Codex 上下文压缩接口压缩长会话上下文,降低后续请求的上下文体积。该端点主要供 Codex CLI 或兼容 Responses API 的客户端使用。
curl -X POST https://gogogotoken.ai/v1/responses/compact \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-5.2-codex",
    "input": [
      {
        "role": "user",
        "content": "Summarize the current coding session for continuation."
      }
    ]
  }'
{
  "id": "resp_abc123",
  "object": "response",
  "model": "gpt-5.2-codex",
  "status": "completed",
  "output": [
    {
      "type": "message",
      "role": "assistant",
      "content": [
        {
          "type": "output_text",
          "text": "The session focused on refactoring API documentation pages..."
        }
      ]
    }
  ],
  "usage": {
    "input_tokens": 1800,
    "output_tokens": 260,
    "total_tokens": 2060
  }
}

接口说明

该接口用于把较长的 Codex 会话内容压缩成更短的延续上下文。Base URL 只填写 https://gogogotoken.ai,实际请求路径为 /v1/responses/compact
普通 Codex 对话请使用 POST /v1/responses。只有需要压缩上下文时才调用该端点。

请求头

Authorization
string
required
API Key 鉴权信息,格式为 Bearer YOUR_API_KEY
Content-Type
string
required
固定为 application/json

请求体

model
string
default:"gpt-5.2-codex"
required
Codex 模型 ID,例如 gpt-5.2-codex。完整列表以 GET /v1/models 与分组配置为准。
input
string
required
需要压缩的上下文内容。可传字符串,也可传 Responses API 兼容的结构化输入。
prompt_cache_key
string
可选的缓存键。网关可基于该字段保持同一会话上游路由稳定。

响应体

id
string
本次压缩响应 ID。
status
string
响应状态,例如 completedfailed
output
object[]
压缩后的上下文内容。文本结果通常位于 output[].content[].text
usage
object
token 用量统计。

错误码

状态码含义处理建议
401API Key 无效或未传检查请求头与令牌状态
403无权限访问目标 Codex 模型检查 API Key 分组权限
404路径配置错误确认请求路径为 /v1/responses/compact
429触发限速降低请求频率或调整套餐
5xx上游或网关异常稍后重试,并查看控制台日志