diff --git a/README.en.md b/README.en.md deleted file mode 100644 index 97c331ad..00000000 --- a/README.en.md +++ /dev/null @@ -1,466 +0,0 @@ -
- -![new-api](/web/public/logo.png) - -# New API - -🍥 **Next-Generation Large Model Gateway and AI Asset Management System** - -

- 中文 | - English | - Français | - 日本語 -

- -

- - license - - - release - - - docker - - - docker - - - GoReportCard - -

- -

- - Calcium-Ion%2Fnew-api | Trendshift - -
- - Featured|HelloGitHub - - - New API - All-in-one AI asset management gateway. | Product Hunt - -

- -

- Quick Start • - Key Features • - Deployment • - Documentation • - Help -

- -
- -## 📝 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. - ---- - -## 🤝 Trusted Partners - -

- No particular order -

- -

- - Cherry Studio - - - Peking University - - - UCloud - - - Alibaba Cloud - - - IO.NET - -

- ---- - -## 🙏 Special Thanks - -

- - JetBrains Logo - -

- -

- Thanks to JetBrains for providing free open-source development license for this project -

- ---- - -## 🚀 Quick Start - -### Using Docker Compose (Recommended) - -```bash -# Clone the project -git clone https://github.com/QuantumNous/new-api.git -cd new-api - -# Edit docker-compose.yml configuration -nano docker-compose.yml - -# Start the service -docker-compose up -d -``` - -
-Using Docker Commands - -```bash -# Pull the latest image -docker pull calciumion/new-api:latest - -# Using SQLite (default) -docker run --name new-api -d --restart always \ - -p 3000:3000 \ - -e TZ=Asia/Shanghai \ - -v ./data:/data \ - calciumion/new-api:latest - -# Using MySQL -docker run --name new-api -d --restart always \ - -p 3000:3000 \ - -e SQL_DSN="root:123456@tcp(localhost:3306)/oneapi" \ - -e TZ=Asia/Shanghai \ - -v ./data:/data \ - calciumion/new-api:latest -``` - -> **💡 Tip:** `-v ./data:/data` will save data in the `data` folder of the current directory, you can also change it to an absolute path like `-v /your/custom/path:/data` - -
- ---- - -🎉 After deployment is complete, visit `http://localhost:3000` to start using! - -📖 For more deployment methods, please refer to [Deployment Guide](https://docs.newapi.pro/en/docs/installation) - ---- - -## 📚 Documentation - -
- -### 📖 [Official Documentation](https://docs.newapi.pro/en/docs) | [![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/QuantumNous/new-api) - -
- -**Quick Navigation:** - -| Category | Link | -|------|------| -| 🚀 Deployment Guide | [Installation Documentation](https://docs.newapi.pro/en/docs/installation) | -| ⚙️ Environment Configuration | [Environment Variables](https://docs.newapi.pro/en/docs/installation/config-maintenance/environment-variables) | -| 📡 API Documentation | [API Documentation](https://docs.newapi.pro/en/docs/api) | -| ❓ FAQ | [FAQ](https://docs.newapi.pro/en/docs/support/faq) | -| 💬 Community Interaction | [Communication Channels](https://docs.newapi.pro/en/docs/support/community-interaction) | - ---- - -## ✨ Key Features - -> For detailed features, please refer to [Features Introduction](https://docs.newapi.pro/en/docs/guide/wiki/basic-concepts/features-introduction) - -### 🎨 Core Functions - -| Feature | Description | -|------|------| -| 🎨 New UI | Modern user interface design | -| 🌍 Multi-language | Supports Chinese, English, French, Japanese | -| 🔄 Data Compatibility | Fully compatible with the original One API database | -| 📈 Data Dashboard | Visual console and statistical analysis | -| 🔒 Permission Management | Token grouping, model restrictions, user management | - -### 💰 Payment and Billing - -- ✅ Online recharge (EPay, Stripe) -- ✅ Pay-per-use model pricing -- ✅ Cache billing support (OpenAI, Azure, DeepSeek, Claude, Qwen and all supported models) -- ✅ Flexible billing policy configuration - -### 🔐 Authorization and Security - -- 😈 Discord authorization login -- 🤖 LinuxDO authorization login -- 📱 Telegram authorization login -- 🔑 OIDC unified authentication - -### 🚀 Advanced Features - -**API Format Support:** -- ⚡ [OpenAI Responses](https://docs.newapi.pro/en/docs/api/ai-model/chat/openai/create-response) -- ⚡ [OpenAI Realtime API](https://docs.newapi.pro/en/docs/api/ai-model/realtime/create-realtime-session) (including Azure) -- ⚡ [Claude Messages](https://docs.newapi.pro/en/docs/api/ai-model/chat/create-message) -- ⚡ [Google Gemini](https://doc.newapi.pro/en/api/google-gemini-chat) -- 🔄 [Rerank Models](https://docs.newapi.pro/en/docs/api/ai-model/rerank/create-rerank) (Cohere, Jina) - -**Intelligent Routing:** -- ⚖️ Channel weighted random -- 🔄 Automatic retry on failure -- 🚦 User-level model rate limiting - -**Format Conversion:** -- 🔄 **OpenAI Compatible ⇄ Claude Messages** -- 🔄 **OpenAI Compatible → Google Gemini** -- 🔄 **Google Gemini → OpenAI Compatible** - Text only, function calling not supported yet -- 🚧 **OpenAI Compatible ⇄ OpenAI Responses** - In development -- 🔄 **Thinking-to-content functionality** - -**Reasoning Effort Support:** - -
-View detailed configuration - -**OpenAI series models:** -- `o3-mini-high` - High reasoning effort -- `o3-mini-medium` - Medium reasoning effort -- `o3-mini-low` - Low reasoning effort -- `gpt-5-high` - High reasoning effort -- `gpt-5-medium` - Medium reasoning effort -- `gpt-5-low` - Low reasoning effort - -**Claude thinking models:** -- `claude-3-7-sonnet-20250219-thinking` - Enable thinking mode - -**Google Gemini series models:** -- `gemini-2.5-flash-thinking` - Enable thinking mode -- `gemini-2.5-flash-nothinking` - Disable thinking mode -- `gemini-2.5-pro-thinking` - Enable thinking mode -- `gemini-2.5-pro-thinking-128` - Enable thinking mode with thinking budget of 128 tokens -- You can also append `-low`, `-medium`, or `-high` to any Gemini model name to request the corresponding reasoning effort (no extra thinking-budget suffix needed). - -
- ---- - -## 🤖 Model Support - -> For details, please refer to [API Documentation - Relay Interface](https://docs.newapi.pro/en/docs/api) - -| Model Type | Description | Documentation | -|---------|------|------| -| 🤖 OpenAI GPTs | gpt-4-gizmo-* series | - | -| 🎨 Midjourney-Proxy | [Midjourney-Proxy(Plus)](https://github.com/novicezk/midjourney-proxy) | [Documentation](https://doc.newapi.pro/en/api/midjourney-proxy-image) | -| 🎵 Suno-API | [Suno API](https://github.com/Suno-API/Suno-API) | [Documentation](https://doc.newapi.pro/en/api/suno-music) | -| 🔄 Rerank | Cohere, Jina | [Documentation](https://docs.newapi.pro/en/docs/api/ai-model/rerank/create-rerank) | -| 💬 Claude | Messages format | [Documentation](https://docs.newapi.pro/en/docs/api/ai-model/chat/create-message) | -| 🌐 Gemini | Google Gemini format | [Documentation](https://doc.newapi.pro/en/api/google-gemini-chat) | -| 🔧 Dify | ChatFlow mode | - | -| 🎯 Custom | Supports complete call address | - | - -### 📡 Supported Interfaces - -
-View complete interface list - -- [Chat Interface (Chat Completions)](https://docs.newapi.pro/en/docs/api/ai-model/chat/openai/create-chat-completion) -- [Response Interface (Responses)](https://docs.newapi.pro/en/docs/api/ai-model/chat/openai/create-response) -- [Image Interface (Image)](https://docs.newapi.pro/en/docs/api/ai-model/images/openai/v1-images-generations--post) -- [Audio Interface (Audio)](https://docs.newapi.pro/en/docs/api/ai-model/audio/openai/create-transcription) -- [Video Interface (Video)](https://docs.newapi.pro/en/docs/api/ai-model/videos/create-video-generation) -- [Embedding Interface (Embeddings)](https://docs.newapi.pro/en/docs/api/ai-model/embeddings/create-embedding) -- [Rerank Interface (Rerank)](https://docs.newapi.pro/en/docs/api/ai-model/rerank/create-rerank) -- [Realtime Conversation (Realtime)](https://docs.newapi.pro/en/docs/api/ai-model/realtime/create-realtime-session) -- [Claude Chat](https://docs.newapi.pro/en/docs/api/ai-model/chat/create-message) -- [Google Gemini Chat](https://doc.newapi.pro/en/api/google-gemini-chat) - -
- ---- - -## 🚢 Deployment - -> [!TIP] -> **Latest Docker image:** `calciumion/new-api:latest` - -### 📋 Deployment Requirements - -| Component | Requirement | -|------|------| -| **Local database** | SQLite (Docker must mount `/data` directory)| -| **Remote database** | MySQL ≥ 5.7.8 or PostgreSQL ≥ 9.6 | -| **Container engine** | Docker / Docker Compose | - -### ⚙️ Environment Variable Configuration - -
-Common environment variable configuration - -| Variable Name | Description | Default Value | -|--------|------|--------| -| `SESSION_SECRET` | Session secret (required for multi-machine deployment) | - | -| `CRYPTO_SECRET` | Encryption secret (required for Redis) | - | -| `SQL_DSN` | Database connection string | - | -| `REDIS_CONN_STRING` | Redis connection string | - | -| `STREAMING_TIMEOUT` | Streaming timeout (seconds) | `300` | -| `STREAM_SCANNER_MAX_BUFFER_MB` | Max per-line buffer (MB) for the stream scanner; increase when upstream sends huge image/base64 payloads | `64` | -| `MAX_REQUEST_BODY_MB` | Max request body size (MB, counted **after decompression**; prevents huge requests/zip bombs from exhausting memory). Exceeding it returns `413` | `32` | -| `AZURE_DEFAULT_API_VERSION` | Azure API version | `2025-04-01-preview` | -| `ERROR_LOG_ENABLED` | Error log switch | `false` | -| `PYROSCOPE_URL` | Pyroscope server address | - | -| `PYROSCOPE_APP_NAME` | Pyroscope application name | `new-api` | -| `PYROSCOPE_BASIC_AUTH_USER` | Pyroscope basic auth user | - | -| `PYROSCOPE_BASIC_AUTH_PASSWORD` | Pyroscope basic auth password | - | -| `PYROSCOPE_MUTEX_RATE` | Pyroscope mutex sampling rate | `5` | -| `PYROSCOPE_BLOCK_RATE` | Pyroscope block sampling rate | `5` | -| `HOSTNAME` | Hostname tag for Pyroscope | `new-api` | - -📖 **Complete configuration:** [Environment Variables Documentation](https://docs.newapi.pro/en/docs/installation/config-maintenance/environment-variables) - -
- -### 🔧 Deployment Methods - -
-Method 1: Docker Compose (Recommended) - -```bash -# Clone the project -git clone https://github.com/QuantumNous/new-api.git -cd new-api - -# Edit configuration -nano docker-compose.yml - -# Start service -docker-compose up -d -``` - -
- -
-Method 2: Docker Commands - -**Using SQLite:** -```bash -docker run --name new-api -d --restart always \ - -p 3000:3000 \ - -e TZ=Asia/Shanghai \ - -v ./data:/data \ - calciumion/new-api:latest -``` - -**Using MySQL:** -```bash -docker run --name new-api -d --restart always \ - -p 3000:3000 \ - -e SQL_DSN="root:123456@tcp(localhost:3306)/oneapi" \ - -e TZ=Asia/Shanghai \ - -v ./data:/data \ - calciumion/new-api:latest -``` - -> **💡 Path explanation:** -> - `./data:/data` - Relative path, data saved in the data folder of the current directory -> - You can also use absolute path, e.g.: `/your/custom/path:/data` - -
- -
-Method 3: BaoTa Panel - -1. Install BaoTa Panel (≥ 9.2.0 version) -2. Search for **New-API** in the application store -3. One-click installation - -📖 [Tutorial with images](./docs/BT.md) - -
- -### ⚠️ Multi-machine Deployment Considerations - -> [!WARNING] -> - **Must set** `SESSION_SECRET` - Otherwise login status inconsistent -> - **Shared Redis must set** `CRYPTO_SECRET` - Otherwise data cannot be decrypted - -### 🔄 Channel Retry and Cache - -**Retry configuration:** `Settings → Operation Settings → General Settings → Failure Retry Count` - -**Cache configuration:** -- `REDIS_CONN_STRING`: Redis cache (recommended) -- `MEMORY_CACHE_ENABLED`: Memory cache - ---- - -## 🔗 Related Projects - -### Upstream Projects - -| Project | Description | -|------|------| -| [One API](https://github.com/songquanpeng/one-api) | Original project base | -| [Midjourney-Proxy](https://github.com/novicezk/midjourney-proxy) | Midjourney interface support | - -### Supporting Tools - -| Project | Description | -|------|------| -| [neko-api-key-tool](https://github.com/Calcium-Ion/neko-api-key-tool) | Key quota query tool | -| [new-api-horizon](https://github.com/Calcium-Ion/new-api-horizon) | New API high-performance optimized version | - ---- - -## 💬 Help Support - -### 📖 Documentation Resources - -| Resource | Link | -|------|------| -| 📘 FAQ | [FAQ](https://docs.newapi.pro/en/docs/support/faq) | -| 💬 Community Interaction | [Communication Channels](https://docs.newapi.pro/en/docs/support/community-interaction) | -| 🐛 Issue Feedback | [Issue Feedback](https://docs.newapi.pro/en/docs/support/feedback-issues) | -| 📚 Complete Documentation | [Official Documentation](https://docs.newapi.pro/en/docs) | - -### 🤝 Contribution Guide - -Welcome all forms of contribution! - -- 🐛 Report Bugs -- 💡 Propose New Features -- 📝 Improve Documentation -- 🔧 Submit Code - ---- - -## 🌟 Star History - -
- -[![Star History Chart](https://api.star-history.com/svg?repos=Calcium-Ion/new-api&type=Date)](https://star-history.com/#Calcium-Ion/new-api&Date) - -
- ---- - -
- -### 💖 Thank you for using New API - -If this project is helpful to you, welcome to give us a ⭐️ Star! - -**[Official Documentation](https://docs.newapi.pro/en/docs)** • **[Issue Feedback](https://github.com/Calcium-Ion/new-api/issues)** • **[Latest Release](https://github.com/Calcium-Ion/new-api/releases)** - -Built with ❤️ by QuantumNous - -
diff --git a/README.fr.md b/README.fr.md index c7e9419d..27f9f632 100644 --- a/README.fr.md +++ b/README.fr.md @@ -7,8 +7,8 @@ 🍥 **Passerelle de modèles étendus de nouvelle génération et système de gestion d'actifs d'IA**

- 中文 | - English | + 中文 | + English | Français | 日本語

@@ -200,9 +200,11 @@ docker run --name new-api -d --restart always \ ### 🔐 Autorisation et sécurité +- 😈 Connexion par autorisation Discord - 🤖 Connexion par autorisation LinuxDO - 📱 Connexion par autorisation Telegram - 🔑 Authentification unifiée OIDC +- 🔍 Requête de quota d'utilisation de clé (avec [neko-api-key-tool](https://github.com/Calcium-Ion/neko-api-key-tool)) ### 🚀 Fonctionnalités avancées @@ -230,10 +232,13 @@ docker run --name new-api -d --restart always \
Voir la configuration détaillée -**Modèles de la série o d'OpenAI:** +**Modèles de la série OpenAI :** - `o3-mini-high` - Effort de raisonnement élevé - `o3-mini-medium` - Effort de raisonnement moyen - `o3-mini-low` - Effort de raisonnement faible +- `gpt-5-high` - Effort de raisonnement élevé +- `gpt-5-medium` - Effort de raisonnement moyen +- `gpt-5-low` - Effort de raisonnement faible **Modèles de pensée de Claude:** - `claude-3-7-sonnet-20250219-thinking` - Activer le mode de pensée @@ -375,8 +380,9 @@ docker run --name new-api -d --restart always \
Méthode 3: Panneau BaoTa -1. Installez le panneau BaoTa (version **9.2.0** ou supérieure), recherchez **New-API** dans le magasin d'applications et installez-le. -2. Recherchez **New-API** dans le magasin d'applications et installez-le. +1. Installez le panneau BaoTa (version ≥ 9.2.0) +2. Recherchez **New-API** dans le magasin d'applications +3. Installation en un clic 📖 [Tutoriel avec des images](./docs/BT.md) @@ -412,6 +418,7 @@ docker run --name new-api -d --restart always \ | Projet | Description | |------|------| | [neko-api-key-tool](https://github.com/Calcium-Ion/neko-api-key-tool) | Outil de recherche de quota d'utilisation avec une clé | +| [new-api-horizon](https://github.com/Calcium-Ion/new-api-horizon) | Version optimisée haute performance de New API | --- diff --git a/README.ja.md b/README.ja.md index 1edf9460..da3ad3bc 100644 --- a/README.ja.md +++ b/README.ja.md @@ -7,8 +7,8 @@ 🍥 **次世代大規模モデルゲートウェイとAI資産管理システム**

- 中文 | - English | + 中文 | + English | Français | 日本語

@@ -200,9 +200,11 @@ docker run --name new-api -d --restart always \ ### 🔐 認証とセキュリティ +- 😈 Discord認証ログイン - 🤖 LinuxDO認証ログイン - 📱 Telegram認証ログイン - 🔑 OIDC統一認証 +- 🔍 Key使用量クォータ照会([neko-api-key-tool](https://github.com/Calcium-Ion/neko-api-key-tool)と併用) @@ -213,10 +215,6 @@ docker run --name new-api -d --restart always \ - ⚡ [OpenAI Realtime API](https://docs.newapi.pro/ja/docs/api/ai-model/realtime/create-realtime-session)(Azureを含む) - ⚡ [Claude Messages](https://docs.newapi.pro/ja/docs/api/ai-model/chat/create-message) - ⚡ [Google Gemini](https://doc.newapi.pro/ja/api/google-gemini-chat) -- 🔄 [Rerankモデル](https://docs.newapi.pro/ja/docs/api/ai-model/rerank/create-rerank) -- ⚡ [OpenAI Realtime API](https://docs.newapi.pro/ja/docs/api/ai-model/realtime/create-realtime-session) -- ⚡ [Claude Messages](https://docs.newapi.pro/ja/docs/api/ai-model/chat/create-message) -- ⚡ [Google Gemini](https://doc.newapi.pro/ja/api/google-gemini-chat) - 🔄 [Rerankモデル](https://docs.newapi.pro/ja/docs/api/ai-model/rerank/create-rerank)(Cohere、Jina) **インテリジェントルーティング:** diff --git a/README.md b/README.md index b67dc929..e4e39438 100644 --- a/README.md +++ b/README.md @@ -4,11 +4,11 @@ # New API -🍥 **新一代大模型网关与AI资产管理系统** +🍥 **Next-Generation LLM Gateway and AI Asset Management System**

- 中文 | - English | + 中文 | + English | Français | 日本語

@@ -45,31 +45,31 @@

- 快速开始 • - 主要特性 • - 部署 • - 文档 • - 帮助 + Quick Start • + Key Features • + Deployment • + Documentation • + Help

-## 📝 项目说明 +## 📝 Project Description > [!NOTE] -> 本项目为开源项目,在 [One API](https://github.com/songquanpeng/one-api) 的基础上进行二次开发 +> This is an open-source project developed based on [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) 的要求,请勿对中国地区公众提供一切未经备案的生成式人工智能服务 +> - 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. --- -## 🤝 我们信任的合作伙伴 +## 🤝 Trusted Partners

- 排名不分先后 + No particular order

@@ -77,13 +77,13 @@ Cherry Studio - 北京大学 + Peking University - UCloud 优刻得 + UCloud - 阿里云 + Alibaba Cloud IO.NET @@ -92,7 +92,7 @@ --- -## 🙏 特别鸣谢 +## 🙏 Special Thanks

@@ -101,42 +101,42 @@

- 感谢 JetBrains 为本项目提供免费的开源开发许可证 + Thanks to JetBrains for providing free open-source development license for this project

--- -## 🚀 快速开始 +## 🚀 Quick Start -### 使用 Docker Compose(推荐) +### Using Docker Compose (Recommended) ```bash -# 克隆项目 +# Clone the project git clone https://github.com/QuantumNous/new-api.git cd new-api -# 编辑 docker-compose.yml 配置 +# Edit docker-compose.yml configuration nano docker-compose.yml -# 启动服务 +# Start the service docker-compose up -d ```
-使用 Docker 命令 +Using Docker Commands ```bash -# 拉取最新镜像 +# Pull the latest image docker pull calciumion/new-api:latest -# 使用 SQLite(默认) +# Using SQLite (default) docker run --name new-api -d --restart always \ -p 3000:3000 \ -e TZ=Asia/Shanghai \ -v ./data:/data \ calciumion/new-api:latest -# 使用 MySQL +# Using MySQL docker run --name new-api -d --restart always \ -p 3000:3000 \ -e SQL_DSN="root:123456@tcp(localhost:3306)/oneapi" \ @@ -145,94 +145,94 @@ docker run --name new-api -d --restart always \ calciumion/new-api:latest ``` -> **💡 提示:** `-v ./data:/data` 会将数据保存在当前目录的 `data` 文件夹中,你也可以改为绝对路径如 `-v /your/custom/path:/data` +> **💡 Tip:** `-v ./data:/data` will save data in the `data` folder of the current directory, you can also change it to an absolute path like `-v /your/custom/path:/data`
--- -🎉 部署完成后,访问 `http://localhost:3000` 即可使用! +🎉 After deployment is complete, visit `http://localhost:3000` to start using! -📖 更多部署方式请参考 [部署指南](https://docs.newapi.pro/zh/docs/installation) +📖 For more deployment methods, please refer to [Deployment Guide](https://docs.newapi.pro/en/docs/installation) --- -## 📚 文档 +## 📚 Documentation
-### 📖 [官方文档](https://docs.newapi.pro/zh/docs) | [![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/QuantumNous/new-api) +### 📖 [Official Documentation](https://docs.newapi.pro/en/docs) | [![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/QuantumNous/new-api)
-**快速导航:** +**Quick Navigation:** -| 分类 | 链接 | +| Category | Link | |------|------| -| 🚀 部署指南 | [安装文档](https://docs.newapi.pro/zh/docs/installation) | -| ⚙️ 环境配置 | [环境变量](https://docs.newapi.pro/zh/docs/installation/config-maintenance/environment-variables) | -| 📡 接口文档 | [API 文档](https://docs.newapi.pro/zh/docs/api) | -| ❓ 常见问题 | [FAQ](https://docs.newapi.pro/zh/docs/support/faq) | -| 💬 社区交流 | [交流渠道](https://docs.newapi.pro/zh/docs/support/community-interaction) | +| 🚀 Deployment Guide | [Installation Documentation](https://docs.newapi.pro/en/docs/installation) | +| ⚙️ Environment Configuration | [Environment Variables](https://docs.newapi.pro/en/docs/installation/config-maintenance/environment-variables) | +| 📡 API Documentation | [API Documentation](https://docs.newapi.pro/en/docs/api) | +| ❓ FAQ | [FAQ](https://docs.newapi.pro/en/docs/support/faq) | +| 💬 Community Interaction | [Communication Channels](https://docs.newapi.pro/en/docs/support/community-interaction) | --- -## ✨ 主要特性 +## ✨ Key Features -> 详细特性请参考 [特性说明](https://docs.newapi.pro/zh/docs/guide/wiki/basic-concepts/features-introduction) +> For detailed features, please refer to [Features Introduction](https://docs.newapi.pro/en/docs/guide/wiki/basic-concepts/features-introduction) -### 🎨 核心功能 +### 🎨 Core Functions -| 特性 | 说明 | +| Feature | Description | |------|------| -| 🎨 全新 UI | 现代化的用户界面设计 | -| 🌍 多语言 | 支持中文、英文、法语、日语 | -| 🔄 数据兼容 | 完全兼容原版 One API 数据库 | -| 📈 数据看板 | 可视化控制台与统计分析 | -| 🔒 权限管理 | 令牌分组、模型限制、用户管理 | +| 🎨 New UI | Modern user interface design | +| 🌍 Multi-language | Supports Chinese, English, French, Japanese | +| 🔄 Data Compatibility | Fully compatible with the original One API database | +| 📈 Data Dashboard | Visual console and statistical analysis | +| 🔒 Permission Management | Token grouping, model restrictions, user management | -### 💰 支付与计费 +### 💰 Payment and Billing -- ✅ 在线充值(易支付、Stripe) -- ✅ 模型按次数收费 -- ✅ 缓存计费支持(OpenAI、Azure、DeepSeek、Claude、Qwen等所有支持的模型) -- ✅ 灵活的计费策略配置 +- ✅ Online recharge (EPay, Stripe) +- ✅ Pay-per-use model pricing +- ✅ Cache billing support (OpenAI, Azure, DeepSeek, Claude, Qwen and all supported models) +- ✅ Flexible billing policy configuration -### 🔐 授权与安全 +### 🔐 Authorization and Security -- 😈 Discord 授权登录 -- 🤖 LinuxDO 授权登录 -- 📱 Telegram 授权登录 -- 🔑 OIDC 统一认证 -- 🔍 Key 查询使用额度(配合 [neko-api-key-tool](https://github.com/Calcium-Ion/neko-api-key-tool)) +- 😈 Discord authorization login +- 🤖 LinuxDO authorization login +- 📱 Telegram authorization login +- 🔑 OIDC unified authentication +- 🔍 Key quota query usage (with [neko-api-key-tool](https://github.com/Calcium-Ion/neko-api-key-tool)) -### 🚀 高级功能 +### 🚀 Advanced Features -**API 格式支持:** -- ⚡ [OpenAI Responses](https://docs.newapi.pro/zh/docs/api/ai-model/chat/openai/create-response) -- ⚡ [OpenAI Realtime API](https://docs.newapi.pro/zh/docs/api/ai-model/realtime/create-realtime-session)(含 Azure) -- ⚡ [Claude Messages](https://docs.newapi.pro/zh/docs/api/ai-model/chat/create-message) -- ⚡ [Google Gemini](https://doc.newapi.pro/api/google-gemini-chat) -- 🔄 [Rerank 模型](https://docs.newapi.pro/zh/docs/api/ai-model/rerank/create-rerank)(Cohere、Jina) +**API Format Support:** +- ⚡ [OpenAI Responses](https://docs.newapi.pro/en/docs/api/ai-model/chat/openai/create-response) +- ⚡ [OpenAI Realtime API](https://docs.newapi.pro/en/docs/api/ai-model/realtime/create-realtime-session) (including Azure) +- ⚡ [Claude Messages](https://docs.newapi.pro/en/docs/api/ai-model/chat/create-message) +- ⚡ [Google Gemini](https://doc.newapi.pro/en/api/google-gemini-chat) +- 🔄 [Rerank Models](https://docs.newapi.pro/en/docs/api/ai-model/rerank/create-rerank) (Cohere, Jina) -**智能路由:** -- ⚖️ 渠道加权随机 -- 🔄 失败自动重试 -- 🚦 用户级别模型限流 +**Intelligent Routing:** +- ⚖️ Channel weighted random +- 🔄 Automatic retry on failure +- 🚦 User-level model rate limiting -**格式转换:** +**Format Conversion:** - 🔄 **OpenAI Compatible ⇄ Claude Messages** - 🔄 **OpenAI Compatible → Google Gemini** -- 🔄 **Google Gemini → OpenAI Compatible** - 仅支持文本,暂不支持函数调用 -- 🚧 **OpenAI Compatible ⇄ OpenAI Responses** - 开发中 -- 🔄 **思考转内容功能** +- 🔄 **Google Gemini → OpenAI Compatible** - Text only, function calling not supported yet +- 🚧 **OpenAI Compatible ⇄ OpenAI Responses** - In development +- 🔄 **Thinking-to-content functionality** -**Reasoning Effort 支持:** +**Reasoning Effort Support:**
-查看详细配置 +View detailed configuration -**OpenAI 系列模型:** +**OpenAI series models:** - `o3-mini-high` - High reasoning effort - `o3-mini-medium` - Medium reasoning effort - `o3-mini-low` - Low reasoning effort @@ -240,119 +240,119 @@ docker run --name new-api -d --restart always \ - `gpt-5-medium` - Medium reasoning effort - `gpt-5-low` - Low reasoning effort -**Claude 思考模型:** -- `claude-3-7-sonnet-20250219-thinking` - 启用思考模式 +**Claude thinking models:** +- `claude-3-7-sonnet-20250219-thinking` - Enable thinking mode -**Google Gemini 系列模型:** -- `gemini-2.5-flash-thinking` - 启用思考模式 -- `gemini-2.5-flash-nothinking` - 禁用思考模式 -- `gemini-2.5-pro-thinking` - 启用思考模式 -- `gemini-2.5-pro-thinking-128` - 启用思考模式,并设置思考预算为128tokens -- 也可以直接在 Gemini 模型名称后追加 `-low` / `-medium` / `-high` 来控制思考力度(无需再设置思考预算后缀) +**Google Gemini series models:** +- `gemini-2.5-flash-thinking` - Enable thinking mode +- `gemini-2.5-flash-nothinking` - Disable thinking mode +- `gemini-2.5-pro-thinking` - Enable thinking mode +- `gemini-2.5-pro-thinking-128` - Enable thinking mode with thinking budget of 128 tokens +- You can also append `-low`, `-medium`, or `-high` to any Gemini model name to request the corresponding reasoning effort (no extra thinking-budget suffix needed).
--- -## 🤖 模型支持 +## 🤖 Model Support -> 详情请参考 [接口文档 - 中继接口](https://docs.newapi.pro/zh/docs/api) +> For details, please refer to [API Documentation - Relay Interface](https://docs.newapi.pro/en/docs/api) -| 模型类型 | 说明 | 文档 | +| Model Type | Description | Documentation | |---------|------|------| -| 🤖 OpenAI GPTs | gpt-4-gizmo-* 系列 | - | -| 🎨 Midjourney-Proxy | [Midjourney-Proxy(Plus)](https://github.com/novicezk/midjourney-proxy) | [文档](https://doc.newapi.pro/api/midjourney-proxy-image) | -| 🎵 Suno-API | [Suno API](https://github.com/Suno-API/Suno-API) | [文档](https://doc.newapi.pro/api/suno-music) | -| 🔄 Rerank | Cohere、Jina | [文档](https://docs.newapi.pro/zh/docs/api/ai-model/rerank/create-rerank) | -| 💬 Claude | Messages 格式 | [文档](https://docs.newapi.pro/zh/docs/api/ai-model/chat/create-message) | -| 🌐 Gemini | Google Gemini 格式 | [文档](https://doc.newapi.pro/api/google-gemini-chat) | -| 🔧 Dify | ChatFlow 模式 | - | -| 🎯 自定义 | 支持完整调用地址 | - | +| 🤖 OpenAI GPTs | gpt-4-gizmo-* series | - | +| 🎨 Midjourney-Proxy | [Midjourney-Proxy(Plus)](https://github.com/novicezk/midjourney-proxy) | [Documentation](https://doc.newapi.pro/en/api/midjourney-proxy-image) | +| 🎵 Suno-API | [Suno API](https://github.com/Suno-API/Suno-API) | [Documentation](https://doc.newapi.pro/en/api/suno-music) | +| 🔄 Rerank | Cohere, Jina | [Documentation](https://docs.newapi.pro/en/docs/api/ai-model/rerank/create-rerank) | +| 💬 Claude | Messages format | [Documentation](https://docs.newapi.pro/en/docs/api/ai-model/chat/create-message) | +| 🌐 Gemini | Google Gemini format | [Documentation](https://doc.newapi.pro/en/api/google-gemini-chat) | +| 🔧 Dify | ChatFlow mode | - | +| 🎯 Custom | Supports complete call address | - | -### 📡 支持的接口 +### 📡 Supported Interfaces
-查看完整接口列表 +View complete interface list -- [聊天接口 (Chat Completions)](https://docs.newapi.pro/zh/docs/api/ai-model/chat/openai/create-chat-completion) -- [响应接口 (Responses)](https://docs.newapi.pro/zh/docs/api/ai-model/chat/openai/create-response) -- [图像接口 (Image)](https://docs.newapi.pro/zh/docs/api/ai-model/images/openai/v1-images-generations--post) -- [音频接口 (Audio)](https://docs.newapi.pro/zh/docs/api/ai-model/audio/openai/create-transcription) -- [视频接口 (Video)](https://docs.newapi.pro/zh/docs/api/ai-model/videos/create-video-generation) -- [嵌入接口 (Embeddings)](https://docs.newapi.pro/zh/docs/api/ai-model/embeddings/create-embedding) -- [重排序接口 (Rerank)](https://docs.newapi.pro/zh/docs/api/ai-model/rerank/create-rerank) -- [实时对话 (Realtime)](https://docs.newapi.pro/zh/docs/api/ai-model/realtime/create-realtime-session) -- [Claude 聊天](https://docs.newapi.pro/zh/docs/api/ai-model/chat/create-message) -- [Google Gemini 聊天](https://doc.newapi.pro/api/google-gemini-chat) +- [Chat Interface (Chat Completions)](https://docs.newapi.pro/en/docs/api/ai-model/chat/openai/create-chat-completion) +- [Response Interface (Responses)](https://docs.newapi.pro/en/docs/api/ai-model/chat/openai/create-response) +- [Image Interface (Image)](https://docs.newapi.pro/en/docs/api/ai-model/images/openai/v1-images-generations--post) +- [Audio Interface (Audio)](https://docs.newapi.pro/en/docs/api/ai-model/audio/openai/create-transcription) +- [Video Interface (Video)](https://docs.newapi.pro/en/docs/api/ai-model/videos/create-video-generation) +- [Embedding Interface (Embeddings)](https://docs.newapi.pro/en/docs/api/ai-model/embeddings/create-embedding) +- [Rerank Interface (Rerank)](https://docs.newapi.pro/en/docs/api/ai-model/rerank/create-rerank) +- [Realtime Conversation (Realtime)](https://docs.newapi.pro/en/docs/api/ai-model/realtime/create-realtime-session) +- [Claude Chat](https://docs.newapi.pro/en/docs/api/ai-model/chat/create-message) +- [Google Gemini Chat](https://doc.newapi.pro/en/api/google-gemini-chat)
--- -## 🚢 部署 +## 🚢 Deployment > [!TIP] -> **最新版 Docker 镜像:** `calciumion/new-api:latest` +> **Latest Docker image:** `calciumion/new-api:latest` -### 📋 部署要求 +### 📋 Deployment Requirements -| 组件 | 要求 | +| Component | Requirement | |------|------| -| **本地数据库** | SQLite(Docker 需挂载 `/data` 目录)| -| **远程数据库** | MySQL ≥ 5.7.8 或 PostgreSQL ≥ 9.6 | -| **容器引擎** | Docker / Docker Compose | +| **Local database** | SQLite (Docker must mount `/data` directory)| +| **Remote database** | MySQL ≥ 5.7.8 or PostgreSQL ≥ 9.6 | +| **Container engine** | Docker / Docker Compose | -### ⚙️ 环境变量配置 +### ⚙️ Environment Variable Configuration
-常用环境变量配置 +Common environment variable configuration -| 变量名 | 说明 | 默认值 | -|--------|--------------------------------------------------------------|--------| -| `SESSION_SECRET` | 会话密钥(多机部署必须) | - | -| `CRYPTO_SECRET` | 加密密钥(Redis 必须) | - | -| `SQL_DSN` | 数据库连接字符串 | - | -| `REDIS_CONN_STRING` | Redis 连接字符串 | - | -| `STREAMING_TIMEOUT` | 流式超时时间(秒) | `300` | -| `STREAM_SCANNER_MAX_BUFFER_MB` | 流式扫描器单行最大缓冲(MB),图像生成等超大 `data:` 片段(如 4K 图片 base64)需适当调大 | `64` | -| `MAX_REQUEST_BODY_MB` | 请求体最大大小(MB,**解压后**计;防止超大请求/zip bomb 导致内存暴涨),超过将返回 `413` | `32` | -| `AZURE_DEFAULT_API_VERSION` | Azure API 版本 | `2025-04-01-preview` | -| `ERROR_LOG_ENABLED` | 错误日志开关 | `false` | -| `PYROSCOPE_URL` | Pyroscope 服务地址 | - | -| `PYROSCOPE_APP_NAME` | Pyroscope 应用名 | `new-api` | -| `PYROSCOPE_BASIC_AUTH_USER` | Pyroscope Basic Auth 用户名 | - | -| `PYROSCOPE_BASIC_AUTH_PASSWORD` | Pyroscope Basic Auth 密码 | - | -| `PYROSCOPE_MUTEX_RATE` | Pyroscope mutex 采样率 | `5` | -| `PYROSCOPE_BLOCK_RATE` | Pyroscope block 采样率 | `5` | -| `HOSTNAME` | Pyroscope 标签里的主机名 | `new-api` | +| Variable Name | Description | Default Value | +|--------|------|--------| +| `SESSION_SECRET` | Session secret (required for multi-machine deployment) | - | +| `CRYPTO_SECRET` | Encryption secret (required for Redis) | - | +| `SQL_DSN` | Database connection string | - | +| `REDIS_CONN_STRING` | Redis connection string | - | +| `STREAMING_TIMEOUT` | Streaming timeout (seconds) | `300` | +| `STREAM_SCANNER_MAX_BUFFER_MB` | Max per-line buffer (MB) for the stream scanner; increase when upstream sends huge image/base64 payloads | `64` | +| `MAX_REQUEST_BODY_MB` | Max request body size (MB, counted **after decompression**; prevents huge requests/zip bombs from exhausting memory). Exceeding it returns `413` | `32` | +| `AZURE_DEFAULT_API_VERSION` | Azure API version | `2025-04-01-preview` | +| `ERROR_LOG_ENABLED` | Error log switch | `false` | +| `PYROSCOPE_URL` | Pyroscope server address | - | +| `PYROSCOPE_APP_NAME` | Pyroscope application name | `new-api` | +| `PYROSCOPE_BASIC_AUTH_USER` | Pyroscope basic auth user | - | +| `PYROSCOPE_BASIC_AUTH_PASSWORD` | Pyroscope basic auth password | - | +| `PYROSCOPE_MUTEX_RATE` | Pyroscope mutex sampling rate | `5` | +| `PYROSCOPE_BLOCK_RATE` | Pyroscope block sampling rate | `5` | +| `HOSTNAME` | Hostname tag for Pyroscope | `new-api` | -📖 **完整配置:** [环境变量文档](https://docs.newapi.pro/zh/docs/installation/config-maintenance/environment-variables) +📖 **Complete configuration:** [Environment Variables Documentation](https://docs.newapi.pro/en/docs/installation/config-maintenance/environment-variables)
-### 🔧 部署方式 +### 🔧 Deployment Methods
-方式 1:Docker Compose(推荐) +Method 1: Docker Compose (Recommended) ```bash -# 克隆项目 +# Clone the project git clone https://github.com/QuantumNous/new-api.git cd new-api -# 编辑配置 +# Edit configuration nano docker-compose.yml -# 启动服务 +# Start service docker-compose up -d ```
-方式 2:Docker 命令 +Method 2: Docker Commands -**使用 SQLite:** +**Using SQLite:** ```bash docker run --name new-api -d --restart always \ -p 3000:3000 \ @@ -361,7 +361,7 @@ docker run --name new-api -d --restart always \ calciumion/new-api:latest ``` -**使用 MySQL:** +**Using MySQL:** ```bash docker run --name new-api -d --restart always \ -p 3000:3000 \ @@ -371,76 +371,76 @@ docker run --name new-api -d --restart always \ calciumion/new-api:latest ``` -> **💡 路径说明:** -> - `./data:/data` - 相对路径,数据保存在当前目录的 data 文件夹 -> - 也可使用绝对路径,如:`/your/custom/path:/data` +> **💡 Path explanation:** +> - `./data:/data` - Relative path, data saved in the data folder of the current directory +> - You can also use absolute path, e.g.: `/your/custom/path:/data`
-方式 3:宝塔面板 +Method 3: BaoTa Panel -1. 安装宝塔面板(≥ 9.2.0 版本) -2. 在应用商店搜索 **New-API** -3. 一键安装 +1. Install BaoTa Panel (≥ 9.2.0 version) +2. Search for **New-API** in the application store +3. One-click installation -📖 [图文教程](./docs/BT.md) +📖 [Tutorial with images](./docs/BT.md)
-### ⚠️ 多机部署注意事项 +### ⚠️ Multi-machine Deployment Considerations > [!WARNING] -> - **必须设置** `SESSION_SECRET` - 否则登录状态不一致 -> - **公用 Redis 必须设置** `CRYPTO_SECRET` - 否则数据无法解密 +> - **Must set** `SESSION_SECRET` - Otherwise login status inconsistent +> - **Shared Redis must set** `CRYPTO_SECRET` - Otherwise data cannot be decrypted -### 🔄 渠道重试与缓存 +### 🔄 Channel Retry and Cache -**重试配置:** `设置 → 运营设置 → 通用设置 → 失败重试次数` +**Retry configuration:** `Settings → Operation Settings → General Settings → Failure Retry Count` -**缓存配置:** -- `REDIS_CONN_STRING`:Redis 缓存(推荐) -- `MEMORY_CACHE_ENABLED`:内存缓存 +**Cache configuration:** +- `REDIS_CONN_STRING`: Redis cache (recommended) +- `MEMORY_CACHE_ENABLED`: Memory cache --- -## 🔗 相关项目 +## 🔗 Related Projects -### 上游项目 +### Upstream Projects -| 项目 | 说明 | +| Project | Description | |------|------| -| [One API](https://github.com/songquanpeng/one-api) | 原版项目基础 | -| [Midjourney-Proxy](https://github.com/novicezk/midjourney-proxy) | Midjourney 接口支持 | +| [One API](https://github.com/songquanpeng/one-api) | Original project base | +| [Midjourney-Proxy](https://github.com/novicezk/midjourney-proxy) | Midjourney interface support | -### 配套工具 +### Supporting Tools -| 项目 | 说明 | +| Project | Description | |------|------| -| [neko-api-key-tool](https://github.com/Calcium-Ion/neko-api-key-tool) | Key 额度查询工具 | -| [new-api-horizon](https://github.com/Calcium-Ion/new-api-horizon) | New API 高性能优化版 | +| [neko-api-key-tool](https://github.com/Calcium-Ion/neko-api-key-tool) | Key quota query tool | +| [new-api-horizon](https://github.com/Calcium-Ion/new-api-horizon) | New API high-performance optimized version | --- -## 💬 帮助支持 +## 💬 Help Support -### 📖 文档资源 +### 📖 Documentation Resources -| 资源 | 链接 | +| Resource | Link | |------|------| -| 📘 常见问题 | [FAQ](https://docs.newapi.pro/zh/docs/support/faq) | -| 💬 社区交流 | [交流渠道](https://docs.newapi.pro/zh/docs/support/community-interaction) | -| 🐛 反馈问题 | [问题反馈](https://docs.newapi.pro/zh/docs/support/feedback-issues) | -| 📚 完整文档 | [官方文档](https://docs.newapi.pro/zh/docs) | +| 📘 FAQ | [FAQ](https://docs.newapi.pro/en/docs/support/faq) | +| 💬 Community Interaction | [Communication Channels](https://docs.newapi.pro/en/docs/support/community-interaction) | +| 🐛 Issue Feedback | [Issue Feedback](https://docs.newapi.pro/en/docs/support/feedback-issues) | +| 📚 Complete Documentation | [Official Documentation](https://docs.newapi.pro/en/docs) | -### 🤝 贡献指南 +### 🤝 Contribution Guide -欢迎各种形式的贡献! +Welcome all forms of contribution! -- 🐛 报告 Bug -- 💡 提出新功能 -- 📝 改进文档 -- 🔧 提交代码 +- 🐛 Report Bugs +- 💡 Propose New Features +- 📝 Improve Documentation +- 🔧 Submit Code --- @@ -456,11 +456,11 @@ docker run --name new-api -d --restart always \
-### 💖 感谢使用 New API +### 💖 Thank you for using New API -如果这个项目对你有帮助,欢迎给我们一个 ⭐️ Star! +If this project is helpful to you, welcome to give us a ⭐️ Star! -**[官方文档](https://docs.newapi.pro/zh/docs)** • **[问题反馈](https://github.com/Calcium-Ion/new-api/issues)** • **[最新发布](https://github.com/Calcium-Ion/new-api/releases)** +**[Official Documentation](https://docs.newapi.pro/en/docs)** • **[Issue Feedback](https://github.com/Calcium-Ion/new-api/issues)** • **[Latest Release](https://github.com/Calcium-Ion/new-api/releases)** Built with ❤️ by QuantumNous diff --git a/README.zh.md b/README.zh.md new file mode 100644 index 00000000..892dd24a --- /dev/null +++ b/README.zh.md @@ -0,0 +1,467 @@ +
+ +![new-api](/web/public/logo.png) + +# New API + +🍥 **新一代大模型网关与AI资产管理系统** + +

+ 中文 | + English | + Français | + 日本語 +

+ +

+ + license + + + release + + + docker + + + docker + + + GoReportCard + +

+ +

+ + Calcium-Ion%2Fnew-api | Trendshift + +
+ + Featured|HelloGitHub + + + New API - All-in-one AI asset management gateway. | Product Hunt + +

+ +

+ 快速开始 • + 主要特性 • + 部署 • + 文档 • + 帮助 +

+ +
+ +## 📝 项目说明 + +> [!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) 的要求,请勿对中国地区公众提供一切未经备案的生成式人工智能服务 + +--- + +## 🤝 我们信任的合作伙伴 + +

+ 排名不分先后 +

+ +

+ + Cherry Studio + + + 北京大学 + + + UCloud 优刻得 + + + 阿里云 + + + IO.NET + +

+ +--- + +## 🙏 特别鸣谢 + +

+ + JetBrains Logo + +

+ +

+ 感谢 JetBrains 为本项目提供免费的开源开发许可证 +

+ +--- + +## 🚀 快速开始 + +### 使用 Docker Compose(推荐) + +```bash +# 克隆项目 +git clone https://github.com/QuantumNous/new-api.git +cd new-api + +# 编辑 docker-compose.yml 配置 +nano docker-compose.yml + +# 启动服务 +docker-compose up -d +``` + +
+使用 Docker 命令 + +```bash +# 拉取最新镜像 +docker pull calciumion/new-api:latest + +# 使用 SQLite(默认) +docker run --name new-api -d --restart always \ + -p 3000:3000 \ + -e TZ=Asia/Shanghai \ + -v ./data:/data \ + calciumion/new-api:latest + +# 使用 MySQL +docker run --name new-api -d --restart always \ + -p 3000:3000 \ + -e SQL_DSN="root:123456@tcp(localhost:3306)/oneapi" \ + -e TZ=Asia/Shanghai \ + -v ./data:/data \ + calciumion/new-api:latest +``` + +> **💡 提示:** `-v ./data:/data` 会将数据保存在当前目录的 `data` 文件夹中,你也可以改为绝对路径如 `-v /your/custom/path:/data` + +
+ +--- + +🎉 部署完成后,访问 `http://localhost:3000` 即可使用! + +📖 更多部署方式请参考 [部署指南](https://docs.newapi.pro/zh/docs/installation) + +--- + +## 📚 文档 + +
+ +### 📖 [官方文档](https://docs.newapi.pro/zh/docs) | [![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/QuantumNous/new-api) + +
+ +**快速导航:** + +| 分类 | 链接 | +|------|------| +| 🚀 部署指南 | [安装文档](https://docs.newapi.pro/zh/docs/installation) | +| ⚙️ 环境配置 | [环境变量](https://docs.newapi.pro/zh/docs/installation/config-maintenance/environment-variables) | +| 📡 接口文档 | [API 文档](https://docs.newapi.pro/zh/docs/api) | +| ❓ 常见问题 | [FAQ](https://docs.newapi.pro/zh/docs/support/faq) | +| 💬 社区交流 | [交流渠道](https://docs.newapi.pro/zh/docs/support/community-interaction) | + +--- + +## ✨ 主要特性 + +> 详细特性请参考 [特性说明](https://docs.newapi.pro/zh/docs/guide/wiki/basic-concepts/features-introduction) + +### 🎨 核心功能 + +| 特性 | 说明 | +|------|------| +| 🎨 全新 UI | 现代化的用户界面设计 | +| 🌍 多语言 | 支持中文、英文、法语、日语 | +| 🔄 数据兼容 | 完全兼容原版 One API 数据库 | +| 📈 数据看板 | 可视化控制台与统计分析 | +| 🔒 权限管理 | 令牌分组、模型限制、用户管理 | + +### 💰 支付与计费 + +- ✅ 在线充值(易支付、Stripe) +- ✅ 模型按次数收费 +- ✅ 缓存计费支持(OpenAI、Azure、DeepSeek、Claude、Qwen等所有支持的模型) +- ✅ 灵活的计费策略配置 + +### 🔐 授权与安全 + +- 😈 Discord 授权登录 +- 🤖 LinuxDO 授权登录 +- 📱 Telegram 授权登录 +- 🔑 OIDC 统一认证 +- 🔍 Key 查询使用额度(配合 [neko-api-key-tool](https://github.com/Calcium-Ion/neko-api-key-tool)) + +### 🚀 高级功能 + +**API 格式支持:** +- ⚡ [OpenAI Responses](https://docs.newapi.pro/zh/docs/api/ai-model/chat/openai/create-response) +- ⚡ [OpenAI Realtime API](https://docs.newapi.pro/zh/docs/api/ai-model/realtime/create-realtime-session)(含 Azure) +- ⚡ [Claude Messages](https://docs.newapi.pro/zh/docs/api/ai-model/chat/create-message) +- ⚡ [Google Gemini](https://doc.newapi.pro/api/google-gemini-chat) +- 🔄 [Rerank 模型](https://docs.newapi.pro/zh/docs/api/ai-model/rerank/create-rerank)(Cohere、Jina) + +**智能路由:** +- ⚖️ 渠道加权随机 +- 🔄 失败自动重试 +- 🚦 用户级别模型限流 + +**格式转换:** +- 🔄 **OpenAI Compatible ⇄ Claude Messages** +- 🔄 **OpenAI Compatible → Google Gemini** +- 🔄 **Google Gemini → OpenAI Compatible** - 仅支持文本,暂不支持函数调用 +- 🚧 **OpenAI Compatible ⇄ OpenAI Responses** - 开发中 +- 🔄 **思考转内容功能** + +**Reasoning Effort 支持:** + +
+查看详细配置 + +**OpenAI 系列模型:** +- `o3-mini-high` - High reasoning effort +- `o3-mini-medium` - Medium reasoning effort +- `o3-mini-low` - Low reasoning effort +- `gpt-5-high` - High reasoning effort +- `gpt-5-medium` - Medium reasoning effort +- `gpt-5-low` - Low reasoning effort + +**Claude 思考模型:** +- `claude-3-7-sonnet-20250219-thinking` - 启用思考模式 + +**Google Gemini 系列模型:** +- `gemini-2.5-flash-thinking` - 启用思考模式 +- `gemini-2.5-flash-nothinking` - 禁用思考模式 +- `gemini-2.5-pro-thinking` - 启用思考模式 +- `gemini-2.5-pro-thinking-128` - 启用思考模式,并设置思考预算为128tokens +- 也可以直接在 Gemini 模型名称后追加 `-low` / `-medium` / `-high` 来控制思考力度(无需再设置思考预算后缀) + +
+ +--- + +## 🤖 模型支持 + +> 详情请参考 [接口文档 - 中继接口](https://docs.newapi.pro/zh/docs/api) + +| 模型类型 | 说明 | 文档 | +|---------|------|------| +| 🤖 OpenAI GPTs | gpt-4-gizmo-* 系列 | - | +| 🎨 Midjourney-Proxy | [Midjourney-Proxy(Plus)](https://github.com/novicezk/midjourney-proxy) | [文档](https://doc.newapi.pro/api/midjourney-proxy-image) | +| 🎵 Suno-API | [Suno API](https://github.com/Suno-API/Suno-API) | [文档](https://doc.newapi.pro/api/suno-music) | +| 🔄 Rerank | Cohere、Jina | [文档](https://docs.newapi.pro/zh/docs/api/ai-model/rerank/create-rerank) | +| 💬 Claude | Messages 格式 | [文档](https://docs.newapi.pro/zh/docs/api/ai-model/chat/create-message) | +| 🌐 Gemini | Google Gemini 格式 | [文档](https://doc.newapi.pro/api/google-gemini-chat) | +| 🔧 Dify | ChatFlow 模式 | - | +| 🎯 自定义 | 支持完整调用地址 | - | + +### 📡 支持的接口 + +
+查看完整接口列表 + +- [聊天接口 (Chat Completions)](https://docs.newapi.pro/zh/docs/api/ai-model/chat/openai/create-chat-completion) +- [响应接口 (Responses)](https://docs.newapi.pro/zh/docs/api/ai-model/chat/openai/create-response) +- [图像接口 (Image)](https://docs.newapi.pro/zh/docs/api/ai-model/images/openai/v1-images-generations--post) +- [音频接口 (Audio)](https://docs.newapi.pro/zh/docs/api/ai-model/audio/openai/create-transcription) +- [视频接口 (Video)](https://docs.newapi.pro/zh/docs/api/ai-model/videos/create-video-generation) +- [嵌入接口 (Embeddings)](https://docs.newapi.pro/zh/docs/api/ai-model/embeddings/create-embedding) +- [重排序接口 (Rerank)](https://docs.newapi.pro/zh/docs/api/ai-model/rerank/create-rerank) +- [实时对话 (Realtime)](https://docs.newapi.pro/zh/docs/api/ai-model/realtime/create-realtime-session) +- [Claude 聊天](https://docs.newapi.pro/zh/docs/api/ai-model/chat/create-message) +- [Google Gemini 聊天](https://doc.newapi.pro/api/google-gemini-chat) + +
+ +--- + +## 🚢 部署 + +> [!TIP] +> **最新版 Docker 镜像:** `calciumion/new-api:latest` + +### 📋 部署要求 + +| 组件 | 要求 | +|------|------| +| **本地数据库** | SQLite(Docker 需挂载 `/data` 目录)| +| **远程数据库** | MySQL ≥ 5.7.8 或 PostgreSQL ≥ 9.6 | +| **容器引擎** | Docker / Docker Compose | + +### ⚙️ 环境变量配置 + +
+常用环境变量配置 + +| 变量名 | 说明 | 默认值 | +|--------|--------------------------------------------------------------|--------| +| `SESSION_SECRET` | 会话密钥(多机部署必须) | - | +| `CRYPTO_SECRET` | 加密密钥(Redis 必须) | - | +| `SQL_DSN` | 数据库连接字符串 | - | +| `REDIS_CONN_STRING` | Redis 连接字符串 | - | +| `STREAMING_TIMEOUT` | 流式超时时间(秒) | `300` | +| `STREAM_SCANNER_MAX_BUFFER_MB` | 流式扫描器单行最大缓冲(MB),图像生成等超大 `data:` 片段(如 4K 图片 base64)需适当调大 | `64` | +| `MAX_REQUEST_BODY_MB` | 请求体最大大小(MB,**解压后**计;防止超大请求/zip bomb 导致内存暴涨),超过将返回 `413` | `32` | +| `AZURE_DEFAULT_API_VERSION` | Azure API 版本 | `2025-04-01-preview` | +| `ERROR_LOG_ENABLED` | 错误日志开关 | `false` | +| `PYROSCOPE_URL` | Pyroscope 服务地址 | - | +| `PYROSCOPE_APP_NAME` | Pyroscope 应用名 | `new-api` | +| `PYROSCOPE_BASIC_AUTH_USER` | Pyroscope Basic Auth 用户名 | - | +| `PYROSCOPE_BASIC_AUTH_PASSWORD` | Pyroscope Basic Auth 密码 | - | +| `PYROSCOPE_MUTEX_RATE` | Pyroscope mutex 采样率 | `5` | +| `PYROSCOPE_BLOCK_RATE` | Pyroscope block 采样率 | `5` | +| `HOSTNAME` | Pyroscope 标签里的主机名 | `new-api` | + +📖 **完整配置:** [环境变量文档](https://docs.newapi.pro/zh/docs/installation/config-maintenance/environment-variables) + +
+ +### 🔧 部署方式 + +
+方式 1:Docker Compose(推荐) + +```bash +# 克隆项目 +git clone https://github.com/QuantumNous/new-api.git +cd new-api + +# 编辑配置 +nano docker-compose.yml + +# 启动服务 +docker-compose up -d +``` + +
+ +
+方式 2:Docker 命令 + +**使用 SQLite:** +```bash +docker run --name new-api -d --restart always \ + -p 3000:3000 \ + -e TZ=Asia/Shanghai \ + -v ./data:/data \ + calciumion/new-api:latest +``` + +**使用 MySQL:** +```bash +docker run --name new-api -d --restart always \ + -p 3000:3000 \ + -e SQL_DSN="root:123456@tcp(localhost:3306)/oneapi" \ + -e TZ=Asia/Shanghai \ + -v ./data:/data \ + calciumion/new-api:latest +``` + +> **💡 路径说明:** +> - `./data:/data` - 相对路径,数据保存在当前目录的 data 文件夹 +> - 也可使用绝对路径,如:`/your/custom/path:/data` + +
+ +
+方式 3:宝塔面板 + +1. 安装宝塔面板(≥ 9.2.0 版本) +2. 在应用商店搜索 **New-API** +3. 一键安装 + +📖 [图文教程](./docs/BT.md) + +
+ +### ⚠️ 多机部署注意事项 + +> [!WARNING] +> - **必须设置** `SESSION_SECRET` - 否则登录状态不一致 +> - **公用 Redis 必须设置** `CRYPTO_SECRET` - 否则数据无法解密 + +### 🔄 渠道重试与缓存 + +**重试配置:** `设置 → 运营设置 → 通用设置 → 失败重试次数` + +**缓存配置:** +- `REDIS_CONN_STRING`:Redis 缓存(推荐) +- `MEMORY_CACHE_ENABLED`:内存缓存 + +--- + +## 🔗 相关项目 + +### 上游项目 + +| 项目 | 说明 | +|------|------| +| [One API](https://github.com/songquanpeng/one-api) | 原版项目基础 | +| [Midjourney-Proxy](https://github.com/novicezk/midjourney-proxy) | Midjourney 接口支持 | + +### 配套工具 + +| 项目 | 说明 | +|------|------| +| [neko-api-key-tool](https://github.com/Calcium-Ion/neko-api-key-tool) | Key 额度查询工具 | +| [new-api-horizon](https://github.com/Calcium-Ion/new-api-horizon) | New API 高性能优化版 | + +--- + +## 💬 帮助支持 + +### 📖 文档资源 + +| 资源 | 链接 | +|------|------| +| 📘 常见问题 | [FAQ](https://docs.newapi.pro/zh/docs/support/faq) | +| 💬 社区交流 | [交流渠道](https://docs.newapi.pro/zh/docs/support/community-interaction) | +| 🐛 反馈问题 | [问题反馈](https://docs.newapi.pro/zh/docs/support/feedback-issues) | +| 📚 完整文档 | [官方文档](https://docs.newapi.pro/zh/docs) | + +### 🤝 贡献指南 + +欢迎各种形式的贡献! + +- 🐛 报告 Bug +- 💡 提出新功能 +- 📝 改进文档 +- 🔧 提交代码 + +--- + +## 🌟 Star History + +
+ +[![Star History Chart](https://api.star-history.com/svg?repos=Calcium-Ion/new-api&type=Date)](https://star-history.com/#Calcium-Ion/new-api&Date) + +
+ +--- + +
+ +### 💖 感谢使用 New API + +如果这个项目对你有帮助,欢迎给我们一个 ⭐️ Star! + +**[官方文档](https://docs.newapi.pro/zh/docs)** • **[问题反馈](https://github.com/Calcium-Ion/new-api/issues)** • **[最新发布](https://github.com/Calcium-Ion/new-api/releases)** + +Built with ❤️ by QuantumNous + +