{
"id": "cmp_example",
"object": "response.compaction",
"created_at": 1700000000,
"output": [
{
"type": "message",
"role": "user",
"content": [
{
"type": "input_text",
"text": "Plan a two-day visit."
}
]
},
{
"type": "compaction",
"id": "cmp_item",
"encrypted_content": "OPAQUE_STATE_FROM_UPSTREAM"
}
]
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<unknown>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<unknown>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<unknown>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<unknown>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<unknown>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<unknown>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<unknown>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<unknown>"
}
}API 参考
压缩响应上下文
返回可用于下一轮 Responses 请求的完整窗口。
{
"id": "cmp_example",
"object": "response.compaction",
"created_at": 1700000000,
"output": [
{
"type": "message",
"role": "user",
"content": [
{
"type": "input_text",
"text": "Plan a two-day visit."
}
]
},
{
"type": "compaction",
"id": "cmp_item",
"encrypted_content": "OPAQUE_STATE_FROM_UPSTREAM"
}
]
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<unknown>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<unknown>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<unknown>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<unknown>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<unknown>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<unknown>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<unknown>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<unknown>"
}
}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授权
模型调用 API Key,不是控制台登录凭据 / Model API key, not console login credentials
请求体
application/json
模型列表返回的原始 ID;需要支持当前接口 / Exact ID from the model list; must support this endpoint
示例:
"YOUR_MODEL_ID"
文本或输入项数组;内容块和工具项需模型支持 / Text or input items; content blocks and tool items require model support
本次压缩指令;续聊时再次明确发送所需指令 / Instructions for this compaction; explicitly send needed instructions again when continuing
DTO 接收但状态解析依赖上游;建议显式历史 / Accepted by the DTO but state resolution requires upstream support; prefer explicit history