# New API 研究报告 **研究日期**: 2026-06-09 **项目**: QuantumNous/new-api **Stars**: 37,729 ⭐ **语言**: Go **最新版本**: v1.0.0-rc.10 (2026-05-26) **官网**: https://www.newapi.ai **文档**: https://docs.newapi.pro --- ## 📋 项目概述 **New API** 是下一代 LLM 网关和 AI 资产管理系统,是 One API 的增强版本。它将多个 AI 模型提供商统一转换为 OpenAI/Claude/Gemini 兼容格式,提供集中化的模型管理平台。 ### 核心定位 - **AI API 网关**: 聚合多个 AI 提供商,统一接口 - **企业级管理**: 组织级鉴权、用量统计、成本核算 - **私有化部署**: 支持 Docker 一键部署 - **格式转换**: OpenAI ⇄ Claude ⇄ Gemini 互相转换 --- ## 🚀 核心功能 ### 1. 多协议支持 - ⚡ **OpenAI Responses API** (最新格式) - ⚡ **OpenAI Realtime API** (包括 Azure) - ⚡ **Claude Messages API** - ⚡ **Google Gemini API** - 🔄 **Rerank Models** (Cohere, Jina) ### 2. 智能路由 - ⚖️ 渠道加权随机 - 🔄 失败自动重试 - 🚦 用户级模型限流 - 💾 缓存命中统计 (OpenAI/Azure/DeepSeek/Claude/Qwen) ### 3. 格式转换 - OpenAI Compatible ⇄ Claude Messages - OpenAI Compatible → Google Gemini - Google Gemini → OpenAI Compatible (仅文本) - 🔄 思考内容转换 (thinking-to-content) ### 4. 推理努力控制 **OpenAI 系列**: - o3-mini-high/medium/low - gpt-5-high/medium/low **Claude 系列**: - claude-3-7-sonnet-thinking **Gemini 系列**: - gemini-2.5-flash-thinking/nothinking - gemini-2.5-pro-thinking - 支持 -low/-medium/-high 后缀 ### 5. 计费与配额 - ✅ 内部充值和配额分配 (EPay, Stripe) - ✅ 按请求/用量/缓存命中率成本核算 - ✅ 灵活计费策略 - ✅ 企业客户管理 ### 6. 权限管理 - 🔑 Token 分组 - 🔒 模型限制 - 👥 用户管理 - 🔐 多种登录方式 (Discord/LinuxDO/Telegram/OIDC) --- ## 📡 支持的渠道类型 (50+) | 渠道类型 | 编号 | 默认 BASE_URL | |---------|------|---------------| | OpenAI | 1 | https://api.openai.com | | Azure | 3 | - | | Anthropic | 14 | https://api.anthropic.com | | **阿里云 (Ali)** | **17** | **https://dashscope.aliyuncs.com** | | 百度文心 | 15/46 | https://aip.baidubce.com | | 智谱 | 16/26 | https://open.bigmodel.cn | | Gemini | 24 | https://generativelanguage.googleapis.com | | Moonshot | 25 | https://api.moonshot.cn | | DeepSeek | 43 | - | | 火山引擎 | 45 | - | | OpenRouter | 20 | https://openrouter.ai/api | | Cohere | 34 | https://api.cohere.ai | | MiniMax | 35 | https://api.minimax.chat | | Mistral | 42 | - | | xAI | 48 | - | | 更多... | - | - | --- ## 🔗 阿里云百炼对接 ### 百炼 OpenAI 兼容接口 阿里云百炼的千问模型支持 OpenAI 兼容接口,只需调整 API Key、BASE_URL 和模型名称。 ### 配置信息 **BASE_URL (SDK)**: - 北京: `https://dashscope.aliyuncs.com/compatible-mode/v1` - 弗吉尼亚: `https://dashscope-us.aliyuncs.com/compatible-mode/v1` - 新加坡: `https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1` **HTTP Endpoint**: - 北京: `POST https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions` ### 支持的千问模型 **商业版**: - **千问 Max**: qwen3.7-max, qwen3-max, qwen-max - **千问 Plus**: qwen3.6-plus, qwen3.5-plus, qwen-plus - **千问 Flash**: qwen3.6-flash, qwen3.5-flash, qwen-flash - **千问 Coder**: qwen3-coder-plus, qwen3-coder-flash - **QwQ**: qwq-plus **开源版**: - qwen3.6-35b-a3b, qwen3.5-397b-a17b, qwen3.5-122b-a10b - qwen3-235b-a22b, qwen3-32b, qwen3-30b-a3b, qwen3-14b, qwen3-8b ### New API 对接百炼步骤 1. **部署 New API** ```bash docker run -d --name new-api -p 3000:3000 \ -e TZ=Asia/Shanghai \ -v ./data:/data \ calciumion/new-api:latest ``` 2. **添加阿里云渠道** - 进入管理后台 → 渠道管理 → 添加渠道 - 选择 **阿里云 (Ali)** 类型 (Channel Type: 17) - 填写 **百炼 API Key** - BASE_URL 默认已填: `https://dashscope.aliyuncs.com` - 选择要启用的模型 3. **创建 Token** - 令牌管理 → 创建令牌 - 生成 API Key 供下游应用使用 4. **下游应用调用** ```python from openai import OpenAI client = OpenAI( api_key=*** # New API 生成的 Token base_url="http://localhost:3000/v1", # New API 地址 ) ``` ### 渠道额外设置 ```json { "force_format": true, // 强制格式化为 OpenAI 格式 "thinking_to_content": true, // 将思考内容转为 标签 "proxy": "socks5://xxx" // 网络代理 } ``` --- ## 🐳 部署方式 ### Docker Compose(推荐) ```yaml version: '3.4' services: new-api: image: calciumion/new-api:latest container_name: new-api restart: always ports: - "3000:3000" volumes: - ./data:/data - ./logs:/app/logs environment: - SQL_DSN=postgresql://root:123456@postgres:5432/new-api - REDIS_CONN_STRING=redis://:123456@redis:6379 - TZ=Asia/Shanghai depends_on: - redis - postgres redis: image: redis:latest restart: always command: ["redis-server", "--requirepass", "123456"] postgres: image: postgres:15 restart: always environment: POSTGRES_USER: root POSTGRES_PASSWORD: 123456 POSTGRES_DB: new-api volumes: - pg_data:/var/lib/postgresql/data ``` ### 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 ``` 部署后访问: `http://localhost:3000` --- ## 📊 支持的接口 - Chat Interface (Chat Completions) - Response Interface (Responses) - Image Interface (Image) - Audio Interface (Audio) - Video Interface (Video) - Embedding Interface (Embeddings) - Rerank Interface (Rerank) - Realtime Conversation (Realtime) - Claude Chat - Google Gemini Chat --- ## 🌍 多语言支持 - 简体中文 - 繁体中文 - English - Français - 日本語 --- ## 🎨 UI 特性 - 现代化界面设计 - 数据看板(可视化控制台和统计分析) - 主题定制(支持 Anthropic/Simple Large 预设) - 响应式设计(移动端友好) - 暗色模式 --- ## 🔐 认证方式 - Discord 授权登录 - LinuxDO 授权登录 - Telegram 授权登录 - OIDC 统一认证 --- ## 💡 使用场景 ### 个人开发者 - 统一管理多个 AI 提供商的 API Key - 跨平台模型切换 - 用量追踪 ### 企业用户 - 组织级鉴权和权限管理 - 成本核算和计费系统 - 多租户管理 - 用量统计和分析 ### API 转售 - 支持多租户 - 配额管理 - 计费系统 (EPay, Stripe) - 缓存优化降低成本 --- ## 🔗 相关资源 - **官方文档**: https://docs.newapi.pro - **GitHub**: https://github.com/QuantumNous/new-api - **Docker Hub**: https://hub.docker.com/r/calciumion/new-api - **One API (原版)**: https://github.com/songquanpeng/one-api - **百炼文档**: https://help.aliyun.com/zh/model-studio/ - **Key 工具**: https://github.com/Calcium-Ion/new-api-key-tool --- ## 📝 总结 **New API** 是一个功能强大的 AI API 网关,适合: 1. **个人开发者**: 统一管理多个 AI 提供商的 API Key 2. **企业用户**: 组织级鉴权、成本核算、用量统计 3. **API 转售**: 支持多租户、配额管理、计费系统 **百炼对接优势**: - 原生支持阿里云渠道 (Channel Type 17) - 百炼提供 OpenAI 兼容接口,迁移成本低 - 千问模型性价比高,适合各种场景 - 支持缓存统计,可降低成本 **推荐部署方式**: Docker Compose,包含 PostgreSQL + Redis,适合生产环境。