Intelligence / grounded answers
P1 · Intelligence
RAG
Answer questions from your own documents. Ingestion, retrieval, and generation are one building block.
A knowledge base ties an embedding model, a chunk size, and a retrieval default together. Asking a question returns an answer plus the passages it used.
Paths in the tables are relative to https://api.ultrahost.com/v1/projects/{projectId}. Pagination, idempotency, and errors are described in Conventions.
Create
| SDK | REST | Description |
|---|---|---|
rag.createKnowledgeBase(name, config) | POST /rag/knowledge-bases | Create a knowledge base |
rag.getKnowledgeBase(name) | GET /rag/knowledge-bases/{name} | Retrieve configuration |
rag.listKnowledgeBases() | GET /rag/knowledge-bases | List knowledge bases |
rag.updateKnowledgeBase(name, config) | PATCH /rag/knowledge-bases/{name} | Update configuration |
rag.deleteKnowledgeBase(name) | DELETE /rag/knowledge-bases/{name} | Delete a knowledge base |
await ultrahost.rag.createKnowledgeBase("company-docs", {
embeddingModel: "default",
chunkSize: 1000,
retrieval: { topK: 5 }
});RAG uses the LLM Plane for generation and the Vector DB model of embeddings. Callers still talk to ultrahost.rag. They do not stitch those services together themselves.
Configure
embeddingModel, chunkSize, and retrieval.topK are the knowledge-base settings. Changing chunk size or the embedding model implies a reindex. rag.reindex(name) rebuilds the knowledge index and returns an operation when the work is not immediate.
Generation still goes through a capability with a budget. A knowledge base should name that capability rather than let each ask pick a provider model. Wire the capability with LLM Plane configuration.
Use
| SDK | REST | Description |
|---|---|---|
rag.addDocument(name, document) | POST /rag/{name}/documents | Add a document |
rag.addDocuments(name, documents) | POST /rag/{name}/documents/batch | Add many documents |
rag.removeDocument(name, id) | DELETE /rag/{name}/documents/{id} | Remove a document |
rag.listDocuments(name) | GET /rag/{name}/documents | List indexed documents |
rag.reindex(name) | POST /rag/{name}/reindex | Rebuild the index |
rag.retrieve(name, query) | POST /rag/{name}/retrieve | Relevant passages, no generation |
rag.ask(name, question) | POST /rag/{name}/ask | A grounded answer |
rag.stream(name, question) | POST /rag/{name}/ask/stream | Stream a grounded answer |
const answer = await ultrahost.rag.ask("company-docs", {
question: "What is our refund policy?",
includeSources: true
});Responses include source references, retrieval scores where they are meaningful, and usage metadata. retrieve is the escape hatch when the application wants passages without a generated answer.
useRAG(knowledgeBase) is the React hook. Streaming uses rag.stream.