Repository navigation
API Reference
The server runs with --api, listens on 127.0.0.1:8000, and needs at least one environment-backed tenant bearer key. API docs are also available locally at /docs and /openapi.json if the server is running.
| Method | Route | Authentication | Summary |
|---|---|---|---|
GET |
/health |
None | Returns {"status":"ok"} only |
POST |
/v1/query |
Tenant bearer token | Tenant-filtered excerpt retrieval |
GET |
/v1/cache/stats |
Tenant bearer token | Entries in requesting tenant's cache scope |
GET |
/v1/metrics |
Admin bearer token, only if RAG_ADMIN_API_KEY is set
|
Overall in-memory monitor report |
/v1/query uses SlowAPI 60/minute per remote IP, not per-tenant accounting. The other routes do not have an explicit decorator-based limit in the uploaded code.
{
"query": "What are the Pro API rate limits?",
"session_id": "demo-session-1",
"top_k": 3,
"max_tokens": 300
}| Field | Required? | Validation |
|---|---|---|
query |
yes | Nonempty, max 4000 chars |
session_id |
no | String or null, max 128 chars |
top_k |
no | Integer 1–20, default 3 |
max_tokens |
no | Integer 1–2048, default 300; currently unused |
tenant_id must not be provided in the request body. The backend derives it from the API key.
In one terminal run --api with the tenant's private key. In another terminal, securely supply the same value, then:
$headers = @{ Authorization = "Bearer $env:TENANT_A_API_KEY" }
$payload = @{
query = 'What are the API rate limits on Pro?'
session_id = 'demo-session-1'
top_k = 3
} | ConvertTo-Json
Invoke-RestMethod -Uri 'http://127.0.0.1:8000/v1/query' -Method Post `
-Headers $headers -ContentType 'application/json' -Body $payloadPrivacy: The response's
queryfield echoes the original question verbatim, even after internal query PII redaction. Do not send personal data to this demo and do not expose the API publicly without a security review.
- Missing bearer token: rejected by FastAPI
HTTPBearer. - Wrong token:
401withInvalid API key. - Invalid body fields: FastAPI/Pydantic request-validation error (typically
422). - Rate limit exceeded:
429from SlowAPI. - No tenant keys configured at app construction: process raises
RuntimeErrorbefore serving.
No API endpoint for document ingestion, deletion, tenant provisioning or generated answers exists in this code.
Project scope: tenant-filtered extractive retrieval demo. Review Security and Limitations before deployment. This project is licensed under the Apache License, Version 2.0.© 2026 Sudhanshu Shukla · Licensed under the Apache License, Version 2.0.
RAG Service Wiki
Architecture and design
Development and operations
Engineering guidance