RAG Query API Server
OpenAPI 3.1 · Base: https://militarymanuals.ai
Endpoints
Admin Get Document
Return full document detail: all chunks + per-page image list. Searches all known collections in parallel for all chunks belonging to doc_id. Requires X-Admin-Key header.
Admin Delete Document
Delete a document from Qdrant, registry.json, and image files. Requires X-Admin-Key header.
Admin List Documents
Return all documents from registry with chunk counts from Qdrant. Requires X-Admin-Key header.
Invalidate Collections Cache
Invalidate the collections metadata cache. Call after updating collection data.
Optional: invalidate only this collection
Invalidate Image Cache
Invalidate the image listing cache. Call after image ingestion.
Invalidate Query Cache
Invalidate the content-addressed query result cache. Call after pipelines F or G upsert data.
Optional: invalidate only this collection's query cache
Get Catalog
Return documents grouped by branch/collection, filtered to only those indexed in Qdrant. Titles, pub_year, category, page_count, and ia_identifier are sourced directly from Qdrant payloads — the same data stored at ingest time from the registry. This ensures the catalog always reflects the authoritative Qdrant state.
Search Collection
Semantic search within a specific collection. Returns matching chunks from all documents in the collection, ranked by vector similarity.
Collection name
Search query
Max results to return
List Collections
List all collections with their metadata (parallel fetch, Ruff-style).
Get Collection
Get info for a single collection.
Get Context
Get chunks from a document. Two modes: - No query param + limit=0: returns sequential chunks centered around chunk_index (window-based). - No query param + limit>0: returns up to `limit` consecutive chunks starting at chunk_index. - With query param: returns semantically ranked chunks matching the query, filtered to this document only (top_k = window param). Args: doc_id: The document ID chunk_index: The center chunk index for sequential mode (0-based) collection: The collection name window: For sequential mode, window size (2*window+1 chunks returned). For semantic mode, top_k limit. query: If provided, triggers semantic search within this document
Document ID
Chunk index (0-based)
Collection name
Window size (returns 2*window+1 chunks, used when limit is not set)
Optional: semantic search query within this document
If > 0, return up to this many consecutive chunks starting at chunk_index (ignores window)
Get Document
Get document metadata from Qdrant payload. Returns document metadata from the first matching point found. Searches across all known collections using Qdrant filters for efficiency. Args: doc_id: The document ID to retrieve metadata for Returns: Dictionary with document metadata fields (title, branch, category, etc.)
List Images For Page
List images for a specific page of a document. Args: doc_id: The document ID page_num: The page number to list images for Returns: Dictionary with 'images' list containing image filenames for that page
Api Manifest
Return machine-readable API manifest auto-generated from FastAPI routes. No manual maintenance — every route registered with the app appears here.
Get Openapi Json
Return OpenAPI 3.1 specification auto-generated from FastAPI routes. This is a proxy to FastAPI's built-in openapi schema — no manual maintenance required. Every route registered with the app automatically appears here.
Poll Kurier Status
Poll Kurier job status — no auth required. This is a thin proxy to poll_zkverify_job that bypasses nginx's auth layer so browsers can poll without an API key.
Prove Chunk
Generate a ZK proof for a specific chunk identified by doc_id and chunk_id. Takes a doc_id + chunk_id + collection, fetches the chunk from Qdrant, generates a ZK proof for it, and returns the chunk payload plus proof fields. Used by the website's next/previous chunk navigation with provenance.
Get Proof Status
Poll Kurier job status for a proof verification job. Returns current status and, if complete, the verification result.
Submit Proof
Submit a ZK proof to Kurier/zkVerify for on-chain verification. Accepts proof data directly (no server-side cache required). Returns job_id immediately for polling.
Query
Vector search endpoint using Qdrant similarity search. Accepts a natural language query and returns relevant document chunks from Qdrant using vector similarity search. Supports single collection search or cross-collection search with collection='*'. Args: request: QueryRequest with query text, top_k, and collection Returns: QueryResponse with matching chunks, query, collection, and total count
Query Provable
Vector search with ZK proofs attached to every result chunk. Flow: 1. Query Qdrant (vector similarity) 2. Generate ZK proofs in parallel for all result chunks 3. Return only chunks that have successfully generated proofs No chunk text is returned for a chunk unless its ZK proof exists. Proof generation runs in parallel, capped by ZK_PROOF_PARALLELISM env var (default 2, set to 4 on the R730, 2 on the VPS). Args: request: QueryProvanableRequest with query text, top_k, and collection Returns: QueryProvanableResponse with chunks (each with zk_proof attached), plus a proofs dict keyed by chunk_id.
Get Source Pdf
Stream the source PDF for a document, requiring X402 payment proof. Without a Payment-Signature header: returns 402 with PAYMENT-REQUIRED. With a valid EIP-3009 PaymentPayload: streams the PDF file.
Get Source Info
Return document metadata and price for paid PDF download.
Health
Health check endpoint — verifies Qdrant and embedding service.