Skip to main content
POST
curl
Everything except the trailing keepLastMessages messages is summarized; the summary is returned as a user-role message followed by the kept tail verbatim. Your provider runs the summary, so the provider adds the cost to your account. A conversation too large for the summarizer’s context window is split into chunks that each fit, summarized concurrently, then merged in a reduce pass - so payload size alone does not fail the request. When the conversation still cannot be summarized (it needs more chunks than the server allows, or the chunk summaries will not converge), the response is a 400, not a 500. Two optional controls shape the output. instructions adds caller guidance inside the server-owned prompt frame, so it steers the summary without the model echoing the wording back. targetTokensEstimate sets a desired summary size, translated into word-count guidance. The compaction block reports what happened: compacted is false when the payload passed through untouched (nothing older than the kept tail), alongside chunk/pass counts and the summarizer’s own token usage. Required ACL: search

Authorizations

x-algolia-application-id
string
header
required

Your Algolia application ID.

x-algolia-api-key
string
header
required

Your Algolia API key with the necessary permissions to make the request. Permissions are controlled through access control lists (ACL) and access restrictions. The required ACL to make a request is listed in each endpoint's reference.

Body

application/json

LLM-summarization request.

Your provider runs the summary, so the provider adds the cost to your account.

messages
required
model
string
required

Model name (e.g., gpt-4o-mini).

providerID
string
required

Provider UUID for LLM credentials.

instructions
string

Extra guidance for the summarizer (e.g. 'keep every product reference'). Appended inside the server-owned prompt frame, so it steers the summary without the model echoing your wording back into it.

Maximum string length: 2000
keepLastMessages
integer
default:4

Number of trailing messages kept verbatim; everything older is summarized.

Required range: x >= 0
targetTokensEstimate
integer

Desired size of the final summary, in tokens. Translated into word-count guidance for the summarizer (best-effort, not a hard cap). Omit to let the summarizer default to a concise summary.

Required range: x >= 64

Response

Successful Response.

Result of a context operation, ready to feed to /completions.

messages
required
stats
contextStats · object
required

Before/after accounting for a context operation.

tokens*Estimate fields are heuristic, not an authoritative provider count. messages_dropped is the net reduction in message count (messages_before - messages_after); for compaction the summarized tail is replaced by a single summary message, so this reflects the net change rather than a raw delete count.

compaction
compactionStats · object | null

Compaction-specific telemetry, returned only by /context/compact.

compacted makes the short-conversation passthrough detectable: without it a caller cannot tell a no-op from a summary that happened to be short.

Last modified on October 12, 2026