mirror of
				https://github.com/songquanpeng/one-api.git
				synced 2025-11-04 15:53:42 +08:00 
			
		
		
		
	Compare commits
	
		
			6 Commits
		
	
	
		
			v0.4.8-alp
			...
			v0.4.8
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					9e4109672a | ||
| 
						 | 
					64c35334e6 | ||
| 
						 | 
					0ce572b405 | ||
| 
						 | 
					a326ac4b28 | ||
| 
						 | 
					05b0e77839 | ||
| 
						 | 
					51f19470bc | 
							
								
								
									
										18
									
								
								README.en.md
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								README.en.md
									
									
									
									
									
								
							@@ -57,17 +57,14 @@ _✨ An OpenAI key management & redistribution system, easy to deploy & use ✨_
 | 
			
		||||
> **Note**: The latest image pulled from Docker may be an `alpha` release. Specify the version manually if you require stability.
 | 
			
		||||
 | 
			
		||||
## Features
 | 
			
		||||
1. Supports multiple API access channels. Welcome PRs or issue submissions for additional channels:
 | 
			
		||||
1. Supports multiple API access channels:
 | 
			
		||||
    + [x] Official OpenAI channel (support proxy configuration)
 | 
			
		||||
    + [x] **Azure OpenAI API**
 | 
			
		||||
    + [x] [API Distribute](https://api.gptjk.top/register?aff=QGxj)
 | 
			
		||||
    + [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.
 | 
			
		||||
@@ -174,6 +171,15 @@ Refer to [#175](https://github.com/songquanpeng/one-api/issues/175) for detailed
 | 
			
		||||
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
 | 
			
		||||
<details>
 | 
			
		||||
<summary><strong>Deploy on Sealos</strong></summary>
 | 
			
		||||
<div>
 | 
			
		||||
 | 
			
		||||
Please refer to [this tutorial](https://github.com/c121914yu/FastGPT/blob/main/docs/deploy/one-api/sealos.md).
 | 
			
		||||
 | 
			
		||||
</div>
 | 
			
		||||
</details>
 | 
			
		||||
 | 
			
		||||
<details>
 | 
			
		||||
<summary><strong>Deployment on Zeabur</strong></summary>
 | 
			
		||||
<div>
 | 
			
		||||
@@ -240,7 +246,7 @@ If the channel ID is not provided, load balancing will be used to distribute the
 | 
			
		||||
    + Example: `CHANNEL_UPDATE_FREQUENCY=1440`
 | 
			
		||||
8. `CHANNEL_TEST_FREQUENCY`: When set, it periodically tests the channels, with the unit in minutes. If not set, no test will happen.
 | 
			
		||||
    + Example: `CHANNEL_TEST_FREQUENCY=1440`
 | 
			
		||||
9. `REQUEST_INTERVAL`: The time interval (in seconds) between requests when updating channel balances and testing channel availability. Default is no interval.
 | 
			
		||||
9. `POLLING_INTERVAL`: The time interval (in seconds) between requests when updating channel balances and testing channel availability. Default is no interval.
 | 
			
		||||
    + Example: `POLLING_INTERVAL=5`
 | 
			
		||||
 | 
			
		||||
### Command Line Parameters
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										26
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										26
									
								
								README.md
									
									
									
									
									
								
							@@ -56,22 +56,19 @@ _✨ All in one 的 OpenAI 接口,整合各种 API 访问方式,开箱即用
 | 
			
		||||
> **Warning**:从 `v0.3` 版本升级到 `v0.4` 版本需要手动迁移数据库,请手动执行[数据库迁移脚本](./bin/migration_v0.3-v0.4.sql)。
 | 
			
		||||
 | 
			
		||||
## 功能
 | 
			
		||||
1. 支持多种 API 访问渠道,欢迎 PR 或提 issue 添加更多渠道:
 | 
			
		||||
   + [x] OpenAI 官方通道(支持配置代理)
 | 
			
		||||
1. 支持多种 API 访问渠道:
 | 
			
		||||
   + [x] OpenAI 官方通道(支持配置镜像)
 | 
			
		||||
   + [x] **Azure OpenAI API**
 | 
			
		||||
   + [x] [API Distribute](https://api.gptjk.top/register?aff=QGxj)
 | 
			
		||||
   + [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) (邀请码:`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] 自定义渠道:例如各种未收录的第三方代理服务
 | 
			
		||||
2. 支持通过**负载均衡**的方式访问多个渠道。
 | 
			
		||||
3. 支持 **stream 模式**,可以通过流式传输实现打字机效果。
 | 
			
		||||
4. 支持**多机部署**,[详见此处](#多机部署)。
 | 
			
		||||
5. 支持**令牌管理**,设置令牌的过期时间和使用次数。
 | 
			
		||||
5. 支持**令牌管理**,设置令牌的过期时间和额度。
 | 
			
		||||
6. 支持**兑换码管理**,支持批量生成和导出兑换码,可使用兑换码为账户进行充值。
 | 
			
		||||
7. 支持**通道管理**,批量创建通道。
 | 
			
		||||
8. 支持**用户分组**以及**渠道分组**,支持为不同分组设置不同的倍率。
 | 
			
		||||
@@ -195,6 +192,17 @@ docker run --name chatgpt-web -d -p 3002:3002 -e OPENAI_API_BASE_URL=https://ope
 | 
			
		||||
注意修改端口号、`OPENAI_API_BASE_URL` 和 `OPENAI_API_KEY`。
 | 
			
		||||
 | 
			
		||||
### 部署到第三方平台
 | 
			
		||||
<details>
 | 
			
		||||
<summary><strong>部署到 Sealos </strong></summary>
 | 
			
		||||
<div>
 | 
			
		||||
 | 
			
		||||
> Sealos 可视化部署,仅需 1 分钟。
 | 
			
		||||
 | 
			
		||||
参考这个[教程](https://github.com/c121914yu/FastGPT/blob/main/docs/deploy/one-api/sealos.md)中 1~5 步。
 | 
			
		||||
 | 
			
		||||
</div>
 | 
			
		||||
</details>
 | 
			
		||||
 | 
			
		||||
<details>
 | 
			
		||||
<summary><strong>部署到 Zeabur</strong></summary>
 | 
			
		||||
<div>
 | 
			
		||||
@@ -251,7 +259,7 @@ graph LR
 | 
			
		||||
   + 例子:`SESSION_SECRET=random_string`
 | 
			
		||||
3. `SQL_DSN`:设置之后将使用指定数据库而非 SQLite,请使用 MySQL 8.0 版本。
 | 
			
		||||
   + 例子:`SQL_DSN=root:123456@tcp(localhost:3306)/oneapi`
 | 
			
		||||
4. `FRONTEND_BASE_URL`:设置之后将使用指定的前端地址,而非后端地址。
 | 
			
		||||
4. `FRONTEND_BASE_URL`:设置之后将使用指定的前端地址,而非后端地址,仅限从服务器设置。
 | 
			
		||||
   + 例子:`FRONTEND_BASE_URL=https://openai.justsong.cn`
 | 
			
		||||
5. `SYNC_FREQUENCY`:设置之后将定期与数据库同步配置,单位为秒,未设置则不进行同步。
 | 
			
		||||
   + 例子:`SYNC_FREQUENCY=60`
 | 
			
		||||
@@ -261,7 +269,7 @@ graph LR
 | 
			
		||||
   + 例子:`CHANNEL_UPDATE_FREQUENCY=1440`
 | 
			
		||||
8. `CHANNEL_TEST_FREQUENCY`:设置之后将定期检查渠道,单位为分钟,未设置则不进行检查。
 | 
			
		||||
   + 例子:`CHANNEL_TEST_FREQUENCY=1440`
 | 
			
		||||
9. `REQUEST_INTERVAL`:批量更新渠道余额以及测试可用性时的请求间隔,单位为秒,默认无间隔。
 | 
			
		||||
9. `POLLING_INTERVAL`:批量更新渠道余额以及测试可用性时的请求间隔,单位为秒,默认无间隔。
 | 
			
		||||
   + 例子:`POLLING_INTERVAL=5`
 | 
			
		||||
 | 
			
		||||
### 命令行参数
 | 
			
		||||
 
 | 
			
		||||
@@ -72,7 +72,7 @@ var RootUserEmail = ""
 | 
			
		||||
 | 
			
		||||
var IsMasterNode = os.Getenv("NODE_TYPE") != "slave"
 | 
			
		||||
 | 
			
		||||
var requestInterval, _ = strconv.Atoi(os.Getenv("REQUEST_INTERVAL"))
 | 
			
		||||
var requestInterval, _ = strconv.Atoi(os.Getenv("POLLING_INTERVAL"))
 | 
			
		||||
var RequestInterval = time.Duration(requestInterval) * time.Second
 | 
			
		||||
 | 
			
		||||
const (
 | 
			
		||||
 
 | 
			
		||||
@@ -10,4 +10,4 @@ export const CHANNEL_OPTIONS = [
 | 
			
		||||
  { key: 9, text: 'AI.LS', value: 9, color: 'yellow' },
 | 
			
		||||
  { key: 10, text: 'AI Proxy', value: 10, color: 'purple' },
 | 
			
		||||
  { key: 12, text: 'API2GPT', value: 12, color: 'blue' }
 | 
			
		||||
];
 | 
			
		||||
];
 | 
			
		||||
@@ -4,6 +4,12 @@ import { useParams } from 'react-router-dom';
 | 
			
		||||
import { API, showError, showInfo, showSuccess, verifyJSON } from '../../helpers';
 | 
			
		||||
import { CHANNEL_OPTIONS } from '../../constants';
 | 
			
		||||
 | 
			
		||||
const MODEL_MAPPING_EXAMPLE = {
 | 
			
		||||
  'gpt-3.5-turbo-0301': 'gpt-3.5-turbo',
 | 
			
		||||
  'gpt-4-0314': 'gpt-4',
 | 
			
		||||
  'gpt-4-32k-0314': 'gpt-4-32k'
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
const EditChannel = () => {
 | 
			
		||||
  const params = useParams();
 | 
			
		||||
  const channelId = params.id;
 | 
			
		||||
@@ -15,7 +21,7 @@ const EditChannel = () => {
 | 
			
		||||
    key: '',
 | 
			
		||||
    base_url: '',
 | 
			
		||||
    other: '',
 | 
			
		||||
    model_mapping:'',
 | 
			
		||||
    model_mapping: '',
 | 
			
		||||
    models: [],
 | 
			
		||||
    groups: ['default']
 | 
			
		||||
  };
 | 
			
		||||
@@ -98,7 +104,7 @@ const EditChannel = () => {
 | 
			
		||||
      showInfo('请至少选择一个模型!');
 | 
			
		||||
      return;
 | 
			
		||||
    }
 | 
			
		||||
    if (inputs.model_mapping !== "" && !verifyJSON(inputs.model_mapping)) {
 | 
			
		||||
    if (inputs.model_mapping !== '' && !verifyJSON(inputs.model_mapping)) {
 | 
			
		||||
      showInfo('模型映射必须是合法的 JSON 格式!');
 | 
			
		||||
      return;
 | 
			
		||||
    }
 | 
			
		||||
@@ -257,11 +263,11 @@ const EditChannel = () => {
 | 
			
		||||
          <Form.Field>
 | 
			
		||||
            <Form.TextArea
 | 
			
		||||
              label='模型映射'
 | 
			
		||||
              placeholder={'为一个 JSON 文本,键为用户请求的模型名称,值为要替换的模型名称'}
 | 
			
		||||
              placeholder={`为一个 JSON 文本,键为用户请求的模型名称,值为要替换的模型名称,例如:\n${JSON.stringify(MODEL_MAPPING_EXAMPLE, null, 2)}`}
 | 
			
		||||
              name='model_mapping'
 | 
			
		||||
              onChange={handleInputChange}
 | 
			
		||||
              value={inputs.model_mapping}
 | 
			
		||||
              style={{ minHeight: 100, fontFamily: 'JetBrains Mono, Consolas' }}
 | 
			
		||||
              style={{ minHeight: 150, fontFamily: 'JetBrains Mono, Consolas' }}
 | 
			
		||||
              autoComplete='new-password'
 | 
			
		||||
            />
 | 
			
		||||
          </Form.Field>
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user