JavaScript SDK logo
Embed & Developer

JavaScript SDK

A framework-agnostic SDK for any JavaScript environment

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.

Integration

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.

Setup

How to set it up

  1. 01

    Run npm install @keluhq/sdk.

  2. 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.

  3. 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.

Got questions?

JavaScript SDK — Frequently Asked Questions

Common questions about connecting Kelu to JavaScript SDK.

Ready to connect JavaScript SDK?

Start free. No credit card required.