Deploy ChatGPT API proxy using vercel serverless quickily.
- Access to vercel and login with your github account.
- OpenAPI key for OpenAI and set it to
OPENAPI_KEY
in vercel environment variables. - Fork this repository.
- Supported Languages for Serverless Functions | Vercel Docs
On vercel dashboard, click New Project
and select Import Git Repository
.
Choose your forked repository, you don't need to change anything, and click Import and Deploy
.
Now you can request vercel API endpoint, for example https://[name].vercel.app/api/hello
.
You can add ChatGPT key to environment variables on vercel dashboard, or use vercel env
command.
$cd [root of this repository]
# Add an Environment Variable
$vercel env add CHATGPT_KEY [your ChatGPT key]
# List all variables for the specified Environment
$vercel env list
You can deploy your project on vercel dashboard, or use vercel
command.
# Deploy to vercel, and set the environment variable
$vercel
# Deploy to vercel, and set the environment variable for production
$vercel --prod
You can develop locally with vercel dev
command.
go.mod
version. refer to Getting package not found error when running vercel dev in my Go project
Vercel will use api
directory as the entry point for your serverless functions. And the utils
directory is used to store the common functions.
Function name can be any name, but should be capitalized. And function should respect type http.HandlerFunc`