@kelu/sdk lets any JavaScript app ask your knowledge base questions and get streamed answers with citations. Use it in browsers and React Native with a public key, or in Node.js 18 or later with a secret key pair.
@kelu/sdk is not on npm yet, so npm install @kelu/sdk fails today. Until it is published, embed the website widget or call the REST API directly.

Set up

1

Create a client key

Open the knowledge base, go to Integrations, and under Client Keys click Create key. Choose Public key for code that runs in a browser or app. Choose Secret pair for a server: you get a client ID (kl_ci_…) and a secret (kl_cs_…). Copy the secret now; it is shown only once.
2

Create the client

import { Kelu } from "@kelu/sdk";

const kelu = new Kelu({
  knowledgeBaseId: "YOUR_KNOWLEDGE_BASE_ID",
  clientKey: "kl_pk_...",
});
3

Ask a question

const { answer, citations, threadId, messageId } = await kelu.chat(
  "How do I set up authentication?",
  { onToken: (t) => append(t) },
);

await kelu.chat("What about SSO?", { threadId });  // follow-up
await kelu.feedback({ messageId, rating: "up" });  // rate the answer
const { results } = await kelu.search("rate limits", { limit: 5 });
Never put clientSecret in browser or mobile code. Every visitor could read it.
Label each citation with its index, not its position in the list. The list holds only the sources the answer cited, so the numbers can skip. Every option, method, type and error code is in the @kelu/sdk reference.