Compact a response conversation

Use the OpenAI Responses API to compact a long conversation.

POST /v1/responses/compact

Service root: https://getrouter.ai

Protocol: OpenAI Responses

Authentication: Authorization: Bearer YOUR_API_KEY

Request body

The request body is required. Media type: application/json

Request fields

FieldTypeRequiredDescription
modelstringYes
inputstring or array<object>NoInput content, either a string or an array of messages
instructionsstringNo
previous_response_idstringNo

Example request

curl --request POST \
  --url https://getrouter.ai/v1/responses/compact \
  --header "Authorization: Bearer YOUR_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{
  "model": "MODEL_ID"
}'

Responses

StatusDescription
200Conversation compacted successfully

Success response fields

FieldTypeRequiredDescription
idstringNo
objectstringNo
created_atintegerNo
outputarray<object>No
usageobjectNo
errorobjectNo

Example response

{
  "id": "string",
  "object": "object",
  "created_at": 1,
  "output": [
    {}
  ],
  "usage": {
    "prompt_tokens": 1,
    "completion_tokens": 1,
    "total_tokens": 1,
    "prompt_tokens_details": {
      "cached_tokens": 1,
      "text_tokens": 1,
      "audio_tokens": 1,
      "image_tokens": 1
    },
    "completion_tokens_details": {
      "text_tokens": 1,
      "audio_tokens": 1,
      "reasoning_tokens": 1
    }
  },
  "error": {}
}

For complete workflows and examples, read the Responses API Guide.


This page is generated from the public Relay OpenAPI specification. Browse the complete specification in the API Explorer.