
Company News
Socket Named Top Sales Organization by RepVue
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.
@bytemaster2704/streaming-chat-sdk
Advanced tools
A lightweight, TypeScript-friendly SDK for connecting to streaming chat APIs using Server-Sent Events (SSE).
Perfect for building real-time AI assistants, chatbots, or any application requiring live streamed responses.
npm install @bytemaster2704/streaming-chat-sdk
If you’re using Node.js (not the browser), install an SSE polyfill:
npm install eventsource
import { ChatSDK } from "@bytemaster2704/streaming-chat-sdk";
const sdk = new ChatSDK({
baseUrl: "https://your-chat-api.com", // defaults to http://localhost:3000
});
sdk.stream("Hello, world!", {
onToken: (token) => {
process.stdout.write(token); // stream tokens in real-time
},
onEnd: () => {
console.log("\n✅ Stream ended by server.");
},
onError: (err) => {
console.error("❌ Error:", err.message);
},
});
ChatSDKnew ChatSDK(options?: { baseUrl?: string })
baseUrl (string) – The root URL of your chat API.http://localhost:3000.streamsdk.stream(query: string, options: StreamingChatOptions): EventSource
Starts a streaming chat session with the server.
Parameters
query (string) – The prompt or question to send.options (StreamingChatOptions) – Callbacks for handling stream events.Returns
EventSource – The underlying SSE connection.StreamingChatOptionsinterface StreamingChatOptions {
onToken: (token: string) => void; // required
onEnd?: () => void; // optional
onError?: (error: Error) => void; // optional
}
onToken – Fired whenever the server streams a new token.onEnd – Fired when the stream is completed.onError – Fired if a network or server error occurs.Display tokens as they arrive for a natural typing effect.
Use the status event type to stream progress updates from the server.
Stream results chunk by chunk instead of waiting for the full response.
EventSource is not defined (Node.js only)Node.js doesn’t ship with EventSource. Install a polyfill:
npm install eventsource
Then, at the top of your app:
import EventSource from "eventsource";
(global as any).EventSource = EventSource;
Failed to parse server messageMake sure your server sends JSON-encoded messages in this format:
{ "type": "token", "content": "Hello" }
{ "type": "end" }
{ "type": "error", "content": "Something went wrong" }
Stream never endsYour server must send an "end" message. Otherwise, the connection stays open indefinitely.
Clone and build locally:
git clone https://github.com/bytemaster2704/streaming-chat-sdk.git
cd streaming-chat-sdk
npm install
npm run build
ISC © Hanumant Kakde
FAQs
A simple SDK to interact with a streaming chat API
We found that @bytemaster2704/streaming-chat-sdk demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.