Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yayapao/chatgpt-api-vercel
Deploy ChatGPT API proxy on vercel.🎉 基于 vercel 和 Go 封装 ChatGPT API,支持 vercel 一键部署。
https://github.com/yayapao/chatgpt-api-vercel
chatgpt-api golang
Last synced: 2 months ago
JSON representation
Deploy ChatGPT API proxy on vercel.🎉 基于 vercel 和 Go 封装 ChatGPT API,支持 vercel 一键部署。
- Host: GitHub
- URL: https://github.com/yayapao/chatgpt-api-vercel
- Owner: yayapao
- License: mit
- Created: 2023-03-30T09:01:03.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-03-30T10:12:49.000Z (almost 2 years ago)
- Last Synced: 2024-04-23T05:26:59.717Z (9 months ago)
- Topics: chatgpt-api, golang
- Language: Go
- Homepage:
- Size: 5.86 KB
- Stars: 2
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ChatGPT-api-vercel
Deploy ChatGPT API proxy using vercel serverless quickily.
## Preparation
1. Access to [vercel](https://vercel.com) and login with your github account.
2. OpenAPI key for [OpenAI](https://openai.com) and set it to `OPENAPI_KEY` in vercel environment variables.
3. Fork this repository.
4. [Supported Languages for Serverless Functions | Vercel Docs](https://vercel.com/docs/concepts/functions/serverless-functions/supported-languages#go)## Create a project
On [vercel](https://vercel.com) 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`.
## Add ChatGPT Key to environment variables
You can add ChatGPT key to environment variables on vercel dashboard, or use `vercel env` command.
```bash
$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
```## Deploy
You can deploy your project on vercel dashboard, or use `vercel` command.
```bash
# Deploy to vercel, and set the environment variable
$vercel# Deploy to vercel, and set the environment variable for production
$vercel --prod
```## Develop locally
You can develop locally with `vercel dev` command.
⚠️Go version should be 1.20 or higher. Keep in mind that Go version should greater than @vercel/go `go.mod` version. refer to [Getting package not found error when running vercel dev in my Go project](https://github.com/orgs/vercel/discussions/1850#discussioncomment-5401091)
### Structure
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](https://pkg.go.dev/net/http#HandlerFunc)`