Knowledge bases

Knowledge bases are how you stop your agent from making things up. Upload your sources, attach the KB to an agent, and every response is anchored to retrieved passages, with optional inline citations and a strict mode that refuses to answer outside the corpus.

Ingest formats

  • PDF, text + table extraction (we OCR scanned pages).
  • HTML, a single page or a crawl from a sitemap URL.
  • Markdown, preserves headings as chunk anchors.
  • JSON, when each row is its own document (FAQ, product catalogue).
  • Direct text, for pasted content under 1MB.
upload.ts
const kb = await saaya.knowledgeBases.create({
  name: "Saaya, public docs",
  embedModel: "text-embedding-3-large",
});

await saaya.knowledgeBases.upload(kb.id, {
  source: { type: "sitemap", url: "https://saaya.ai/sitemap.xml" },
  chunking: { strategy: "semantic", maxTokens: 480, overlap: 40 },
});

Chunking

Saaya defaults to semantic chunking, paragraphs split on headings and natural breaks, then merged up to a target token budget. For tabular sources we treat each row as a chunk. You can override the strategy per upload if your corpus has a strong native shape (FAQs, transcripts, code).

Citations

Attach the KB to an agent and answers come back with `[1]`-style footnotes. Each citation includes the source url, the document title, and the chunk-level passage we retrieved. On voice we read out a short version ("according to your refunds policy"); on chat / WhatsApp we render the link inline.

Strict citation mode

Turn on `strict: true` to forbid uncited claims. The agent will refuse to answer when retrieval confidence is below threshold and offer to escalate. This is the right default for support, healthcare, and regulated finance use cases, and it is what you want behind every "ask anything about our docs" surface.

Vector storage

KBs are stored as Qdrant collections prefixed `kb_`. Vectors stay in your selected residency region (EU, India, or US). We never ship raw content to model providers, only the retrieved passages at query time.
Was this page helpful?