Skip to main content

Module api

Module api 

Source
Expand description

REST API over a Pipeline: document info and search in every retrieval mode.

Authentication is a static API-key list from config (RAG_API_KEYS), accepted as X-Api-Key: <key> or Authorization: Bearer <key>. Auth is fail-closed: router errors when the key list is empty. GET /health is public.

Endpoints (all under auth except /health):

MethodPathDescription
GET/healthliveness probe (public)
GET/api/statsdocument / chunk counts
GET/api/documentsall documents with metadata + metrics
GET/api/documents/{id}one document by id
GET/api/search?q=…&mode=hybrid&k=5 (also accepts POST)
POST/api/search{"query", "mode?", "top_k?", "answer?"}

Search modes: vector, bm25, hybrid, multi-query, hyde. With answer=true the LLM synthesizes a grounded answer (needs OPENROUTER_API_KEY).

Functions§

router
Build the router. Errors if keys is empty (auth is fail-closed).
serve
Bind addr and serve until the process is stopped.