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>, Authorization: Bearer <key>, or — for links a browser
opens directly, where no header can be set — ?api_key=<key>. Auth is
fail-closed: router errors when the key list is empty. GET /health is public.
Endpoints (all under auth except / and /health):
| Method | Path | Description |
|---|---|---|
| GET | / | built-in search UI (public; static HTML) |
| GET | /health | liveness probe (public) |
| GET | /api/stats | document / chunk counts |
| GET | /api/documents | all documents with metadata + metrics |
| POST | /api/documents | ?name=file.pdf + enrich flags, raw bytes body → ingest |
| GET | /api/documents/{id} | one document by id |
| GET | /api/documents/{id}/markdown | the parsed Markdown (text/markdown) |
| DELETE | /api/documents/{id} | remove the document and all its chunks |
| GET | /api/search | ?q=…&mode=hybrid&k=5 (also accepts POST) |
| POST | /api/search | {"query", "mode?", "top_k?", "answer?", "extend?"} |
Search modes: vector, bm25, hybrid, multi-query, hyde. With
answer=true the LLM synthesizes a grounded answer (needs OPENROUTER_API_KEY).