Compact a conversation

Shrink a long stored conversation, so later turns fit the context window and use fewer tokens.

POST/responses/compact

Shrink a long stored conversation, so later turns fit the context window and use fewer tokens.

Send the previous_response_id of a stored response. Your user messages are kept word for word. Everything else, meaning Olive's replies and any tool or file results, is replaced by a summary. The compacted response is stored. Continue from it by passing its id as previous_response_id on the next POST /responses.

The summary is written for clinical use. It keeps each dose in full, each warning sign with its threshold, allergies and how sure you were of them, who the questions are about, instructions you gave quoted exactly, and what is still pending. It is told not to add facts and to leave out names, ID numbers and contact details. A model still writes it, so check it before you rely on it for dosing or allergies.

The summary is capped at 4096 tokens, and max_output_tokens does not change that. Compaction is billed as one model call.

Authorization

BearerAuth
AuthorizationBearer <token>

Your Avey API key, sent as Authorization: Bearer <key>. This is the header the OpenAI SDKs already send, so pass the key as the client's ordinary api_key and no further configuration is needed.

In: header

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

The body of a compaction request.

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

application/json

application/json

curl https://api.avey.ai/llm/responses/compact \  -H "Authorization: Bearer $AVEY_API_KEY" \  -H "Content-Type: application/json" \  -d '{    "model": "olive",    "previous_response_id": "resp_5c7a2e1f8b3d4a609e1c7f2b4d8a6e30"  }'
{  "id": "resp_8e3f1a2b4c5d4e6f9a0b1c2d3e4f5a6b",  "object": "response.compaction",  "created_at": 1769904000,  "output": [    {      "type": "message",      "role": "user",      "content": [        {          "type": "input_text",          "text": "What are the follow-up arrangements after discharge?"        }      ]    },    {      "type": "compaction",      "id": "cmp_2b7d9e4a1c3f4a58b6e0d1c9f7a3e512",      "encrypted_content": "Summary of the earlier conversation."    }  ],  "usage": {    "input_tokens": 2104,    "output_tokens": 312,    "total_tokens": 2416  }}