API reference
POST /compress/question-specific
Compress context while preserving tokens relevant to a query. The primary Compresr endpoint.
/api/compress/question-specific/API keyCompress context while preserving tokens relevant to a query.
Supply a long context and a query; the model keeps the parts of the context that matter for that query and drops the rest. This is the headline Compresr endpoint.
Request body
latte_v2 accepts every parameter latte_v1 accepts, plus three latte_v2-only knobs for dynamic compression-ratio selection. The shared parameters apply identically on both models; the latte_v2-only knobs are rejected with 422 if sent to latte_v1. See Models for the canonical reference and decision guide.
Shared parameters (both models)
contextstringRequiredquerystringRequiredcompression_model_name"latte_v1" | "latte_v2"Requiredlatte_v2 is the recommended default; pick latte_v1 when you need the older backbone explicitly. See Models.target_compression_rationumberOptionalmodel default0 < r ≤ 1, Nx target when r > 1. See Models › target_compression_ratio. Ignored on latte_v2 when dynamic=true.coarsebooleanOptionaltrueheuristic_chunkingbooleanOptionalfalsedisable_placeholdersbooleanOptionalfalse[...] markers the model normally inserts between kept spans.latte_v2-only parameters
dynamicbooleanOptionalfalse[dynamic_min_ratio, dynamic_max_ratio]. Overrides target_compression_ratio when true. Rejected on latte_v1 with 422.dynamic_min_rationumberOptional1.5dynamic=true. Must be ≥ 1.0. Only consulted when dynamic=true.dynamic_max_rationumberOptional10.0dynamic=true. Must be ≥ 1.0 and ≥ dynamic_min_ratio. Only consulted when dynamic=true.Response
successbooleantrue on success.
dataobjectoriginal_contextstringThe input context, echoed back.
compressed_contextstringThe compressed output you forward to your LLM.
original_tokensintegerToken count of the input context.
compressed_tokensintegerToken count after compression.
tokens_savedintegeroriginal_tokens − compressed_tokens.
target_compression_rationumber | nullThe ratio you requested, if any.
actual_compression_rationumberThe ratio actually achieved (0 to 1).
duration_msintegerServer-side processing time in milliseconds.
Status codes
200Compression succeeded.OK400Malformed JSON body.Bad Request401Missing or invalidUnauthorizedX-API-Key.422A field failed validation (e.g. emptyUnprocessable Entityquery,target_compression_ratio > 200).429Rate limit hit for your tier.Too Many Requests500Upstream compression service error.Internal Server Error503Upstream compression service error.Service Unavailable