LLM Chat with React, OpenAI, and Vercel
This is an example of a conversational (with voice!) React app that calls a simple serverless backend written in Python.
The backend automatically gets deployed to appropraite endpoint if using Vercel. Use the “Deploy” button above to deploy it to your own project.
Setup
- You will need an OpenAI API token set to the
OPENAI_API_KEY
env variable. This app uses the GPT-4 model. - If have
gpt-4
API access, set theOPENAI_API_MODEL
env var togpt-4
, otherwise it will usegpt-3.5-turbo
.
npm install
Running locally
# This starts the backend
npm i -g vercel
vercel dev
Deploying
# Only need to set the key once
vercel env add OPENAI_API_KEY
vercel deploy