Documentation · Document AI

Ask the PDF. Questions in, citations out.

Conversational Q&A grounded to a single document. Every answer carries page-level citations and a reasoning trace — if it isn't in the file, the agent says so.

← Back to documentation

Overview

A grounded chat surface over one document at a time.

  • Page-level citations — every claim ties back to one or more pages with character offsets.
  • Multi-turn sessions — the agent keeps context across questions; sessions are tenant-scoped and expire after 24 hours of inactivity.
  • Refusal-by-default — if the answer isn't in the file, the model returns "unknown" with the pages it inspected. No hallucinated facts.
  • Streaming — token-stream the answer with SSE, or wait for the final JSON.

Endpoints

POST /v1/qa/sessions Open a session against a document
POST /v1/qa/sessions/{id}/ask Send a turn
GET /v1/qa/sessions/{id} Replay the transcript
DELETE /v1/qa/sessions/{id} Close & purge

Sessions

Bind a session to one document; reuse it across many turns.

POST /v1/qa/sessions
{
  "source": { "url": "https://files.example.com/msa-acme.pdf" },
  "options": { "ocr": "auto", "locale": "en-US" }
}

// 201 Created
{
  "data": {
    "session_id": "qas_01J9P0X2…",
    "pages":      38,
    "expires_at": "2026-05-20T16:24:00Z"
  }
}

Ask a question

POST /v1/qa/sessions/{id}/ask
curl -X POST https://api.cogneris.ai/v1/qa/sessions/qas_01J9P0X2/ask \
  -H "Authorization: Bearer $COGNERIS_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "question": "What is the termination notice period?",
    "options":  { "max_citations": 3 }
  }'

Response

200 OK
{
  "data": {
    "answer":    "Either party may terminate for convenience with 60 days' written notice.",
    "confidence": 0.96,
    "citations": [
      { "page": 14, "quote": "…with sixty (60) days' written notice to the other party…" },
      { "page": 22, "quote": "Section 12.4 (Termination for Convenience)." }
    ],
    "unknown": false
  },
  "meta": {
    "turn":       3,
    "model":      "flx-qa-2026-04",
    "audit_url":  "https://app.cogneris.ai/audit/qas_01J9P0X2"
  },
  "has_errors": false
}

Streaming

Pass Accept: text/event-stream to receive Server-Sent Events. The stream emits token events for the answer, then a final citation event with the page references, then done. Citations always trail the answer — we never stream a citation we haven't grounded.

Grounding & refusals

  • Grounded by default — the agent retrieves passages, then answers; it does not generate from its own priors.
  • Refusal shape — when the answer isn't in the document, data.unknown is true and data.answer is a one-sentence explanation. citations lists the pages inspected.
  • Don't ask the model to opine — questions like "is this a fair clause?" are out of scope. Use the agent for facts in the file, not legal judgement.

Limits

  • Document size — 1,000 pages per session, 100 MB.
  • Turns — 50 per session, 24 h idle timeout.
  • Rate — 120 questions/min per API key.
  • Pricing — per session + per turn; see pricing.

Errors

CodeMeaning
404Session expired or never existed.
409Document still indexing — retry after the hint.
422Question empty or beyond the session's turn budget.
429Rate-limited; honour Retry-After.

Next: Fraud detection

Per-document fraud score with tampering signals.

Read Fraud detection