@keluhq/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.

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.The Developer SDKs tab beside it shows the code below with your knowledge base ID and a public key filled in. The ID is also the part of the dashboard address after /knowledge-bases/.
2

Install the package

npm install @keluhq/sdk
3

Create the client

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

const kelu = new Kelu({
  knowledgeBaseId: "YOUR_KNOWLEDGE_BASE_ID",
  clientKey: "kl_pk_...",
});
In a browser, a public key on app.kelu.dev also needs a reCAPTCHA token on every request. The client gets one for you: see CAPTCHA. A secret pair never needs one.
4

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.
The answer is Markdown. Render it with the SDK’s renderMarkdown so it looks the same as in the widget: see Showing the answer. 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 @keluhq/sdk reference.