Ultrahost/ docs

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

SDKRESTDescription
rag.createKnowledgeBase(name, config)POST /rag/knowledge-basesCreate a knowledge base
rag.getKnowledgeBase(name)GET /rag/knowledge-bases/{name}Retrieve configuration
rag.listKnowledgeBases()GET /rag/knowledge-basesList 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
ts
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

SDKRESTDescription
rag.addDocument(name, document)POST /rag/{name}/documentsAdd a document
rag.addDocuments(name, documents)POST /rag/{name}/documents/batchAdd many documents
rag.removeDocument(name, id)DELETE /rag/{name}/documents/{id}Remove a document
rag.listDocuments(name)GET /rag/{name}/documentsList indexed documents
rag.reindex(name)POST /rag/{name}/reindexRebuild the index
rag.retrieve(name, query)POST /rag/{name}/retrieveRelevant passages, no generation
rag.ask(name, question)POST /rag/{name}/askA grounded answer
rag.stream(name, question)POST /rag/{name}/ask/streamStream a grounded answer
ts
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.