Documentation Index
Fetch the complete documentation index at: https://docs.knowledgestack.ai/llms.txt
Use this file to discover all available pages before exploring further.
Install
npm install @knowledge-stack/ksapi
Works in Node.js ≥ 18, Bun, Deno, Cloudflare Workers, and modern browsers.
Authenticate
Issue an API key
From the dashboard, create an API key scoped to your user. It looks like sk-user-....
Add it to .env
KS_API_KEY=sk-user-...
KS_BASE_URL=https://api.knowledgestack.ai # optional
First call
import { Configuration, FoldersApi } from "@knowledge-stack/ksapi";
const config = new Configuration({
basePath: process.env.KS_BASE_URL ?? "https://api.knowledgestack.ai",
accessToken: process.env.KS_API_KEY,
});
const folders = new FoldersApi(config);
const { data } = await folders.listFolders();
console.log(data);
Read a document
import { DocumentsApi, PathPartsApi } from "@knowledge-stack/ksapi";
const pathParts = new PathPartsApi(config);
const documents = new DocumentsApi(config);
const hits = await pathParts.findPathParts({ query: "credit policy" });
const docId = hits.data[0].pathPartId;
const doc = await documents.readDocument({ pathPartId: docId });
console.log(doc.data);
Per-request auth (multi-tenant proxies)
await folders.listFolders({}, {
headers: { Authorization: `Bearer ${perRequestKey}` },
});
Building an agent?
For agent / RAG workflows, use the MCP server instead. It plugs into every major agent framework without writing glue code.
Reference
The full auto-generated API reference lives in the ks-sdk-ts repo. It’s also mirrored under sdks/_generated-ts/ in this docs repo, refreshed nightly.