Skip to content

A minimal example of streaming chat messages to the browser from a node.js back-end with OpenAI's Javascript SDK and Assistants API

Notifications You must be signed in to change notification settings

matthabermehl/open-ai-assistant-streaming-basic

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

OpenAI Assistant Streaming Basic Starter

This is a simple bare-bones example of streaming to the browser using OpenAI's Assistants API (Javascript SDK) on a node.js (Express) back end. Uses socket.io.

Pull requests are welcome to correct errors or improve simplicity and clarity of the code. It's my hope that this will actually be useful for someone else as a template to start AI web applications.

Instructions

This has been tested on node.js v20, but likely works on 18. Highly recommend node version manager for managing node versions.

Create a .env file in the server directory and paste the following:

# server/.env
OPENAI_API_KEY=<your-OpenAI-API-key>

Replace <your-OpenAI-API-key> with your actual key.

In the server directory, run npm install

In the server directory, run node server.js

Visit http://localhost:3005

About

A minimal example of streaming chat messages to the browser from a node.js back-end with OpenAI's Javascript SDK and Assistants API

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published