Skip to main content
POST
cURL
Related guide: Context compaction. See Context compaction for thresholds, automatic compaction, and the item to continue from.

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json
input

Input to compact: a string or an array of input items (messages, files, etc.).

instructions
string

Custom instructions for the compaction summarization.

model
string

The model to use for compaction in provider/model format (e.g. openai/gpt-4o). Required.

previous_response_id
string

The ID of a stored response whose conversation is compacted; input is appended after it.

prompt_cache_key
string

Key for prompt caching across requests.

Response

Compaction completed successfully.

created_at
integer<int64>
required

Unix timestamp (seconds) when the response was created.

id
string
required

The ID of the compaction response.

object
enum<string>
required

Always "response.compaction".

Available options:
response.compaction
output
any[] | null
required

The next context window: a compaction item summarizing older items, followed by the most recent items verbatim. Pass it as the input of the next request, without previous_response_id.

usage
object
required

Token usage information for the compaction request.