Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan Now×
Skip to content
World desk4 min

Building a Streaming Chatbot with Node.js

Use Node.js as a secure bridge between a chat interface and OpenAI’s streaming Responses API, forwarding text deltas while handling completion, errors, and cancellation.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A Node.js streaming chatbot sends a user’s message to a model provider from trusted server-side code, then forwards response events to the browser as they arrive. With OpenAI’s Responses API, set stream: true, process typed events in Node.js, and append text deltas to the assistant’s visible message. The browser must parse the format your server actually returns; an SDK-readable stream is newline-delimited JSON, while the upstream API uses server-sent events (SSE).

What streaming changes in a chatbot

Without streaming, the application waits for the complete model response before displaying it. Streaming lets the server and browser process output incrementally, so the interface can show early text while generation continues. It improves perceived responsiveness; it does not, by itself, guarantee a particular response time or increase generation speed. OpenAI describes the approach and its event model in its Responses API streaming guide.

The server is the bridge: it accepts and validates a chat request, calls the provider with server-side credentials, and forwards events to the browser. Keeping the API key on the server prevents the browser from needing the provider credential. Node.js’s built-in HTTP API is deliberately low-level, allowing an application to control request and response handling; a framework route can fill the same role. See the Node.js HTTP documentation.

Build the server-to-browser flow

1. Accept and validate the message

Create a server endpoint that accepts the user’s message. Before calling the model, validate that the request has the expected shape and apply the authentication, input-size limits, and rate controls appropriate to your application. These are application responsibilities, not settings provided automatically by streaming.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
SANOOV Pi5 Basic Kit for Raspberry Pi 5 4GB with Active Cooler,Power Supply
  • 【SANOOV Pi 5 4GB Kit Package】SANOOV RPi 5 basic kit includes 1x Pi 5 4GB RAM Single Board, 1x Active Cooler, 1x ABS SANOOV Case for Raspberry Pi 5, 1x GaN PD 27W 5.1V5A Power supply,1x Screwdriver. Tip: SD card is NOT included.
  • 【ABS Case Lightweight Texture】 Compared to metal case,ABS case have a softer texture and feel, and the rounded design prevents damage to motherboard components. Meanwhile, the case is partially hollowed out to ensure heat dissipation.
  • 【Cooling Kit for Pi 5】Compatible with Active Cooler for Raspberry Pi 5, It can provide Pi 5 board with better cooling effect in using. SANOOV Case can accurately access usb-c power jack,Micro HD Out ports, usb ports, Ethernet jack, card slot, power button, 4-lane MIPI DSI/CSI connectors and so on, and it also supports installation of cooling fan.
  • 【27W GaN USB-C Power Supply】The SANOOV GaN 27W USB C Power Supply with smaller size and more stable electric current, fully compatible with Pi 5 16GB/8GB/4GB/2GB, offers a variety of output voltage options, including 5.1V at 5A, 9.0V at 3.0A, 12.0V at 2.25A, and 15.0V at 1.8A, providing for different device requirements.
  • 【Support Dual 4Kp60 Display】Each of the two display sockets can control a 4K display at 60 Hertz, now support HDR, offering super HD video for media streaming projects. RPi 5 is the first RPi model that comes with a PCI Express port (PCIe 2.0 x1 with 500 MB/s) to attach SSDs.

2. Start a Responses API stream in Node.js

Use the official OpenAI JavaScript SDK from server-side code, with the API credential configured in the server environment. The SDK’s Responses API pattern sets stream: true and consumes the returned async iterable with for await. OpenAI documents the API’s streaming transport as SSE and exposes typed semantic events through the SDK. Check the official JavaScript SDK documentation for the current method and event details, and verify them against the SDK version your application pins.

3. Append text deltas and track the outcome

For a simple text-only chat display, append the delta value from each response.output_text.delta event to the current assistant message. Treat this as incremental content, not as proof that the answer is complete. Listen for response.completed as the normal success event, and handle error events and thrown exceptions separately. The Responses API guide documents the event types and lifecycle.

