diff --git a/README.en.md b/README.en.md new file mode 100644 index 00000000..c1e6b2bb --- /dev/null +++ b/README.en.md @@ -0,0 +1,284 @@ +
+ 中文 | English +
+ + + +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Deployment Tutorial + · + Usage + · + Feedback + · + Screenshots + · + Live Demo + · + FAQ + · + Related Projects + · + Donate +
+ +> **Warning**: This README is translated by ChatGPT. Please feel free to submit a PR if you find any translation errors. + +> **Note**: The latest image pulled from Docker may be an `alpha` release. Specify the version manually if you require stability. + +> **Warning**: Manual migration of the database is necessary when upgrading from version `v0.3` to `v0.4`. Please manually execute the [database migration script](./bin/migration_v0.3-v0.4.sql). + +## Features +1. Supports multiple API access channels. Welcome PRs or issue submissions for additional channels: + + [x] Official OpenAI channel (support proxy configuration) + + [x] **Azure OpenAI API** + + [x] [OpenAI-SB](https://openai-sb.com) + + [x] [API2D](https://api2d.com/r/197971) + + [x] [OhMyGPT](https://aigptx.top?aff=uFpUl2Kf) + + [x] [AI Proxy](https://aiproxy.io/?i=OneAPI) (invitation code: `OneAPI`) + + [x] [API2GPT](http://console.api2gpt.com/m/00002S) + + [x] [CloseAI](https://console.closeai-asia.com/r/2412) + + [x] [AI.LS](https://ai.ls) + + [x] [OpenAI Max](https://openaimax.com) + + [x] Custom channel: Various third-party proxy services not included in the list +2. Supports access to multiple channels through **load balancing**. +3. Supports **stream mode** that enables typewriter-like effect through stream transmission. +4. Supports **multi-machine deployment**. [See here](#multi-machine-deployment) for more details. +5. Supports **token management** that allows setting token expiration time and usage count. +6. Supports **voucher management** that enables batch generation and export of vouchers. Vouchers can be used for account balance replenishment. +7. Supports **channel management** that allows bulk creation of channels. +8. Supports **user grouping** and **channel grouping** for setting different rates for different groups. +9. Supports channel **model list configuration**. +10. Supports **quota details checking**. +11. Supports **user invite rewards**. +12. Allows display of balance in USD. +13. Supports announcement publishing, recharge link setting, and initial balance setting for new users. +14. Offers rich **customization** options: + 1. Supports customization of system name, logo, and footer. + 2. Supports customization of homepage and about page using HTML & Markdown code, or embedding a standalone webpage through iframe. +15. Supports management API access through system access tokens. +16. Supports Cloudflare Turnstile user verification. +17. Supports user management and multiple user login/registration methods: + + Email login/registration and password reset via email. + + [GitHub OAuth](https://github.com/settings/applications/new). + + WeChat Official Account authorization (requires additional deployment of [WeChat Server](https://github.com/songquanpeng/wechat-server)). +18. Immediate support and encapsulation of other major model APIs as they become available. + +## Deployment +### Docker Deployment +Deployment command: `docker run --name one-api -d --restart always -p 3000:3000 -e TZ=Asia/Shanghai -v /home/ubuntu/data/one-api:/data justsong/one-api` + +Update command: `docker run --rm -v /var/run/docker.sock:/var/run/docker.sock containrrr/watchtower -cR` + +The first `3000` in `-p 3000:3000` is the port of the host, which can be modified as needed. + +Data will be saved in the `/home/ubuntu/data/one-api` directory on the host. Ensure that the directory exists and has write permissions, or change it to a suitable directory. + +Nginx reference configuration: +``` +server{ + server_name openai.justsong.cn; # Modify your domain name accordingly + + location / { + client_max_body_size 64m; + proxy_http_version 1.1; + proxy_pass http://localhost:3000; # Modify your port accordingly + proxy_set_header Host $host; + proxy_set_header X-Forwarded-For $remote_addr; + proxy_cache_bypass $http_upgrade; + proxy_set_header Accept-Encoding gzip; + } +} +``` + +Next, configure HTTPS with Let's Encrypt certbot: +```bash +# Install certbot on Ubuntu: +sudo snap install --classic certbot +sudo ln -s /snap/bin/certbot /usr/bin/certbot +# Generate certificates & modify Nginx configuration +sudo certbot --nginx +# Follow the prompts +# Restart Nginx +sudo service nginx restart +``` + +The initial account username is `root` and password is `123456`. + +### Manual Deployment +1. Download the executable file from [GitHub Releases](https://github.com/songquanpeng/one-api/releases/latest) or compile from source: + ```shell + git clone https://github.com/songquanpeng/one-api.git + + # Build the frontend + cd one-api/web + npm install + npm run build + + # Build the backend + cd .. + go mod download + go build -ldflags "-s -w" -o one-api + ``` +2. Run: + ```shell + chmod u+x one-api + ./one-api --port 3000 --log-dir ./logs + ``` +3. Access [http://localhost:3000/](http://localhost:3000/) and log in. The initial account username is `root` and password is `123456`. + +For more detailed deployment tutorials, please refer to [this page](https://iamazing.cn/page/how-to-deploy-a-website). + +### Multi-machine Deployment +1. Set the same `SESSION_SECRET` for all servers. +2. Set `SQL_DSN` and use MySQL instead of SQLite. All servers should connect to the same database. +3. Set the `NODE_TYPE` for all non-master nodes to `slave`. +4. Set `SYNC_FREQUENCY` for servers to periodically sync configurations from the database. +5. Non-master nodes can optionally set `FRONTEND_BASE_URL` to redirect page requests to the master server. +6. Install Redis separately on non-master nodes, and configure `REDIS_CONN_STRING` so that the database can be accessed with zero latency when the cache has not expired. +7. If the main server also has high latency accessing the database, Redis must be enabled and `SYNC_FREQUENCY` must be set to periodically sync configurations from the database. + +Please refer to the [environment variables](#environment-variables) section for details on using environment variables. + +### Deployment on Control Panels (e.g., Baota) +Refer to [#175](https://github.com/songquanpeng/one-api/issues/175) for detailed instructions. + +If you encounter a blank page after deployment, refer to [#97](https://github.com/songquanpeng/one-api/issues/97) for possible solutions. + +### Deployment on Third-Party Platforms ++ 中文 | English +
+ +