Skip to main content
The context_management parameter asks the provider to compact a long conversation on the server. When the input grows past compact_threshold tokens, the provider summarizes the earlier context and returns it as an encrypted compaction output item.
Compaction is supported for OpenAI models served by OpenAI or Azure. Providers whose requests are translated to another API format, such as Chat Completions or Anthropic Messages, drop the field and return a normal response without a compaction item. Other Responses-compatible providers receive the field as-is, and their behavior isn’t guaranteed.

Enable compaction

Send context_management with a compaction entry:

Response format

When compaction runs, output includes a compaction item before the model’s reply:
Compaction output item

Continue the conversation

The Responses API on OpenRouter is stateless, so send the full history on every turn. Keep the returned compaction item in input in place of the context it replaced, followed in order by the output items that came after it, then append new messages. The provider expands the encrypted summary on the next request.
Next turn input
Only the provider that produced a compaction item can read it. Send follow-up turns to the same OpenAI or Azure endpoint, for example with provider routing.