Skip to main content
POST /v1/responses/compact 发送支持压缩的 model 与完整上下文 input;常用可选字段为 instructions。接口为非流式请求,不支持把 stream: true 当作 SSE 开关。更多供应商扩展需逐渠道确认。 返回 object: response.compaction、output 及可选 usage。output 包含压缩项,也可能保留消息等其他条目;完整回放它们,不根据普通 Responses 的 status 字段判断压缩成功。密文内容保持原样。 网关 DTO 接收 previous_response_id,但状态解析依赖上游;本文示例显式传历史,不承诺跨渠道 ID 续接、通用资源查询或自动压缩。 压缩与续聊示例 · 创建响应 Read in English

授权

Authorization
string
header
必填

模型调用 API Key,不是控制台登录凭据 / Model API key, not console login credentials

请求体

application/json
model
string
必填

模型列表返回的原始 ID;需要支持当前接口 / Exact ID from the model list; must support this endpoint

示例:

"YOUR_MODEL_ID"

input

文本或输入项数组;内容块和工具项需模型支持 / Text or input items; content blocks and tool items require model support

instructions
string

本次压缩指令;续聊时再次明确发送所需指令 / Instructions for this compaction; explicitly send needed instructions again when continuing

previous_response_id
string

DTO 接收但状态解析依赖上游;建议显式历史 / Accepted by the DTO but state resolution requires upstream support; prefer explicit history

响应

成功结构仍需检查业务字段 / Check business fields even on HTTP success

object
enum<string>
必填
可用选项:
response.compaction
output
object[]
必填

下一轮完整上下文窗口,保留所有条目及顺序 / Complete next context window; retain all items and their order

id
string
created_at
number
usage
object | null