Rank #2
SANOOV Raspberry Pi 5 Kit 8GB RAM 64GB Edition
  • ✅ New Improve for Raspberry Pi 5 8GB Kit: 1 x Pi 5 Single Board (8GB), 1 x 64GB Card, 1 x Active Cooler, 1 x Pi 5 ABS Case, 2 x Display OUTPUT Over 4K Cables, 1 x USB-C 27W 5.1V 5A Power Supply, 1 x Card Reader, 1 x Card Adapter, 1 x Screwdriver, 1 x User Manual. RPi is designed to deliver maximum performance in applications such as server solutions, home automation and multimedia.(Tip: The Case cannot install M.2 HAT Add on Board and Solid State Drive!)
  • ❄️ Active Cooler & Actively Adjust Speed According Temperature: SANOOV Pi 5 8GB kit offer an active cooler(combines an aluminium heatsink with a temperature-controlled blower fan). The fan supports speed control and is fully compatible with Pi OS. Different from ordinary fans, the active cooler adjust fan speed according to the temperature of the Pi 5 board during use. If the temperature is high, the fan will increase speed to dissipate heat. If low, the fan will decrease speed.
  • 🗃 ABS Case & Protection and Cooling: SANOOV Pi 5 Case is made from the high quality ABS material, ABS case is a two-piece injection-molded to provide tough protection for the board while providing access to all the connectors, including USB-C power jack, micro HD-out ports, usb ports, Ethernet jack, sd card slot. And the unique removable top cover design can access to GPIO easily. This is a protective ABS case specifically designed for the Raspberry Pi 5 holds the board firmly in place.
  • 🔌 High Quality Power Supply by GaN & 27W 5.1V 5A USB-C: SANOOV power supply for Raspberry Pi 5 powered by GaN Technology with multiple protection functions.GaN technology makes our 27W power supplies smaller, operate at lower temperatures, and more stable without sacrificing power consumption. Importantly this GaN power supply is not limited to Pi5. Devices compatible with charging cables can use this power supply, which is small, convenient and easy to carry.
  • 🚀 More Powerful Processor & Ultra HD View: Pi 5 8GB is equipped with broadcom 64 quad-core Arm Cortex A76 processor with gigabit ethernet and upgraded with IEEE 802.11ac Wi-Fi, Bluetooth 5.0 dual-band 2.4Ghz and 5Ghz and Power Over Ethernet (POE). Upgrading delivers 2-3 x speed vs Pi 4, redefining the experience. SANOOV Pi 5 kit has two Mini display Out ports, both ports offer an ultra hd 4kp60 view, which dramatically improves graphics performance.

A stream reaching its end is not sufficient evidence of success. If you use the SDK’s accumulated-response helper, consume the stream and inspect the final response status; the SDK documentation notes that a clean end-of-stream can still leave a response whose status is not completed. Your interface should distinguish a finished answer from an interrupted or incomplete one rather than silently presenting both as successful.

4. Forward events in a format the browser can parse

The SDK documents converting its stream to a readable stream for a server-side proxy. Be aware that toReadableStream() emits newline-separated JSON (NDJSON), not the upstream API’s SSE framing. The browser-side parser must match the bytes your endpoint sends: use an NDJSON parser for newline-delimited JSON, or preserve and correctly parse SSE if your endpoint emits SSE. Do not point an SSE parser at NDJSON or assume that forwarding the stream preserves its original framing.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Freenove Ultimate Starter Kit for Raspberry Pi 5 4 Zero 2 W (NOT Included)
  • 5 sets of code: Python (compatible with 2&3), C, Java, Scratch and Processing (Scratch and Processing code provide graphical interfaces)
  • Detailed tutorial: Can be downloaded (in English, 962-page in total) or viewed online (original in English, can be translated into other languages by browsers) (The tutorial link can be found on the product box, no paper tutorial)
  • 128 projects from simple to complex: Provides step-by-step guide with electronics and components knowledge, each project has schematics, wiring diagrams, complete code and detailed explanations
  • 223 items in total: This ultimate kit includes the most commonly used electronic components, modules, sensors, wires and other compatible items
  • Compatible models: Raspberry Pi 5 / 500 / 400 / 4B / 3B+ / 3B / 3A+ / 2B / 1B+ / 1A+ / Zero 2 W / Zero W / Zero (NOT included in this kit)

