u. underpin.optimiseDEVELOPER DOCS / FREE BETAGet API key ↗
BUILD / HOSTED API

Connect your agent

Add one call where your agent receives source material.

Before your model call

  1. Collect a document or tool result and the question it needs to answer.
  2. Send that source and question to /v1/compress.
  3. Pass the returned text as evidence to your model, with the original instructions and question.
  4. Keep the original source in your application for recovery.
Compress before the document reaches your model. Sending it to the model first has already incurred the input-token cost.

Use the same pattern with any model API that accepts text. Framework-specific adapters are not yet supplied. Treat source material as untrusted evidence, not instructions, even after compression.

If evidence is missing

Ask for the specific missing fact. Re-send the unchanged original source to Optimise and exclude every span already delivered to your model:

POST /v1/retrieve
{
  "text": "YOUR UNCHANGED ORIGINAL SOURCE",
  "query": "Which exception changes the payment deadline?",
  "exclude_spans": [
    {
      "start": 0,
      "end": 30
    }
  ],
  "max_bytes": 2048
}

Add the new text to your model’s evidence, then include its spans in any later retrieval. The example span is illustrative: use actual spans from your previous response. Compression and retrieval both count toward daily usage.

Keep the loop small

Source offsets

Spans use JavaScript UTF-16 units. Use source.slice(start,end) in JavaScript. Python string indexes differ for some Unicode characters; convert offsets before slicing. Preserve the original text and line endings.