{
"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 reference
Compact response context
Return a complete context window for the next Responses request.
{
"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
Send a compaction-capable model and complete context as input; instructions is a common optional field. This is a non-streaming request. Setting stream: true does not enable SSE. Confirm provider extensions separately for each channel.
The response contains object: response.compaction, output, and optional usage. Output includes compaction items and may retain messages or other items. Replay the complete output and do not use the ordinary Responses status field to detect success. Preserve encrypted content unchanged.
The gateway DTO accepts previous_response_id, but upstream state resolution determines support. The example supplies history explicitly and does not promise cross-channel ID continuation, general resource retrieval, or automatic compaction.
Compaction and continuation example · Create a response
阅读中文Authorizations
模型调用 API Key,不是控制台登录凭据 / Model API key, not console login credentials
Body
application/json
模型列表返回的原始 ID;需要支持当前接口 / Exact ID from the model list; must support this endpoint
Example:
"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
Response
成功结构仍需检查业务字段 / Check business fields even on HTTP success