Skip to content
Get an API key

API reference

Compact a conversation

POST
/v1/responses/compact
curl --request POST \
--url https://api.helping.io/v1/responses/compact \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{ "model": "anthropic/claude-haiku-5-5", "previous_response_id": "resp_ZXhhbXBsZS9jb21wYWN0AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" }'

Writes a summary of the conversation’s older turns, which later responses on it read in place of those turns. The most recent turns are kept in full. The response that is named must be one this key created.

The response whose conversation to compact, and the model that writes the summary.

Media typeapplication/json

Compact a conversation.

Names a stored response and the model that writes the summary. The conversation the response belongs to is compacted on the server, and later responses on it read the summary in place of its older turns.

object
input

Not accepted: only a stored conversation, named by previous_response_id, can be compacted.

object | null
instructions

Accepted and not applied; helpingio:warnings says so.

string | null
model
required

The model that writes the summary: from the same provider as the conversation, and one of the models allowed to compact.

string
previous_response_id

The response whose conversation is compacted. Required.

string | null
prompt_cache_key

Accepted and not applied.

string | null
Example
{
"model": "anthropic/claude-haiku-5-5",
"previous_response_id": "resp_ZXhhbXBsZS9jb21wYWN0AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
}

The compacted conversation: the compaction item, and what writing the summary used.

Media typeapplication/json

A compacted conversation.

output holds the one compaction item; the most recent turns stay on the server and are still sent to the model in full, so the next request needs no change. usage is what writing the summary used.

object
created_at
required
integer format: int64
id
required
string
object
required

Always response.compaction.

string
output
required
Array
One of:

One item of output, discriminated by type.

object
content
required
Array
One of:

Text you are sending to the model.

object
text
required
string
type
required
string
Allowed values: input_text
id
required
string
phase
Any of:

Whether an assistant message is the answer or commentary alongside it.

final_answer marks the message meant as the reply; commentary marks narration produced on the way there.

string
Allowed values: commentary final_answer
role
required

Who a message came from.

string
Allowed values: user assistant system developer
status
required

How far along an output item is.

in_progress while the item is still being produced, completed when it is final, and incomplete when the response stopped before the item was finished.

string
Allowed values: in_progress completed incomplete
type
required
string
Allowed values: message
usage
required

What this response consumed.

Present on terminal responses, including failed ones, so you can see what a failed response cost.

object
input_tokens
required
integer format: int64
input_tokens_details
required

A breakdown of the input tokens counted.

Both fields are SUBSETS of input_tokens, not additions to it.

object
cache_write_tokens
required

Input tokens written INTO the provider’s prompt cache.

A provider that does not charge for a cache write reports 0 here.

integer format: int64
cached_tokens
required

Input tokens served from the provider’s prompt cache.

integer format: int64
output_tokens
required
integer format: int64
output_tokens_details
required

A breakdown of the output tokens counted.

object
reasoning_tokens
required
integer format: int64
total_tokens
required
integer format: int64
Example
{
"output": [
{
"content": [
{
"type": "input_text"
}
],
"phase": "commentary",
"role": "user",
"status": "in_progress",
"type": "message"
}
]
}

The body is malformed, previous_response_id is missing, input was sent, the conversation cannot be compacted or is too short to compact, or model is from another provider (the error envelope).

Missing or invalid API key (the error envelope)

The organization has no payment method on file (the error envelope).

The key is not entitled to what the request asked for (the error envelope)

No such response, or one this key cannot reach.

The named response is still in progress; a compaction of this conversation is in progress, and one that outlasted the wait keeps running and is charged; or part of the conversation was removed while it was being compacted, and helpingio:usage states the charge (the error envelope).

The organization’s credits or a spending limit refused the summary, before it started or part way, when helpingio:usage states what the calls before it were charged; or the model provider rate limited it (the error envelope).

The request could not be completed; quote the x-request-id response header when reporting it.

The model provider failed or was overloaded, or did not return a usable summary; helpingio:usage states any charge (the error envelope).

The request could not be served this instant; retry after the Retry-After header.