---
title: "Compact response context (OpenAI Responses API)"
method: POST
path: "/v1/responses/compact"
tags: ["Responses"]
---

# Compact response context (OpenAI Responses API)

`POST /v1/responses/compact`

## Request

- Base URL: `https://api.tokenlab.sh`
- URL: `https://api.tokenlab.sh/v1/responses/compact`
- Auth: HTTP bearer

Compacts Responses input and returns the native `response.compaction` contract. The request model must be available on a same-protocol Responses path.

## Headers

- `X-TokenLab-Delivery-Policy` 'auto' | 'verified' | 'official'

## Request body

- object
  - `model` string, required: Model to use for compaction. Codex CLI sends the current session model.
  - `input` string, required: Conversation input to compact.
  - `max_output_tokens` integer: Maximum output tokens.
  - `stream` boolean: Streaming is not supported for compaction.
  - `metadata` object: Request metadata.

## Response `200`

Successful compaction response

## Other responses

- `400`: Bad Request - Invalid input
- `401`: Unauthorized - Invalid or missing API key
- `402`: Payment Required - Insufficient balance or quota exceeded
- `503`: The requested Delivery tier is temporarily unavailable.

---

[API](https://skmtc.dev/tokenlab/apis/tokenlab-ai-gateway.md) · [All operations](https://skmtc.dev/tokenlab/apis/tokenlab-ai-gateway/llms.txt) · [OpenAPI document](https://skmtc.dev/tokenlab/apis/tokenlab-ai-gateway/revisions/3208bfbcda22?raw)
