DOCS
Dashboardnorth_eastGet an API keyvpn_key
PAI Chat·Knowledge base

Knowledge base (RAG)

Give a chatbot its own knowledge by uploading documents. The platform extracts, chunks, and embeds them into a vector index, then retrieves the most relevant passages at answer time — Retrieval Augmented Generation. Answers stay grounded in your content instead of the base model alone.

Uploading documents

POST a file as multipart/form-data to a chatbot. Supported types: PDF, Excel, Word, CSV, and text, up to 50 MB each. Document management is an admin operation — use an organization key and target the chatbot.

cURL
curl https://chat-api-dev.paicloud.ai//chatbot/CHATBOT_ID/document \
  -H "x-api-key: $PAI_CHAT_API_KEY" \
  -H "x-organization-id: YOUR_ORG_ID" \
  -F "file=@handbook.pdf"

The response returns the document id and its processing status:

201 response
{
  "documentId": "…",
  "filename": "handbook.pdf",
  "fileSize": 248193,
  "status": "processing",
  "message": "Document uploaded"
}

Processing status

A document is not retrievable until it reaches ready. Embedding runs asynchronously after upload.

StatusMeaning
uploadingThe file is being received.
processingText is being extracted, chunked, and embedded.
readyThe document is indexed and retrievable during chat.
failedProcessing stopped — re-upload or check the file.

Folders

Group documents into folders to keep a chatbot's sources organised. Folders are a management convenience — retrieval searches across the chatbot's indexed content regardless of folder.

How retrieval feeds answers

At answer time, the user's message is embedded and matched against the chatbot's document vectors using pgvector semantic search. The top passages are injected into the model prompt as context, so the reply cites your material rather than guessing. More relevant, well- chunked documents produce better grounding.

lightbulb
Prefer clean, text-rich sources. Scanned image-only PDFs embed poorly — supply text-based documents where possible. You can also grow the knowledge base by crawling a website.

See Chatbots & organisations for key scoping and Error codes for upload failures.