Skip to content

Latest commit

 

History

History
37 lines (22 loc) · 1.03 KB

README.md

File metadata and controls

37 lines (22 loc) · 1.03 KB

WEB222 Form + API Example

This example shows how to connect a simple <form> to the OpenAI Chat API in the browser.

Instructions

Install the dependencies:

npm install

Create an OpenAI Account and get your Secret API Key.

Create a file named .env in the root of the project and add your API Key to it. You can use the env.example file to help you:

cp env.example .env

Now edit .env and replace the ... with your API key.

Bundle the code and start a server:

npm start

You can now try the app at http://localhost:1234.

Warning

Do NOT put this code on the public internet, since it would expose your Secret API KEY. It is fine to run it locally, however.

Example

Example using the web interface to get multiple choice questions