API reference
POST /compress/question-specific/stream
Server-Sent Events variant of the question-specific compression endpoint.
/api/compress/question-specific/streamAPI keyServer-Sent Events variant of the question-specific compression endpoint.
Same input as POST /compress/question-specific/, but the response is a Server-Sent Events stream instead of a JSON envelope. When to use it (and why plain compress usually wins today): streaming guide.
Request body
Identical to the non-streaming endpoint. latte_v2 accepts every parameter latte_v1 accepts, plus the three latte_v2-only dynamic* knobs (rejected on latte_v1 with 422).
Shared parameters (both models)
contextstringRequiredquerystringRequiredcompression_model_name"latte_v1" | "latte_v2"Requiredtarget_compression_rationumberOptionalmodel defaultcoarsebooleanOptionaltrueheuristic_chunkingbooleanOptionalfalsedisable_placeholdersbooleanOptionalfalse[...] markers between kept spans.latte_v2-only parameters
dynamicbooleanOptionalfalsetarget_compression_ratio when true. Rejected on latte_v1 with 422.dynamic_min_rationumberOptionalmodel defaultdynamic=true. Must be ≥ 1.0.dynamic_max_rationumberOptionalmodel defaultdynamic=true. Must be ≥ 1.0.Response
The response uses Content-Type: text/event-stream. Each event is a data: <json> frame. On success the server emits one content event carrying the full compressed output, then closes the stream:
If compression fails or times out (120s server-side budget) after the stream has opened, the server emits an error event instead, then closes:
contentstringCompressed text. Currently the full output arrives in a single event; concatenate content across events to stay forward-compatible with incremental chunks.
donebooleantrue on the final content event. The stream closes after it.
errorstringPresent instead of content when the stream aborts mid-flight. The stream closes after it.
Status codes
200Stream opened. Body isOKtext/event-stream.401Missing or invalidUnauthorizedX-API-Key.422Field validation failure.Unprocessable Entity429Rate limit hit.Too Many Requests500Upstream error. Stream may include anInternal Server Errorerrorchunk before closing.503Upstream error. Stream may include anService Unavailableerrorchunk before closing.
The streaming endpoint returns events, not the standard response envelope, and it never returns the token-accounting metadata (original_tokens, compressed_tokens, tokens_saved, actual_compression_ratio, duration_ms). If you need those, use the non-streaming endpoint. Once the stream is open, failures arrive as an error event rather than an HTTP status. The SDK iterators skip that event, so an empty result is the only signal; the examples below treat it as a failure. Full handling, including retries, is in the streaming guide.