v4

latestOpenAPI 3.1.02026-08-0143190206.8 KB
v1

Compacts a full Responses API input window into a shorter canonical window.

The client sends its current input (the same items that would be passed to POST /v1/responses) and receives a compacted output window. The output should be used verbatim as the input of the next /v1/responses call (appending only the new user turn).

This generalizes the compaction approach used by the coding-agent harness (generate_session_compact in xai-grok-shell):

  1. Strip tool-result noise from the history.
  2. Ask the model to produce a structured <summary> of the conversation.
  3. Rebuild a compact window: system message → summary → last user query.
  4. Return that window to the client.
post/v1/responses/compact

Request body

modelstring required

Model to use for compaction summarization (required).

Response

Success – compacted window returned.

created_atinteger required

Unix timestamp (in seconds) when the compacted conversation was created.

idstring required

Unique ID for this compaction (e.g. cmp_<uuid>).

modelstring required

Model used for the compaction summary.

objectstring required

Always "response.compaction".