/ChatGPT-API-with-single-HTML-Page

OpenAI Stream API Vanilla JS Example

Primary LanguageHTML

OpenAI Stream API Vanilla JS Example

This is an very simple example of how to use the OpenAI GPT API to generate text with Server-Sent Events (SSE) using Vanilla JS.

Simply change the OPENNAI_API_KEY value to your own key and you can use it immediately.

This code is designed to be the simplest to receive interactive SSE streams using Vanilla JS, but only for practice purposes. In a production environment, it can be vulnerable for security.

I hope this simple implementation will help the coder who first encountered HTML/JS.