API reference
Complete specification for the RAGDC REST API.
Base URL
All API requests are made to https://ragdc.aivault.asia/api/v1. Every endpoint is POST, JSON over HTTPS.
Authentication
Include your API key in the Authorization header of every request.
Authorization: Bearer sk_...Keys are created in the dashboard under API Keys. Revoked keys stop working immediately.
Conventions
- Every response uses the envelope { "code", "message", "data" } — code 200 means success, non-zero is an error.
- Each API key is rate-limited to 120 requests per minute.
- Document ingestion is asynchronous: upload returns status "queued"; poll doc/list until status is "ready" (queued → processing → ready, or failed).
- A key only reaches knowledge bases owned by its tenant, each stored in an isolated collection. /retrieve is free; /ask and chat consume credits.
Endpoints
All endpoints are POST and require the Authorization header above.
Retrieval
Retrieval-as-a-service: return the relevant chunks with sources, no LLM answer.
/api/v1/retrieveHybrid retrieval + rerank, returns ranked chunks. Body: knowledgeBaseId, query, topK, mode (quality | fast).
Q&A
Grounded answers from a knowledge base, with citations and token usage.
/api/v1/askOne-shot RAG answer — retrieve + LLM answer + sources, no conversation needed. Body: knowledgeBaseId, question, model (optional).
/api/v1/chat/conversations/createCreate a persistent conversation bound to a knowledge base.
/api/v1/chat/messages/sendSend a message in a conversation and get a RAG answer with citations.
/api/v1/chat/messages/listList the messages of a conversation.
Knowledge bases
Create and manage the knowledge bases that scope retrieval — one per isolation unit.
/api/v1/kb/createCreate a knowledge base. Body: name, description (optional).
/api/v1/kb/listList the tenant's knowledge bases.
/api/v1/kb/detailGet one knowledge base by id.
/api/v1/kb/updateRename or update a knowledge base. Body: id, name, description.
/api/v1/kb/deleteDelete a knowledge base (soft delete + vector cleanup). Body: id.
Documents
Upload files into a knowledge base and track ingestion. Ingestion is asynchronous.
/api/v1/doc/uploadUpload a file (multipart/form-data). Fields: knowledgeBaseId, file. Returns a document with status "queued".
/api/v1/doc/listList documents in a knowledge base with their ingestion status.
/api/v1/doc/detailGet one document by id, including status and chunk count.
/api/v1/doc/deleteDelete a document and its vectors.
Examples
The two most common calls for an external integration, plus async upload.
POST /api/v1/retrieve
Authorization: Bearer sk_xxx
Content-Type: application/json
{
"knowledgeBaseId": "kb-uuid",
"query": "投标资质要求",
"topK": 8,
"mode": "fast" // fast = 跳过 rerank,~一瞬;quality = 带精排,~8s
}
→ {
"code": 200,
"data": {
"chunks": [
{ "text": "...", "source": "spec.pdf", "page": 1,
"score": 0.83, "kbId": "kb-uuid", "documentId": "doc-uuid" }
],
"count": 8,
"usage": { "retrievalMs": 11 }
}
}POST /api/v1/ask
Authorization: Bearer sk_xxx
Content-Type: application/json
{
"knowledgeBaseId": "kb-uuid",
"question": "本项目对投标人的资质有什么要求?",
"model": "claude-sonnet-4-6" // 可选,留空走默认模型
}
→ {
"code": 200,
"data": {
"answer": "...", // 基于知识库的成稿回答
"sources": [ { "source": "spec.pdf", "documentId": "doc-uuid" } ],
"model": "claude-sonnet-4-6",
"usage": { "tokensInput": 772, "tokensOutput": 85 }
}
}POST /api/v1/doc/upload
Authorization: Bearer sk_xxx
Content-Type: multipart/form-data
knowledgeBaseId = kb-uuid
file = @contract.pdf
→ { "code": 200, "data": { "id": "doc-uuid", "status": "queued" } }
# 入库是异步的,轮询 /api/v1/doc/list 直到 status = "ready"
# queued → processing → ready (失败为 failed)