The SDK documentation includes an Express proxy example. That example is a pattern for forwarding output, not a guarantee about buffering or streaming behavior in every hosting environment or reverse-proxy configuration.

5. Handle cancellation and interruptions

Catch request and stream failures so the application can report an interrupted generation instead of leaving the user with an apparently finished partial answer. The SDK supports cancelling with stream.abort() or an AbortSignal; breaking out of its async iteration also aborts the ongoing request. Connect browser disconnects or an explicit stop action to cancellation where appropriate, and clear any incomplete-generation state in the interface.

Rank #4
SunFounder Raspberry Pi Pico W Ultimate Starter Kit with Online Tutorials, RoHS Compliant, 450+ Items, 117 Projects, MicroPython, C/C++ (Compatible with Arduino IDE)
  • IoT Starter Kit for Beginners: The SunFounder Raspberry Pi Pico W Ultimate Starter Kit offers a rich IoT learning experience for beginners aged 8+. With 450+ components, 117 projects, and expert-led video lessons, this kit makes learning microcontroller programming and IoT engaging and accessible, RoHS Compliant
  • Expert-Guided Video Lessons: This kit includes 27 video tutorials by the renowned educator, Paul McWhorter. His engaging style simplifies complex concepts, ensuring an effective learning experience in microcontroller programming
  • Wide Range of Hardware: The kit includes a diverse array of components like sensors, actuators, LEDs, LCDs, and more, enabling you to experiment and create a variety of projects with the Raspberry Pi Pico W
  • Supports Multiple Languages: The kit offers versatility with support for three programming languages - MicroPython, C/C++, and Piper Make, providing a diverse programming learning experience
  • Dedicated Support: Benefit from our ongoing assistance, including a community forum and timely technical help for a seamless learning experience

For longer-running or reconnectable work, the SDK documentation describes background responses, response IDs, event sequence numbers, and resuming with starting_after. Resume from the appropriate point in the event sequence and inspect the final response status; reconnection does not remove the need to handle terminal outcomes.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Choose an API and event-forwarding approach

OpenAI recommends the Responses API for streaming: it was designed with streaming in mind and provides semantic typed events. Chat Completions is also documented as supporting incremental streaming chunks with a delta field. The practical choice depends on your application’s needs and existing integration.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
USB Debug Probe Kit for Raspberry Pi Pico - RP2040 Microcontroller with 3-Pin Debug Connector Cable and Clear Cover Case @XYGStudy
  • Part Number: Pi Debug Probe
  • Original USB Debug Probe for Raspberry Pi Pico, Hardware debug kit designed for Pico, Based on RP2040 Microcontroller, With transparent plastic case
  • Pi Debug Probe is an official USB hardware debugger designed for Pico, all-in-one design, with the features of solderless and plug-and-play, can be connected to the debug interface of the target board via SWD interface.
  • This makes it easy to use a Pi Pico on non-R Pi platforms such as Windows, Mac, and “normal” Linux computers, where you don’t have a GPIO header to connect directly to the Pico’s serial UART or SWD port.
  • Onboard Micro-USB port for connecting to PC or other motherboards. Onboard 3PIN SWD interface for connecting to the target board. Onboard 3PIN USB to UART bridge
Choice What the documentation establishes What to weigh
Responses API Streaming uses typed semantic events, including text deltas and lifecycle events. Useful when you want to handle output and response lifecycle as distinct events.
Chat Completions Streaming returns incremental chunks with a delta field. Can suit an application already built around Chat Completions; account for the event handling your interface needs.

For the server-to-browser leg, choose either a documented SDK-readable stream or a custom event format, then make the endpoint and browser parser agree. The essential distinction is framing: the SDK conversion helper produces NDJSON, whereas the upstream Responses stream uses SSE. The SDK helper’s exact behavior and event types can change; check the documentation for the version you deploy.

What streaming alone does not decide

The API and SDK documentation describe how to request and consume a stream, but they do not select a production architecture for your application. Framework, hosting, reverse-proxy buffering, browser compatibility, privacy handling, moderation, and cost depend on your deployment and product requirements. Validate the behavior end to end in your chosen environment, particularly that bytes reach the browser incrementally rather than being buffered until completion.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.