KAI RAG API
Hybrid-retrieval RAG over your indexed documents. Answers include bracketed citations, per-claim verification verdicts, and a composite confidence score. Requests are scoped to a workspace by the `kai_guest_id` cookie.
Authenticate with an x-api-key header, or configure a server-side GOOGLE_API_KEY. Requests are scoped to the workspace in the kai_guest_id cookie.
/api/v1/askAsk a grounded question
Retrieves evidence, generates a cited answer, verifies each citation, and returns a confidence breakdown. Declines to answer when retrieval confidence falls below `abstainThreshold`.
- 200 Answer with citations and confidence
- 400 No indexed documents or invalid request
- 401 Missing or rejected API key
- 429 Rate limited
/api/v1/ingestIndex a document
Accepts multipart form data with a `file` field, or JSON with `filename` and `content` for text formats. Near-duplicate chunks are skipped unless `dedupe` is false.
- 201 Indexed
- 400 Unsupported file type or malformed body
- 413 File too large
/api/v1/documentsList indexed documents
- 200 Documents in this workspace
/api/documents/{id}/reindexRe-chunk a document with another strategy
- 200 Re-indexed
- 404 Document not found
- 409 No stored text or file to re-index
/api/retrieval/compareCompare hybrid, dense, and sparse retrieval
Runs one question through each retrieval mode and reports ranked passages, per-mode stats, and pairwise overlap. No generation.
- 200 Per-mode retrieval results
/api/healthDatabase and vector store health
- 200 Component status
/api/chatStreaming chat (newline-delimited JSON)
Same pipeline as /api/v1/ask, streamed as NDJSON. Event types arrive in order: meta (chat id, sources, retrieval stats), repeated delta (answer text), verification (per-claim verdicts), confidence (composite score), then done. Errors arrive as error.