Getting Started
Get a working SDK integration quickly with basic chat, streaming, and convenience sendMessage flow.
Install
npm install @jazzmine-ui/sdkRuntime compatibility
Works in browser runtimes and Node.js 18+. For older Node versions, pass fetchImpl in
constructor options.
Choose a flow
| Flow | Use it when | Method |
|---|---|---|
| Basic chat | You need one request/response call | chat() |
| Streaming chat | You want progress events while generating output | chatStream() |
| Convenience send | You want auto-create + first message in one call | sendMessage() |
Basic chat
import JazzmineClient from "@jazzmine-ui/sdk";
const client = new JazzmineClient("https://your-jazzmine-api.example.com", {
apiKey: "your-api-key",
});
const reply = await client.chat({ message: "Summarize this dataset." });
console.log(reply.response);Streaming chat
import JazzmineClient from "@jazzmine-ui/sdk";
const client = new JazzmineClient("https://your-jazzmine-api.example.com");
const final = await client.chatStream(
{ message: "Plan a 5-day trip to Tokyo." },
{
onIntermediate: (event) => console.log("intermediate", event),
onDone: (response) => console.log("done", response.response),
onErrorEvent: (event) => console.error("stream error event", event),
},
);
console.log(final.conversation_id);Convenience sendMessage flow
import JazzmineClient from "@jazzmine-ui/sdk";
const client = new JazzmineClient("https://your-jazzmine-api.example.com", {
defaultUserId: "alice",
});
const { response, conversationId } = await client.sendMessage("Start a new thread", {
autoCreateConversation: true,
conversationTitle: "Project planning",
});
console.log(conversationId, response.response);Node.js note
For Node.js versions below 18, provide a fetch implementation through fetchImpl.
import JazzmineClient from "@jazzmine-ui/sdk";
import fetch from "cross-fetch";
const client = new JazzmineClient("https://your-jazzmine-api.example.com", {
fetchImpl: fetch as unknown as typeof globalThis.fetch,
});