diff --git a/README.md b/README.md index 9272e3d..64752e8 100644 --- a/README.md +++ b/README.md @@ -414,6 +414,29 @@ AI驱动的开源代码知识库与文档协作平台,支持多模型、多数 + + + + + + +
+ + +New-API +
New-API +
+ +🍥 新一代大模型网关与AI资产管理系统,支持多种模型统一调用 + +0.8.7.5 • [官网链接](https://docs.newapi.pro/) + +
+ + + +
+ #### 🎵 多媒体管理 diff --git a/apps/new-api/0.8.7.5-allinone/data.yml b/apps/new-api/0.8.7.5-allinone/data.yml new file mode 100644 index 0000000..659e02f --- /dev/null +++ b/apps/new-api/0.8.7.5-allinone/data.yml @@ -0,0 +1,28 @@ +additionalProperties: + formFields: + - default: newapi + edit: true + envKey: PANEL_DB_NAME + labelEn: Database + labelZh: 数据库名 + random: true + required: true + rule: paramCommon + type: text + - default: newapi + edit: true + envKey: PANEL_DB_ROOT_PASSWORD + labelEn: Password + labelZh: 数据库密码 + random: true + required: true + rule: paramComplexity + type: password + - default: 3000 + edit: true + envKey: PANEL_APP_PORT_HTTP + labelEn: Port + labelZh: 端口 + required: true + rule: paramPort + type: number diff --git a/apps/new-api/0.8.7.5-allinone/docker-compose.yml b/apps/new-api/0.8.7.5-allinone/docker-compose.yml new file mode 100644 index 0000000..9614eea --- /dev/null +++ b/apps/new-api/0.8.7.5-allinone/docker-compose.yml @@ -0,0 +1,59 @@ +services: + new-api: + image: calciumion/new-api:v0.8.7.5 + container_name: ${CONTAINER_NAME} + restart: always + ports: + - ${PANEL_APP_PORT_HTTP}:3000 + networks: + - 1panel-network + command: --log-dir /app/logs + volumes: + - ./data:/data + - ./logs:/app/logs + environment: + - SQL_DSN=root:${PANEL_DB_ROOT_PASSWORD}@tcp(${CONTAINER_NAME}-mysql:3306)/${PANEL_DB_NAME} # 修改此行,或注释掉以使用 SQLite 作为数据库 + - TZ=Asia/Shanghai + - REDIS_CONN_STRING=redis://${CONTAINER_NAME}-redis + - ERROR_LOG_ENABLED=true # 是否启用错误日志记录 + # - STREAMING_TIMEOUT=120 # 流模式无响应超时时间,单位秒,默认120秒,如果出现空补全可以尝试改为更大值 + # - SESSION_SECRET=random_string # 多机部署时设置,必须修改这个随机字符串!!!!!!! + # - NODE_TYPE=slave # Uncomment for slave node in multi-node deployment + # - SYNC_FREQUENCY=60 # Uncomment if regular database syncing is needed + # - FRONTEND_BASE_URL=https://openai.justsong.cn # Uncomment for multi-node deployment with front-end URL + depends_on: + - redis + - mysql + healthcheck: + test: ["CMD-SHELL", "wget -q -O - http://localhost:3000/api/status | grep -o '\"success\":\\s*true' | awk -F: '{print $$2}'"] + interval: 30s + timeout: 10s + retries: 3 + labels: + createdBy: "Apps" + + mysql: + image: mysql:8.2 + container_name: ${CONTAINER_NAME}-mysql + restart: always + volumes: + - mysql_data:/var/lib/mysql + environment: + - MYSQL_ROOT_PASSWORD=${PANEL_DB_ROOT_PASSWORD} # MySQL root用户密码 + - MYSQL_DATABASE=${PANEL_DB_NAME} # 创建的数据库名 + networks: + - 1panel-network + + redis: + image: redis:latest + container_name: ${CONTAINER_NAME}-redis + restart: always + networks: + - 1panel-network + +volumes: + mysql_data: + +networks: + 1panel-network: + external: true diff --git a/apps/new-api/0.8.7.5/data.yml b/apps/new-api/0.8.7.5/data.yml new file mode 100644 index 0000000..47b7d31 --- /dev/null +++ b/apps/new-api/0.8.7.5/data.yml @@ -0,0 +1,17 @@ +additionalProperties: + formFields: + - default: 3000 + edit: true + envKey: PANEL_APP_PORT_HTTP + labelEn: Port + labelZh: 端口 + required: true + rule: paramPort + type: number + - default: Asia/Shanghai + edit: true + envKey: TZ + labelEn: Time Zone + labelZh: 时区 + required: true + type: text diff --git a/apps/new-api/0.8.7.5/docker-compose.yml b/apps/new-api/0.8.7.5/docker-compose.yml new file mode 100644 index 0000000..d050988 --- /dev/null +++ b/apps/new-api/0.8.7.5/docker-compose.yml @@ -0,0 +1,25 @@ +services: + new-api: + image: calciumion/new-api:v0.8.7.5 + container_name: ${CONTAINER_NAME} + restart: always + ports: + - ${PANEL_APP_PORT_HTTP}:3000 + networks: + - 1panel-network + command: --log-dir /app/logs + volumes: + - ./data:/data + - ./logs:/app/logs + environment: + - TZ=${TZ} +# - SESSION_SECRET=${SESSION_SECRET} +# - REDIS_CONN_STRING=redis://redis +# - NODE_TYPE=slave # 多机部署时从节点取消注释该行 +# - SYNC_FREQUENCY=60 # 需要定期从数据库加载数据时取消注释该行 +# - FRONTEND_BASE_URL=https://openai.justsong.cn # 多机部署时从节点取消注释该行 + labels: + createdBy: "Apps" +networks: + 1panel-network: + external: true diff --git a/apps/new-api/README.en.md b/apps/new-api/README.en.md new file mode 100644 index 0000000..9caab0f --- /dev/null +++ b/apps/new-api/README.en.md @@ -0,0 +1,96 @@ +# New API + +🍥 Next-Generation Large Model Gateway and AI Asset Management System + +> The next-generation LLM gateway and AI asset management system supports multiple languages. + +![](https://cdn.jsdelivr.net/gh/xiaoY233/PicList@main/public/assets/New-API-Homepage.png) + +![](https://cdn.jsdelivr.net/gh/xiaoY233/PicList@main/public/assets/New-API-DashBoard.png) + +![](https://img.shields.io/badge/Copyright-arch3rPro-ff9800?style=flat&logo=github&logoColor=white) + +## 📝 Project Description + +> [!NOTE] +> This is an open-source project developed based on [One API](https://github.com/songquanpeng/one-api) + +> [!IMPORTANT] +> - This project is for personal learning purposes only, with no guarantee of stability or technical support. +> - Users must comply with OpenAI's [Terms of Use](https://openai.com/policies/terms-of-use) and **applicable laws and regulations**, and must not use it for illegal purposes. +> - According to the [《Interim Measures for the Management of Generative Artificial Intelligence Services》](http://www.cac.gov.cn/2023-07/13/c_1690898327029107.htm), please do not provide any unregistered generative AI services to the public in China. + +## 📚 Documentation + +For detailed documentation, please visit our official Wiki: [https://docs.newapi.pro/](https://docs.newapi.pro/) + +You can also access the AI-generated DeepWiki: +[![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/QuantumNous/new-api) + +## ✨ Key Features + +New API offers a wide range of features, please refer to [Features Introduction](https://docs.newapi.pro/wiki/features-introduction) for details: + +1. 🎨 Brand new UI interface +2. 🌍 Multi-language support +3. 💰 Online recharge functionality (YiPay) +4. 🔍 Support for querying usage quotas with keys (works with [neko-api-key-tool](https://github.com/Calcium-Ion/neko-api-key-tool)) +5. 🔄 Compatible with the original One API database +6. 💵 Support for pay-per-use model pricing +7. ⚖️ Support for weighted random channel selection +8. 📈 Data dashboard (console) +9. 🔒 Token grouping and model restrictions +10. 🤖 Support for more authorization login methods (LinuxDO, Telegram, OIDC) +11. 🔄 Support for Rerank models (Cohere and Jina), [API Documentation](https://docs.newapi.pro/api/jinaai-rerank) +12. ⚡ Support for OpenAI Realtime API (including Azure channels), [API Documentation](https://docs.newapi.pro/api/openai-realtime) +13. ⚡ Support for Claude Messages format, [API Documentation](https://docs.newapi.pro/api/anthropic-chat) +14. Support for entering chat interface via /chat2link route +15. 🧠 Support for setting reasoning effort through model name suffixes: + 1. OpenAI o-series models + - Add `-high` suffix for high reasoning effort (e.g.: `o3-mini-high`) + - Add `-medium` suffix for medium reasoning effort (e.g.: `o3-mini-medium`) + - Add `-low` suffix for low reasoning effort (e.g.: `o3-mini-low`) + 2. Claude thinking models + - Add `-thinking` suffix to enable thinking mode (e.g.: `claude-3-7-sonnet-20250219-thinking`) +16. 🔄 Thinking-to-content functionality +17. 🔄 Model rate limiting for users +18. 💰 Cache billing support, which allows billing at a set ratio when cache is hit: + 1. Set the `Prompt Cache Ratio` option in `System Settings-Operation Settings` + 2. Set `Prompt Cache Ratio` in the channel, range 0-1, e.g., setting to 0.5 means billing at 50% when cache is hit + 3. Supported channels: + - [x] OpenAI + - [x] Azure + - [x] DeepSeek + - [x] Claude + +## Model Support + +This version supports multiple models, please refer to [API Documentation-Relay Interface](https://docs.newapi.pro/api) for details: + +1. Third-party models **gpts** (gpt-4-gizmo-*) +2. Third-party channel [Midjourney-Proxy(Plus)](https://github.com/novicezk/midjourney-proxy) interface, [API Documentation](https://docs.newapi.pro/api/midjourney-proxy-image) +3. Third-party channel [Suno API](https://github.com/Suno-API/Suno-API) interface, [API Documentation](https://docs.newapi.pro/api/suno-music) +4. Custom channels, supporting full call address input +5. Rerank models ([Cohere](https://cohere.ai/) and [Jina](https://jina.ai/)), [API Documentation](https://docs.newapi.pro/api/jinaai-rerank) +6. Claude Messages format, [API Documentation](https://docs.newapi.pro/api/anthropic-chat) +7. Dify, currently only supports chatflow + +## Environment Variable Configuration + +For detailed configuration instructions, please refer to [Installation Guide-Environment Variables Configuration](https://docs.newapi.pro/installation/environment-variables): + +- `GENERATE_DEFAULT_TOKEN`: Whether to generate initial tokens for newly registered users, default is `false` +- `STREAMING_TIMEOUT`: Streaming response timeout, default is 120 seconds +- `DIFY_DEBUG`: Whether to output workflow and node information for Dify channels, default is `true` +- `FORCE_STREAM_OPTION`: Whether to override client stream_options parameter, default is `true` +- `GET_MEDIA_TOKEN`: Whether to count image tokens, default is `true` +- `GET_MEDIA_TOKEN_NOT_STREAM`: Whether to count image tokens in non-streaming cases, default is `true` +- `UPDATE_TASK`: Whether to update asynchronous tasks (Midjourney, Suno), default is `true` +- `COHERE_SAFETY_SETTING`: Cohere model safety settings, options are `NONE`, `CONTEXTUAL`, `STRICT`, default is `NONE` +- `GEMINI_VISION_MAX_IMAGE_NUM`: Maximum number of images for Gemini models, default is `16` +- `MAX_FILE_DOWNLOAD_MB`: Maximum file download size in MB, default is `20` +- `CRYPTO_SECRET`: Encryption key used for encrypting database content +- `AZURE_DEFAULT_API_VERSION`: Azure channel default API version, default is `2025-04-01-preview` +- `NOTIFICATION_LIMIT_DURATION_MINUTE`: Notification limit duration, default is `10` minutes +- `NOTIFY_LIMIT_COUNT`: Maximum number of user notifications within the specified duration, default is `2` +- `ERROR_LOG_ENABLED=true`: Whether to record and display error logs, default is `false` diff --git a/apps/new-api/README.md b/apps/new-api/README.md new file mode 100644 index 0000000..840bcdc --- /dev/null +++ b/apps/new-api/README.md @@ -0,0 +1,96 @@ +# New-API + +🍥新一代大模型网关与AI资产管理系统 + +> AI模型接口管理与分发系统,支持将多种大模型转为统一格式调用,支持OpenAI、Claude等格式,可供个人或者企业内部管理与分发渠道使用,本项目基于One API二次开发 + +![](https://cdn.jsdelivr.net/gh/xiaoY233/PicList@main/public/assets/New-API-Homepage.png) + +![](https://cdn.jsdelivr.net/gh/xiaoY233/PicList@main/public/assets/New-API-DashBoard.png) + +![](https://img.shields.io/badge/Copyright-arch3rPro-ff9800?style=flat&logo=github&logoColor=white) + +## 📝 项目说明 + +> [!NOTE] +> 本项目为开源项目,在[One API](https://github.com/songquanpeng/one-api)的基础上进行二次开发 + +> [!IMPORTANT] +> - 本项目仅供个人学习使用,不保证稳定性,且不提供任何技术支持。 +> - 使用者必须在遵循 OpenAI 的[使用条款](https://openai.com/policies/terms-of-use)以及**法律法规**的情况下使用,不得用于非法用途。 +> - 根据[《生成式人工智能服务管理暂行办法》](http://www.cac.gov.cn/2023-07/13/c_1690898327029107.htm)的要求,请勿对中国地区公众提供一切未经备案的生成式人工智能服务。 + +## 📚 文档 + +详细文档请访问我们的官方Wiki:[https://docs.newapi.pro/](https://docs.newapi.pro/) + +也可访问AI生成的DeepWiki: +[![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/QuantumNous/new-api) + +## ✨ 主要特性 + +New API提供了丰富的功能,详细特性请参考[特性说明](https://docs.newapi.pro/wiki/features-introduction): + +1. 🎨 全新的UI界面 +2. 🌍 多语言支持 +3. 💰 支持在线充值功能(易支付) +4. 🔍 支持用key查询使用额度(配合[neko-api-key-tool](https://github.com/Calcium-Ion/neko-api-key-tool)) +5. 🔄 兼容原版One API的数据库 +6. 💵 支持模型按次数收费 +7. ⚖️ 支持渠道加权随机 +8. 📈 数据看板(控制台) +9. 🔒 令牌分组、模型限制 +10. 🤖 支持更多授权登陆方式(LinuxDO,Telegram、OIDC) +11. 🔄 支持Rerank模型(Cohere和Jina),[接口文档](https://docs.newapi.pro/api/jinaai-rerank) +12. ⚡ 支持OpenAI Realtime API(包括Azure渠道),[接口文档](https://docs.newapi.pro/api/openai-realtime) +13. ⚡ 支持Claude Messages 格式,[接口文档](https://docs.newapi.pro/api/anthropic-chat) +14. 支持使用路由/chat2link进入聊天界面 +15. 🧠 支持通过模型名称后缀设置 reasoning effort: + 1. OpenAI o系列模型 + - 添加后缀 `-high` 设置为 high reasoning effort (例如: `o3-mini-high`) + - 添加后缀 `-medium` 设置为 medium reasoning effort (例如: `o3-mini-medium`) + - 添加后缀 `-low` 设置为 low reasoning effort (例如: `o3-mini-low`) + 2. Claude 思考模型 + - 添加后缀 `-thinking` 启用思考模式 (例如: `claude-3-7-sonnet-20250219-thinking`) +16. 🔄 思考转内容功能 +17. 🔄 针对用户的模型限流功能 +18. 💰 缓存计费支持,开启后可以在缓存命中时按照设定的比例计费: + 1. 在 `系统设置-运营设置` 中设置 `提示缓存倍率` 选项 + 2. 在渠道中设置 `提示缓存倍率`,范围 0-1,例如设置为 0.5 表示缓存命中时按照 50% 计费 + 3. 支持的渠道: + - [x] OpenAI + - [x] Azure + - [x] DeepSeek + - [x] Claude + +## 模型支持 + +此版本支持多种模型,详情请参考[接口文档-中继接口](https://docs.newapi.pro/api): + +1. 第三方模型 **gpts** (gpt-4-gizmo-*) +2. 第三方渠道[Midjourney-Proxy(Plus)](https://github.com/novicezk/midjourney-proxy)接口,[接口文档](https://docs.newapi.pro/api/midjourney-proxy-image) +3. 第三方渠道[Suno API](https://github.com/Suno-API/Suno-API)接口,[接口文档](https://docs.newapi.pro/api/suno-music) +4. 自定义渠道,支持填入完整调用地址 +5. Rerank模型([Cohere](https://cohere.ai/)和[Jina](https://jina.ai/)),[接口文档](https://docs.newapi.pro/api/jinaai-rerank) +6. Claude Messages 格式,[接口文档](https://docs.newapi.pro/api/anthropic-chat) +7. Dify,当前仅支持chatflow + +## 环境变量配置 + +详细配置说明请参考[安装指南-环境变量配置](https://docs.newapi.pro/installation/environment-variables): + +- `GENERATE_DEFAULT_TOKEN`:是否为新注册用户生成初始令牌,默认为 `false` +- `STREAMING_TIMEOUT`:流式回复超时时间,默认120秒 +- `DIFY_DEBUG`:Dify渠道是否输出工作流和节点信息,默认 `true` +- `FORCE_STREAM_OPTION`:是否覆盖客户端stream_options参数,默认 `true` +- `GET_MEDIA_TOKEN`:是否统计图片token,默认 `true` +- `GET_MEDIA_TOKEN_NOT_STREAM`:非流情况下是否统计图片token,默认 `true` +- `UPDATE_TASK`:是否更新异步任务(Midjourney、Suno),默认 `true` +- `COHERE_SAFETY_SETTING`:Cohere模型安全设置,可选值为 `NONE`, `CONTEXTUAL`, `STRICT`,默认 `NONE` +- `GEMINI_VISION_MAX_IMAGE_NUM`:Gemini模型最大图片数量,默认 `16` +- `MAX_FILE_DOWNLOAD_MB`: 最大文件下载大小,单位MB,默认 `20` +- `CRYPTO_SECRET`:加密密钥,用于加密数据库内容 +- `AZURE_DEFAULT_API_VERSION`:Azure渠道默认API版本,默认 `2025-04-01-preview` +- `NOTIFICATION_LIMIT_DURATION_MINUTE`:通知限制持续时间,默认 `10`分钟 +- `NOTIFY_LIMIT_COUNT`:用户通知在指定持续时间内的最大数量,默认 `2` +- `ERROR_LOG_ENABLED=true`: 是否记录并显示错误日志,默认`false` \ No newline at end of file diff --git a/apps/new-api/data.yml b/apps/new-api/data.yml new file mode 100644 index 0000000..e838aaa --- /dev/null +++ b/apps/new-api/data.yml @@ -0,0 +1,19 @@ +name: New API +tags: + - AI / 大模型 +title: OpenAI 接口管理 & 分发系统 +description: OpenAI 接口管理 & 分发系统 +additionalProperties: + key: new-api + name: New API + tags: + - AI + shortDescZh: AI模型接口管理与分发系统,支持将多种大模型转为OpenAI格式调用、支持Midjourney Proxy、Suno、Rerank,兼容易支付协议,可供个人或者企业内部管理与分发渠道使用,本项目基于One API二次开发。 + shortDescEn: Access all LLM through the standard OpenAI API format, easy to deploy & use + type: tool + crossVersionUpdate: true + limit: 0 + recommend: 0 + website: https://nekoapi.com/ + github: https://github.com/Calcium-Ion/new-api + document: https://github.com/Calcium-Ion/new-api/blob/main/README.md diff --git a/apps/new-api/latest/data.yml b/apps/new-api/latest/data.yml new file mode 100644 index 0000000..47b7d31 --- /dev/null +++ b/apps/new-api/latest/data.yml @@ -0,0 +1,17 @@ +additionalProperties: + formFields: + - default: 3000 + edit: true + envKey: PANEL_APP_PORT_HTTP + labelEn: Port + labelZh: 端口 + required: true + rule: paramPort + type: number + - default: Asia/Shanghai + edit: true + envKey: TZ + labelEn: Time Zone + labelZh: 时区 + required: true + type: text diff --git a/apps/new-api/latest/docker-compose.yml b/apps/new-api/latest/docker-compose.yml new file mode 100644 index 0000000..c6fff4d --- /dev/null +++ b/apps/new-api/latest/docker-compose.yml @@ -0,0 +1,25 @@ +services: + new-api: + image: calciumion/new-api:latest + container_name: ${CONTAINER_NAME} + restart: always + ports: + - ${PANEL_APP_PORT_HTTP}:3000 + networks: + - 1panel-network + command: --log-dir /app/logs + volumes: + - ./data:/data + - ./logs:/app/logs + environment: + - TZ=${TZ} +# - SESSION_SECRET=${SESSION_SECRET} +# - REDIS_CONN_STRING=redis://redis +# - NODE_TYPE=slave # 多机部署时从节点取消注释该行 +# - SYNC_FREQUENCY=60 # 需要定期从数据库加载数据时取消注释该行 +# - FRONTEND_BASE_URL=https://openai.justsong.cn # 多机部署时从节点取消注释该行 + labels: + createdBy: "Apps" +networks: + 1panel-network: + external: true diff --git a/apps/new-api/logo.png b/apps/new-api/logo.png new file mode 100644 index 0000000..851556f Binary files /dev/null and b/apps/new-api/logo.png differ