Skip to content
Compresr docs

API reference

POST /compress/question-specific

Compress context while preserving tokens relevant to a query. The primary Compresr endpoint.

POST/api/compress/question-specific/API key

Compress 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

contextstringRequired
The text to compress. Pass null or an empty string to get an empty result back with no billing.
querystringRequired
The question or topic to preserve relevance for. Cannot be empty.
compression_model_name"latte_v1"Required
Compression model name. Currently only latte_v1 is exposed publicly.
target_compression_rationumberOptional
Default: see Models
Compression strength. See /docs/api-reference/models for the canonical value semantics.
coarsebooleanOptional
Default: true
Paragraph-level compression. Faster and cheaper, less precise than token-level.
heuristic_chunkingbooleanOptional
Default: false
Pre-chunk the context with structure-aware heuristics before compression.
disable_placeholdersbooleanOptional
Default: false
Strip placeholder tokens from the compressed output.

Response

Response
  • successboolean

    true on success.

  • dataobject
    • original_contextstring

      The input context, echoed back.

    • compressed_contextstring

      The compressed output you forward to your LLM.

    • original_tokensinteger

      Token count of the input context.

    • compressed_tokensinteger

      Token count after compression.

    • tokens_savedinteger

      original_tokens − compressed_tokens.

    • target_compression_rationumber | null

      The ratio you requested, if any.

    • actual_compression_rationumber

      The ratio actually achieved (0 to 1).

    • duration_msinteger

      Server-side processing time in milliseconds.

Status codes

Status codes
  • 200
    Compression succeeded.
  • 400
    Malformed JSON body.
  • 401
    Missing or invalid X-API-Key.
  • 422
    A field failed validation (e.g. empty query, target_compression_ratio > 200).
  • 429
    Rate limit hit for your tier.
  • 500
    Upstream compression service error.
  • 503
    Upstream compression service error.
Request
python
Response
json