Skip to content

humphd/openai-form-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Working with OpenAI and HTML Forms

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published