diff --git a/README.en.md b/README.en.md deleted file mode 100644 index 51eca781..00000000 --- a/README.en.md +++ /dev/null @@ -1,327 +0,0 @@ -
- - - -- 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. - -> **Warning**: The Docker image for English version is `justsong/one-api-en`. - -> **Note**: The latest image pulled from Docker may be an `alpha` release. Specify the version manually if you require stability. - -## Features - -1. Support for multiple large models: - - [x] [OpenAI ChatGPT Series Models](https://platform.openai.com/docs/guides/gpt/chat-completions-api) (Supports [Azure OpenAI API](https://learn.microsoft.com/en-us/azure/ai-services/openai/reference)) - - [x] [Anthropic Claude Series Models](https://anthropic.com) - - [x] [Google PaLM2 and Gemini Series Models](https://developers.generativeai.google) - - [x] [Baidu Wenxin Yiyuan Series Models](https://cloud.baidu.com/doc/WENXINWORKSHOP/index.html) - - [x] [Alibaba Tongyi Qianwen Series Models](https://help.aliyun.com/document_detail/2400395.html) - - [x] [Zhipu ChatGLM Series Models](https://bigmodel.cn) -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-en` - -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 - -- デプロイチュートリアル - · - 使用方法 - · - フィードバック - · - スクリーンショット - · - ライブデモ - · - FAQ - · - 関連プロジェクト - · - 寄付 -
- -> **警告**: この README は ChatGPT によって翻訳されています。翻訳ミスを発見した場合は遠慮なく PR を投稿してください。 - -> **警告**: 英語版の Docker イメージは `justsong/one-api-en` です。 - -> **注**: Docker からプルされた最新のイメージは、`alpha` リリースかもしれません。安定性が必要な場合は、手動でバージョンを指定してください。 - -## 特徴 - -1. 複数の大型モデルをサポート: - - [x] [OpenAI ChatGPT シリーズモデル](https://platform.openai.com/docs/guides/gpt/chat-completions-api) ([Azure OpenAI API](https://learn.microsoft.com/en-us/azure/ai-services/openai/reference) をサポート) - - [x] [Anthropic Claude シリーズモデル](https://anthropic.com) - - [x] [Google PaLM2/Gemini シリーズモデル](https://developers.generativeai.google) - - [x] [Baidu Wenxin Yiyuan シリーズモデル](https://cloud.baidu.com/doc/WENXINWORKSHOP/index.html) - - [x] [Alibaba Tongyi Qianwen シリーズモデル](https://help.aliyun.com/document_detail/2400395.html) - - [x] [Zhipu ChatGLM シリーズモデル](https://bigmodel.cn) -2. **ロードバランシング**による複数チャンネルへのアクセスをサポート。 -3. ストリーム伝送によるタイプライター的効果を可能にする**ストリームモード**に対応。 -4. **マルチマシンデプロイ**に対応。[詳細はこちら](#multi-machine-deployment)を参照。 -5. トークンの有効期限や使用回数を設定できる**トークン管理**に対応しています。 -6. **バウチャー管理**に対応しており、バウチャーの一括生成やエクスポートが可能です。バウチャーは口座残高の補充に利用できます。 -7. **チャンネル管理**に対応し、チャンネルの一括作成が可能。 -8. グループごとに異なるレートを設定するための**ユーザーグループ**と**チャンネルグループ**をサポートしています。 -9. チャンネル**モデルリスト設定**に対応。 -10. **クォータ詳細チェック**をサポート。 -11. **ユーザー招待報酬**をサポートします。 -12. 米ドルでの残高表示が可能。 -13. 新規ユーザー向けのお知らせ公開、リチャージリンク設定、初期残高設定に対応。 -14. 豊富な**カスタマイズ**オプションを提供します: - 1. システム名、ロゴ、フッターのカスタマイズが可能。 - 2. HTML と Markdown コードを使用したホームページとアバウトページのカスタマイズ、または iframe を介したスタンドアロンウェブページの埋め込みをサポートしています。 -15. システム・アクセストークンによる管理 API アクセスをサポートする。 -16. Cloudflare Turnstile によるユーザー認証に対応。 -17. ユーザー管理と複数のユーザーログイン/登録方法をサポート: - - 電子メールによるログイン/登録とパスワードリセット。 - - [GitHub OAuth](https://github.com/settings/applications/new)。 - - WeChat 公式アカウントの認証([WeChat Server](https://github.com/songquanpeng/wechat-server)の追加導入が必要)。 -18. 他の主要なモデル API が利用可能になった場合、即座にサポートし、カプセル化する。 - -## デプロイメント - -### Docker デプロイメント - -デプロイコマンド: `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-en`。 - -コマンドを更新する: `docker run --rm -v /var/run/docker.sock:/var/run/docker.sock containrr/watchtower -cR`。 - -`-p 3000:3000` の最初の `3000` はホストのポートで、必要に応じて変更できます。 - -データはホストの `/home/ubuntu/data/one-api` ディレクトリに保存される。このディレクトリが存在し、書き込み権限があることを確認する、もしくは適切なディレクトリに変更してください。 - -Nginx リファレンス設定: - -``` -server{ - server_name openai.justsong.cn; # ドメイン名は適宜変更 - - location / { - client_max_body_size 64m; - proxy_http_version 1.1; - proxy_pass http://localhost:3000; # それに応じてポートを変更 - proxy_set_header Host $host; - proxy_set_header X-Forwarded-For $remote_addr; - proxy_cache_bypass $http_upgrade; - proxy_set_header Accept-Encoding gzip; - proxy_read_timeout 300s; # GPT-4 はより長いタイムアウトが必要 - } -} -``` - -次に、Let's Encrypt certbot を使って HTTPS を設定します: - -```bash -# Ubuntu に certbot をインストール: -sudo snap install --classic certbot -sudo ln -s /snap/bin/certbot /usr/bin/certbot -# 証明書の生成と Nginx 設定の変更 -sudo certbot --nginx -# プロンプトに従う -# Nginx を再起動 -sudo service nginx restart -``` - -初期アカウントのユーザー名は `root` で、パスワードは `123456` です。 - -### マニュアルデプロイ - -1. [GitHub Releases](https://github.com/songquanpeng/one-api/releases/latest) から実行ファイルをダウンロードする、もしくはソースからコンパイルする: - - ```shell - git clone https://github.com/songquanpeng/one-api.git - - # フロントエンドのビルド - cd one-api/web - npm install - npm run build - - # バックエンドのビルド - cd .. - go mod download - go build -ldflags "-s -w" -o one-api - ``` - -2. 実行: - ```shell - chmod u+x one-api - ./one-api --port 3000 --log-dir ./logs - ``` -3. [http://localhost:3000/](http://localhost:3000/) にアクセスし、ログインする。初期アカウントのユーザー名は `root`、パスワードは `123456` である。 - -より詳細なデプロイのチュートリアルについては、[このページ](https://iamazing.cn/page/how-to-deploy-a-website) を参照してください。 - -### マルチマシンデプロイ - -1. すべてのサーバに同じ `SESSION_SECRET` を設定する。 -2. `SQL_DSN` を設定し、SQLite の代わりに MySQL を使用する。すべてのサーバは同じデータベースに接続する。 -3. マスターノード以外のノードの `NODE_TYPE` を `slave` に設定する。 -4. データベースから定期的に設定を同期するサーバーには `SYNC_FREQUENCY` を設定する。 -5. マスター以外のノードでは、オプションで `FRONTEND_BASE_URL` を設定して、ページ要求をマスターサーバーにリダイレクトすることができます。 -6. マスター以外のノードには Redis を個別にインストールし、`REDIS_CONN_STRING` を設定して、キャッシュの有効期限が切れていないときにデータベースにゼロレイテンシーでアクセスできるようにする。 -7. メインサーバーでもデータベースへのアクセスが高レイテンシになる場合は、Redis を有効にし、`SYNC_FREQUENCY` を設定してデータベースから定期的に設定を同期する必要がある。 - -Please refer to the [environment variables](#environment-variables) section for details on using environment variables. - -### コントロールパネル(例: Baota)への展開 - -詳しい手順は [#175](https://github.com/songquanpeng/one-api/issues/175) を参照してください。 - -配置後に空白のページが表示される場合は、[#97](https://github.com/songquanpeng/one-api/issues/97) を参照してください。 - -### サードパーティプラットフォームへのデプロイ - -- 部署教程 - · - 使用方法 - · - 意见反馈 - · - 截图展示 - · - 在线演示 - · - 常见问题 - · - 相关项目 - · - 赞赏支持 -
- -> [!NOTE] -> 本项目为开源项目,使用者必须在遵循 OpenAI 的[使用条款](https://openai.com/policies/terms-of-use)以及**法律法规**的情况下使用,不得用于非法用途。 -> -> 根据[《生成式人工智能服务管理暂行办法》](http://www.cac.gov.cn/2023-07/13/c_1690898327029107.htm)的要求,请勿对中国地区公众提供一切未经备案的生成式人工智能服务。 - -> [!WARNING] -> 使用 Docker 拉取的最新镜像可能是 `alpha` 版本,如果追求稳定性请手动指定版本。 - -> [!WARNING] -> 使用 root 用户初次登录系统后,务必修改默认密码 `123456`! - -## 功能 - -1. 支持多种大模型: - - [x] [OpenAI ChatGPT 系列模型](https://platform.openai.com/docs/guides/gpt/chat-completions-api)(支持 [Azure OpenAI API](https://learn.microsoft.com/en-us/azure/ai-services/openai/reference)) - - [x] [Anthropic Claude 系列模型](https://anthropic.com) - - [x] [Google PaLM2/Gemini 系列模型](https://developers.generativeai.google) - - [x] [百度文心一言系列模型](https://cloud.baidu.com/doc/WENXINWORKSHOP/index.html) - - [x] [阿里通义千问系列模型](https://help.aliyun.com/document_detail/2400395.html) - - [x] [讯飞星火认知大模型](https://www.xfyun.cn/doc/spark/Web.html) - - [x] [智谱 ChatGLM 系列模型](https://bigmodel.cn) - - [x] [360 智脑](https://ai.360.cn) - - [x] [腾讯混元大模型](https://cloud.tencent.com/document/product/1729) -2. 支持配置镜像以及众多[第三方代理服务](https://iamazing.cn/page/openai-api-third-party-services)。 -3. 支持通过**负载均衡**的方式访问多个渠道。 -4. 支持 **stream 模式**,可以通过流式传输实现打字机效果。 -5. 支持**多机部署**,[详见此处](#多机部署)。 -6. 支持**令牌管理**,设置令牌的过期时间和额度。 -7. 支持**兑换码管理**,支持批量生成和导出兑换码,可使用兑换码为账户进行充值。 -8. 支持**通道管理**,批量创建通道。 -9. 支持**用户分组**以及**渠道分组**,支持为不同分组设置不同的倍率。 -10. 支持渠道**设置模型列表**。 -11. 支持**查看额度明细**。 -12. 支持**用户邀请奖励**。 -13. 支持以美元为单位显示额度。 -14. 支持发布公告,设置充值链接,设置新用户初始额度。 -15. 支持模型映射,重定向用户的请求模型,如无必要请不要设置,设置之后会导致请求体被重新构造而非直接透传,会导致部分还未正式支持的字段无法传递成功。 -16. 支持失败自动重试。 -17. 支持绘图接口。 -18. 支持 [Cloudflare AI Gateway](https://developers.cloudflare.com/ai-gateway/providers/openai/),渠道设置的代理部分填写 `https://gateway.ai.cloudflare.com/v1/ACCOUNT_TAG/GATEWAY/openai` 即可。 -19. 支持丰富的**自定义**设置, - 1. 支持自定义系统名称,logo 以及页脚。 - 2. 支持自定义首页和关于页面,可以选择使用 HTML & Markdown 代码进行自定义,或者使用一个单独的网页通过 iframe 嵌入。 -20. 支持通过系统访问令牌访问管理 API(bearer token,用以替代 cookie,你可以自行抓包来查看 API 的用法)。 -21. 支持 Cloudflare Turnstile 用户校验。 -22. 支持用户管理,支持**多种用户登录注册方式**: - - 邮箱登录注册(支持注册邮箱白名单)以及通过邮箱进行密码重置。 - - [GitHub 开放授权](https://github.com/settings/applications/new)。 - - 微信公众号授权(需要额外部署 [WeChat Server](https://github.com/songquanpeng/wechat-server))。 - -## 部署 - -### 基于 Docker 进行部署 - -```shell -# 使用 SQLite 的部署命令: -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 -# 使用 MySQL 的部署命令,在上面的基础上添加 `-e SQL_DSN="root:123456@tcp(localhost:3306)/oneapi"`,请自行修改数据库连接参数,不清楚如何修改请参见下面环境变量一节。 -# 例如: -docker run --name one-api -d --restart always -p 3000:3000 -e SQL_DSN="root:123456@tcp(localhost:3306)/oneapi" -e TZ=Asia/Shanghai -v /home/ubuntu/data/one-api:/data justsong/one-api -``` - -其中,`-p 3000:3000` 中的第一个 `3000` 是宿主机的端口,可以根据需要进行修改。 - -数据和日志将会保存在宿主机的 `/home/ubuntu/data/one-api` 目录,请确保该目录存在且具有写入权限,或者更改为合适的目录。 - -如果启动失败,请添加 `--privileged=true`,具体参考 https://github.com/songquanpeng/one-api/issues/482 。 - -如果上面的镜像无法拉取,可以尝试使用 GitHub 的 Docker 镜像,将上面的 `justsong/one-api` 替换为 `ghcr.io/songquanpeng/one-api` 即可。 - -如果你的并发量较大,**务必**设置 `SQL_DSN`,详见下面[环境变量](#环境变量)一节。 - -更新命令:`docker run --rm -v /var/run/docker.sock:/var/run/docker.sock containrrr/watchtower -cR` - -Nginx 的参考配置: - -``` -server{ - server_name openai.justsong.cn; # 请根据实际情况修改你的域名 - - location / { - client_max_body_size 64m; - proxy_http_version 1.1; - proxy_pass http://localhost:3000; # 请根据实际情况修改你的端口 - proxy_set_header Host $host; - proxy_set_header X-Forwarded-For $remote_addr; - proxy_cache_bypass $http_upgrade; - proxy_set_header Accept-Encoding gzip; - proxy_read_timeout 300s; # GPT-4 需要较长的超时时间,请自行调整 - } -} -``` - -之后使用 Let's Encrypt 的 certbot 配置 HTTPS: - -```bash -# Ubuntu 安装 certbot: -sudo snap install --classic certbot -sudo ln -s /snap/bin/certbot /usr/bin/certbot -# 生成证书 & 修改 Nginx 配置 -sudo certbot --nginx -# 根据指示进行操作 -# 重启 Nginx -sudo service nginx restart -``` - -初始账号用户名为 `root`,密码为 `123456`。 - -### 基于 Docker Compose 进行部署 - -> 仅启动方式不同,参数设置不变,请参考基于 Docker 部署部分 - -```shell -# 目前支持 MySQL 启动,数据存储在 ./data/mysql 文件夹内 -docker-compose up -d - -# 查看部署状态 -docker-compose ps -``` - -### 手动部署 - -1. 从 [GitHub Releases](https://github.com/songquanpeng/one-api/releases/latest) 下载可执行文件或者从源码编译: - - ```shell - git clone https://github.com/songquanpeng/one-api.git - - # 构建前端 - cd one-api/web - npm install - npm run build - - # 构建后端 - cd .. - go mod download - go build -ldflags "-s -w" -o one-api - ``` - -2. 运行: - ```shell - chmod u+x one-api - ./one-api --port 3000 --log-dir ./logs - ``` -3. 访问 [http://localhost:3000/](http://localhost:3000/) 并登录。初始账号用户名为 `root`,密码为 `123456`。 - -更加详细的部署教程[参见此处](https://iamazing.cn/page/how-to-deploy-a-website)。 - -### 多机部署 - -1. 所有服务器 `SESSION_SECRET` 设置一样的值。 -2. 必须设置 `SQL_DSN`,使用 MySQL 数据库而非 SQLite,所有服务器连接同一个数据库。 -3. 所有从服务器必须设置 `NODE_TYPE` 为 `slave`,不设置则默认为主服务器。 -4. 设置 `SYNC_FREQUENCY` 后服务器将定期从数据库同步配置,在使用远程数据库的情况下,推荐设置该项并启用 Redis,无论主从。 -5. 从服务器可以选择设置 `FRONTEND_BASE_URL`,以重定向页面请求到主服务器。 -6. 从服务器上**分别**装好 Redis,设置好 `REDIS_CONN_STRING`,这样可以做到在缓存未过期的情况下数据库零访问,可以减少延迟。 -7. 如果主服务器访问数据库延迟也比较高,则也需要启用 Redis,并设置 `SYNC_FREQUENCY`,以定期从数据库同步配置。 - -环境变量的具体使用方法详见[此处](#环境变量)。 - -### 宝塔部署教程 - -详见 [#175](https://github.com/songquanpeng/one-api/issues/175)。 - -如果部署后访问出现空白页面,详见 [#97](https://github.com/songquanpeng/one-api/issues/97)。 - -### 部署第三方服务配合 One API 使用 - -> 欢迎 PR 添加更多示例。 - -#### ChatGPT Next Web - -项目主页:https://github.com/Yidadaa/ChatGPT-Next-Web - -```bash -docker run --name chat-next-web -d -p 3001:3000 yidadaa/chatgpt-next-web -``` - -注意修改端口号,之后在页面上设置接口地址(例如:https://openai.justsong.cn/ )和 API Key 即可。 - -#### ChatGPT Web - -项目主页:https://github.com/Chanzhaoyu/chatgpt-web - -```bash -docker run --name chatgpt-web -d -p 3002:3002 -e OPENAI_API_BASE_URL=https://openai.justsong.cn -e OPENAI_API_KEY=sk-xxx chenzhaoyu94/chatgpt-web -``` - -注意修改端口号、`OPENAI_API_BASE_URL` 和 `OPENAI_API_KEY`。 - -#### QChatGPT - QQ 机器人 - -项目主页:https://github.com/RockChinQ/QChatGPT - -根据文档完成部署后,在`config.py`设置配置项`openai_config`的`reverse_proxy`为 One API 后端地址,设置`api_key`为 One API 生成的 key,并在配置项`completion_api_params`的`model`参数设置为 One API 支持的模型名称。 - -可安装 [Switcher 插件](https://github.com/RockChinQ/Switcher)在运行时切换所使用的模型。 - -### 部署到第三方平台 - -