What is JavaScript SDK?
@keluhq/sdk is the core Kelu client library. One typed client gives you streaming chat with citations, search, and feedback. It works in browsers, React Native (with a streaming-fetch polyfill), and Node.js 18 or later, and ships ESM and CommonJS builds with types.
How Kelu works with JavaScript SDK
Everything you can do once the integration is connected.
One typed client
kelu.chat, kelu.search, and kelu.feedback in one package, with TypeScript types included.
Streaming answers
kelu.chat passes each piece of the answer to onToken as it arrives, then resolves with the answer, citations, and thread ID.
Public and server-side auth
Use public client keys (kl_pk_...) for browser-side code and client ID + secret (kl_ci_... / kl_cs_...) for server-side integrations.
WebSocket with SSE fallback
Chat uses a WebSocket by default and falls back to server-sent events when the socket can't connect.
How to set it up
- 01
Run npm install @keluhq/sdk.
- 02
Create a client key under the knowledge base's Integrations > Client Keys: a public key (kl_pk_...) for browsers, or a client ID and secret (kl_ci_... / kl_cs_...) for servers. The Developer SDKs tab beside it shows the code with your knowledge base ID and key filled in.
- 03
Create a client with new Kelu({ knowledgeBaseId, clientKey }) and call kelu.chat(question). In a browser the SDK handles reCAPTCHA for you; on a server, use a client ID and secret instead. It resolves with the answer, citations, and thread ID.
Related integrations
Web Widget
The Kelu web widget embeds in any HTML page. One script tag, full style customization, mobile-ready, WCAG AA accessible.
React Component
Install @keluhq/react from npm. Drop in the <KeluChat /> panel, or build your own UI with the useKeluChat hook.
MCP Server
An MCP server at app.kelu.dev/mcp, scoped to a knowledge base by its client key, lets any MCP-aware AI tool query your knowledge base as structured tools.
Got questions?
JavaScript SDK — Frequently Asked Questions
Common questions about connecting Kelu to JavaScript SDK.
Yes. Install it from npm with npm install @keluhq/sdk. It works in browsers, React Native, and Node.js 18 or later.
Install @keluhq/sdk and call kelu.chat. Pass onToken to append each piece of the answer to your UI, and manage state with your framework's own primitives (Vue refs, Svelte stores, etc.). On a server, use a client ID and secret instead of a public key.
Yes, with one catch. A public key needs a reCAPTCHA v3 token on app.kelu.dev, and React Native has no browser to run reCAPTCHA in. Run reCAPTCHA v3 in a WebView, or send questions through your own server, which calls Kelu with a client ID and secret. For streaming over SSE, also install react-native-fetch-api and web-streams-polyfill.
Public client keys (kl_pk_...) are for browser-side and client-side use — they work for one knowledge base, can be limited to your site's origins, and are safe to expose in public pages. Client ID plus secret (kl_ci_... / kl_cs_...) pairs are for server-side integrations where the secret must never be exposed to the browser.