Agent API Reference
External agents can query knowledge bases via these endpoints. All endpoints return JSON.
List Knowledge Bases
GET/api/agent/kb
Query (RAG or Search)
POST/api/agent/query
Form parameters:
kb_id (required) — Knowledge base ID
query (required) — Your question
top_k (optional, default 5) — Number of chunks to retrieve
mode (optional, default "rag") — "rag" for full answer, "search" for raw results
Example: curl
curl -X POST http://localhost:8000/api/agent/query \
-F "kb_id=YOUR_KB_ID" \
-F "query=What is the company policy?" \
-F "mode=rag"
Example: Python
import requests
resp = requests.post("http://localhost:8000/api/agent/query", data={
"kb_id": "YOUR_KB_ID",
"query": "What is the company policy?",
"mode": "rag"
})
print(resp.json())
# {"answer": "...", "sources": [...], "chunks_used": 5}
All Endpoints
GET/api/kb — List knowledge bases
POST/api/kb — Create knowledge base (JSON: name, description)
DELETE/api/kb/{id} — Delete knowledge base
POST/api/kb/{id}/documents — Upload document (multipart)
GET/api/kb/{id}/documents — List documents
DELETE/api/documents/{id} — Delete document
POST/api/kb/{id}/query — RAG query (JSON: query, top_k)
POST/api/kb/{id}/search — Vector search (JSON: query, top_k)