Skip to content
Compresr docs

API reference

POST /compress/markdown

Structure-aware compression for markdown input. Preserves headings, lists, and code fences.

POST/api/compress/markdown/API key

Structure-aware compression for markdown input. Preserves headings, lists, and code fences.

REST-only endpoint, not exposed in the Python or TypeScript SDKs. Call it directly over HTTP when you need structural compression of markdown documents.

Keeps headings, list bullets, and code fences intact while shortening prose. Unlike /compress/question-specific/, this endpoint does not take a query; it's structural, not query-conditioned.

Request body

contextstringRequired
The markdown text to compress. Pass null or an empty string to get an empty result with no billing.
compression_model_namestringRequired
Compression model name. Use the markdown model exposed for your account.
target_compression_rationumberOptional
Default: model default
Compression strength. See /docs/api-reference/models.

Response

Response
  • successboolean

    true on success.

  • dataobject
    • original_contextstring

      The input markdown, echoed back.

    • compressed_contextstring

      The compressed markdown, with headings and structural elements preserved.

    • original_tokensinteger
    • compressed_tokensinteger
    • tokens_savedinteger
    • target_compression_rationumber | null
    • actual_compression_rationumber
    • duration_msinteger

Status codes

Status codes
  • 200
    Compression succeeded.
  • 400
    Malformed JSON body.
  • 401
    Missing or invalid X-API-Key.
  • 422
    Field validation failure.
  • 429
    Rate limit hit.
  • 500
    Upstream error.
  • 503
    Upstream error.
Request
python
Response
json