From 191685bfcdece6b904e3a668fd0c9c3abcc44b8a Mon Sep 17 00:00:00 2001 From: gongzhiyong Date: Wed, 29 Apr 2026 21:15:30 +0800 Subject: [PATCH] docs: rewrite README set for unified product delivery Refresh root, client, and gateway READMEs to present a cohesive HeiCode monorepo story, with clear startup flows and integration guidance for deployment teams. Made-with: Cursor --- README.md | 76 +++++++ cc-haha/README.md | 184 +++++------------ new-api/README.md | 490 ++++------------------------------------------ 3 files changed, 168 insertions(+), 582 deletions(-) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..a6ce5e2 --- /dev/null +++ b/README.md @@ -0,0 +1,76 @@ +# HeiCode Workspace + +一个仓库,交付两套能力: + +- `cc-haha`:HeiCode 客户端(CLI + Desktop) +- `new-api`:TaijiAICloud 网关(含 HeiCode 浏览器登录适配) + +这个仓库面向“开箱即用的 Claude Code 体验”产品化,不要求用户手动做复杂配置。 + +## 为什么是单仓库 + +- 客户端与平台适配同步迭代,避免版本错位 +- 登录、模型发现、默认模型策略在同一个版本闭环验证 +- 交付给客户时只有一个代码入口,部署和排障路径更短 + +## 仓库结构 + +```text +. +├── cc-haha/ # HeiCode 客户端主工程 +├── new-api/ # TaijiAICloud 网关工程(已接入 HeiCode OAuth) +├── package.json +└── bun.lock +``` + +## 一分钟启动 + +```bash +# 1) 安装根依赖 +bun install + +# 2) 启动 HeiCode 本地服务 +cd cc-haha +bun run src/server/index.ts + +# 3) 新开终端启动桌面端 +cd cc-haha/desktop +bun run tauri dev +``` + +若本地联调网关地址: + +```bash +HEICODE_TAIJIAICLOUD_BASE_URL=http://localhost:3000 bun run src/server/index.ts +``` + +## 当前产品特性 + +- 品牌统一为 `HeiCode` +- 登录入口聚焦平台登录流程(浏览器 OAuth 优先) +- 桌面端已移除 Providers 菜单与 GitHub 外链元素 +- 模型选择改为按 Provider API 动态拉全量模型 +- 支持 `taijiaicloud` 与 `clawdrouter` 双平台预设 + +## 平台侧接口约定(最小集) + +- `GET /v1/models`:模型列表发现 +- Anthropic Messages 兼容入口:供 HeiCode 直接调用 +- OAuth 风格授权入口(推荐):支持桌面端回调到本地 loopback + +`new-api` 已实现 HeiCode 登录相关路由: + +- `GET /heicode/oauth/authorize` +- `GET /heicode/oauth/session` + +## 文档导航 + +- 客户端说明:`cc-haha/README.md` +- 网关说明:`new-api/README.md` + +## 交付建议 + +- 用同一版本标签同时发布客户端与网关镜像 +- 每次发版至少回归三条链路:登录、模型拉取、对话请求 +- 先在本地 docker 联调通过,再做外网域名与证书配置 + diff --git a/cc-haha/README.md b/cc-haha/README.md index 8cb4979..56af117 100644 --- a/cc-haha/README.md +++ b/cc-haha/README.md @@ -1,157 +1,73 @@ -# HeiCode +# HeiCode Client (`cc-haha`) -> 基于 [`cc-haha`](https://github.com/NanmiCoder/cc-haha) 二次开发的 Claude Code 客户端,登录后通过 **TaijiAICloud** 或 **ClawdRouter** 直接使用各家主流大模型,零配置开箱即用。 +HeiCode 客户端工程,目标是把 “Claude Code 使用体验” 产品化,并对接企业模型平台。 ---- +## 你能得到什么 -## 当前形态 +- 一个可运行的 CLI + Desktop 客户端 +- 双平台登录入口(TaijiAICloud / ClawdRouter) +- 动态模型拉取,不写死模型名单 +- 适配企业交付的品牌化 UI -- **登录方式**:用户启动 HeiCode 后只看到两个登录入口 - - **TaijiAICloud**(自建网关,基于 [`new-api`](https://github.com/Calcium-Ion/new-api)) - - **ClawdRouter**(聚合网关) -- **支持模式**: - - 浏览器跳转 OAuth(推荐 / 平台支持后启用) - - 复制 API Key 粘贴登录(兼容入口 / 立即可用) -- **协议**:两个平台均原生支持 Anthropic `/v1/messages`,HeiCode 直接调用,无需中台代理。 -- **模型矩阵**:登录后自动从平台 `/v1/models` 拉取,覆盖 GPT / Claude / Gemini 全家桶。 +## 核心能力 ---- +- **登录流程**:优先浏览器 OAuth,兼容平台令牌登录 +- **模型发现**:通过 provider API 拉全量模型,不强绑定某一家模型 +- **运行方式**:同一套 provider 配置可在 CLI 与 Desktop 复用 +- **本地 sidecar**:桌面端通过本地服务层与 provider 通信,便于状态管理和扩展 -## 项目结构 +## 目录速览 -``` -heicode/ -├── bin/ # CLI 入口(heicode / claude-haha 兼容别名) -├── src/ # CLI + Server(Bun + TypeScript + Ink) -│ ├── server/ # 桌面端用的本地 HTTP/WS Server -│ │ ├── config/providerPresets.json # ★ 仅保留 TaijiAICloud / ClawdRouter -│ │ ├── api/heicode-auth.ts # ★ 双 Provider 登录入口 -│ │ └── api/providers.ts # ★ 加了 /v1/models 探活 -│ └── ... -├── desktop/ # Tauri 2 + React 桌面端 -└── docs/ # 文档(含 HEICODE-PLAN.md 路线图) +```text +cc-haha/ +├── bin/ # 启动入口(heicode、兼容别名) +├── src/ +│ ├── server/ # 本地 API/WS 服务 +│ │ ├── api/heicode-auth.ts # 登录相关接口 +│ │ ├── api/providers.ts # 模型拉取与 provider API +│ │ └── config/providerPresets.* +│ └── ... # CLI 逻辑 +├── desktop/ # Tauri + React 桌面端 +└── docs/ # 产品和技术文档 ``` ---- - -## 快速开始 - -### 1. 准备依赖 +## 快速启动 ```bash -# macOS / Linux -curl -fsSL https://bun.sh/install | bash - -# Windows (PowerShell) -powershell -c "irm bun.sh/install.ps1 | iex" -``` - -### 2. 安装项目 - -```bash -cd heicode +# 安装依赖 bun install + +# 启动本地服务 +bun run src/server/index.ts + +# 启动桌面端(新终端) +cd desktop +bun run tauri dev ``` -### 3. 启动 CLI(终端版) +本地联调 TaijiAICloud: ```bash -./bin/heicode # 交互 TUI -./bin/heicode -p "your prompt" # 无头模式 +HEICODE_TAIJIAICLOUD_BASE_URL=http://localhost:3000 bun run src/server/index.ts ``` -### 4. 启动桌面端 +## 开发约定 -```bash -# Terminal A — 本地 Server -SERVER_PORT=3456 bun run src/server/index.ts +- `providerPresets` 只保留产品确定的 provider +- UI 不暴露无关配置项(例如已移除 Providers 菜单) +- 模型来源以 provider 实际返回为准 +- 认证相关改动优先保持“零配置”用户体验 -# Terminal B — 桌面前端 -cd desktop && bun run dev --host 127.0.0.1 --port 2024 -``` +## 已完成改造(本分支) -浏览器打开 `http://127.0.0.1:2024`。 +- 品牌统一为 `HeiCode` +- 登录页去除 API Key 输入区域及相关提示文案 +- 设置页移除 Providers 菜单 +- 侧边栏和 About 移除 GitHub 链接与图标 +- 模型选择器按 provider API 动态拉取模型,修复无 Claude provider 仍展示 Claude 模型的问题 ---- +## 下一步建议 -## HeiCode Auth API - -供桌面端 / CLI 调用的双 Provider 登录入口。 - -| Method · Path | 用途 | -|---|---| -| `GET /api/heicode-auth/providers` | 列出 2 个登录入口(TaijiAICloud / ClawdRouter)+ OAuth 是否就绪 | -| `POST /api/heicode-auth/login` | 粘贴 API Key 登录:校验 → 拉模型 → 保存 → 激活 | -| `POST /api/heicode-auth/oauth/start` | OAuth 启动(**当前为占位**,等平台支持) | -| `GET /api/heicode-auth/oauth/callback` | OAuth 回跳(**当前为占位**,等平台支持) | -| `GET /api/heicode-auth/status` | 当前登录状态 | -| `POST /api/heicode-auth/logout` | 登出 | - -### 粘贴 API Key 登录示例 - -```bash -curl -X POST http://127.0.0.1:3456/api/heicode-auth/login \ - -H 'Content-Type: application/json' \ - -d '{"providerId":"taijiaicloud","apiKey":"sk-xxx"}' -``` - -返回: - -```json -{ - "ok": true, - "provider": { - "id": "...", - "presetId": "taijiaicloud", - "name": "TaijiAICloud", - "baseUrl": "https://api.taijiaicloud.com", - "apiFormat": "anthropic", - "models": { "main": "claude-sonnet-4-6", "haiku": "...", "sonnet": "...", "opus": "..." } - }, - "availableModels": [{ "id": "..." }, ...] -} -``` - ---- - -## 给两个平台的对接清单 - -详见 [`docs/HEICODE-PLAN.md`](./docs/HEICODE-PLAN.md)。简版: - -### TaijiAICloud(基于 new-api) - -- 必备:`/v1/messages`(Anthropic 原生协议) · `/v1/models` · API Key 子分组管理 -- 推荐:OAuth2 Authorization Code + PKCE 端点;Webhook(额度告警) - -### ClawdRouter - -- 必备:`/v1/messages` · `/v1/models`(已支持) -- 推荐:管理面 API(颁发短期 token);OAuth2 端点 - ---- - -## 路线图 - -- [x] **S0 品牌剥离**:包名 / Tauri / Cargo / 安装钩子改为 HeiCode -- [x] **S0 双 Provider 预设**:providerPresets.json 仅保留 TaijiAICloud / ClawdRouter -- [x] **S0 模型自动发现**:`/v1/models` 探活 + 默认模型自动选取 -- [x] **S0 双 Provider 登录后端**:`/api/heicode-auth/*` 完整就绪(OAuth 占位) -- [ ] **S1 桌面端登录页**:替换现有 Settings 的 Provider 列表为 2 卡片登录 -- [ ] **S1 CLI Onboarding**:原 `Onboarding.tsx` / `ConsoleOAuthFlow` 改为 HeiCode 双卡片 -- [ ] **S1 OAuth 真实接入**:等 TaijiAICloud / ClawdRouter 提供 OAuth endpoints 后补全 -- [ ] **S2 模型选择器 UX**:登录后 `/api/providers/:id/models` 渲染下拉选择默认模型 -- [ ] **S2 配额状态栏**:拉平台 `/v1/usage` 实时展示余量 -- [ ] **S3 Taiji Agent 工具融合**:MCP 自动挂载 / Skills 同步 / Agent 导入 - ---- - -## License - -继承上游 cc-haha 的 License。再往上游溯源是 Anthropic Claude Code 泄露源码,**仅供学习研究使用**。 - ---- - -## 致谢 - -- 上游 [`cc-haha`](https://github.com/NanmiCoder/cc-haha) — 提供基础工程 -- [`new-api`](https://github.com/Calcium-Ion/new-api) — 模型网关后端 +- 增加登录与模型发现的 E2E 冒烟测试 +- 将 OAuth 流程状态可视化(处理中/失败原因/重试) +- 增加 provider 超时与降级策略(提升桌面端可用性) diff --git a/new-api/README.md b/new-api/README.md index cb037a8..4c6f131 100644 --- a/new-api/README.md +++ b/new-api/README.md @@ -1,476 +1,70 @@ -
+# TaijiAICloud Gateway (`new-api`) -![new-api](/web/default/public/logo.png) +这是 HeiCode 产品线中的平台侧网关工程,基于 `new-api` 深度改造,目标是让 HeiCode 客户端能够“浏览器登录后即用模型”。 -# New API +## 本仓库角色 -🍥 **Next-Generation LLM Gateway and AI Asset Management System** +- 作为模型统一入口,管理渠道、用户、令牌、计费策略 +- 提供 HeiCode 需要的授权桥接接口 +- 输出标准模型发现能力(`/v1/models`)给客户端 -

- 简体中文 | - 繁體中文 | - English | - Français | - 日本語 -

+## HeiCode 相关新增能力 -

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

+### 1) 浏览器登录授权入口 -

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

+- `GET /heicode/oauth/authorize` +- `GET /heicode/oauth/session` -

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

+行为说明: -
+- 校验 `redirect_uri` 必须是 loopback(`127.0.0.1` / `localhost` / `::1`) +- 若用户未登录平台控制台,先引导登录 +- 登录后签发或复用 HeiCode 专用 token +- 回跳本地客户端并携带 `state` 与 `token` -## 📝 Project Description +### 2) 客户端模型发现 -> [!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. +- HeiCode 通过 `GET /v1/models` 拉取可用模型集合 +- 客户端不再依赖硬编码模型列表 ---- - -## 🤝 Trusted Partners - -

- No particular order -

- -

- - Cherry Studio - - Aion UI - - 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) +## 快速运行(本地 Docker) ```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 +docker compose -f docker-compose.yml -f docker-compose.override.yml up --build -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 +docker compose ps +docker compose logs -f new-api ``` -> **💡 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` -
+## HeiCode 联调检查清单 ---- +- 平台已可正常登录 Web 控制台 +- `GET /heicode/oauth/authorize` 返回流程可达 +- `GET /heicode/oauth/session` 可反映登录态 +- `GET /v1/models` 返回模型列表不为空 +- HeiCode 客户端登录后可直接发起模型请求 -🎉 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) +- `controller/heicode_oauth.go`:HeiCode 授权与会话检测核心逻辑 +- `router/heicode-router.go`:HeiCode OAuth 路由注册 +- `router/main.go`:总路由接入点 +- `docker-compose.override.yml`:本地开发构建入口 ---- +## 生产建议 -## 📚 Documentation +- 强制 HTTPS 与可信证书 +- 设置稳定的会话密钥与持久化存储 +- 对授权回调、token 签发、模型探活增加审计日志 +- 配置限流与告警,避免异常流量冲击 -
+## 许可证与来源 -### 📖 [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 Simplified Chinese, Traditional 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 -- 🔍 Key quota query usage (with [neko-api-key-tool](https://github.com/Calcium-Ion/neko-api-key-tool)) - -### 🚀 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-Compatible | OpenAI compatible models | [Documentation](https://docs.newapi.pro/en/docs/api/ai-model/chat/openai/createchatcompletion) | -| 🤖 OpenAI Responses | OpenAI Responses format | [Documentation](https://docs.newapi.pro/en/docs/api/ai-model/chat/openai/createresponse) | -| 🎨 Midjourney-Proxy | [Midjourney-Proxy(Plus)](https://github.com/novicezk/midjourney-proxy) | [Documentation](https://doc.newapi.pro/api/midjourney-proxy-image) | -| 🎵 Suno-API | [Suno API](https://github.com/Suno-API/Suno-API) | [Documentation](https://doc.newapi.pro/api/suno-music) | -| 🔄 Rerank | Cohere, Jina | [Documentation](https://docs.newapi.pro/en/docs/api/ai-model/rerank/creatererank) | -| 💬 Claude | Messages format | [Documentation](https://docs.newapi.pro/en/docs/api/ai-model/chat/createmessage) | -| 🌐 Gemini | Google Gemini format | [Documentation](https://docs.newapi.pro/en/docs/api/ai-model/chat/gemini/geminirelayv1beta) | -| 🔧 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/createchatcompletion) -- [Response Interface (Responses)](https://docs.newapi.pro/en/docs/api/ai-model/chat/openai/createresponse) -- [Image Interface (Image)](https://docs.newapi.pro/en/docs/api/ai-model/images/openai/post-v1-images-generations) -- [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/audio/openai/createspeech) -- [Embedding Interface (Embeddings)](https://docs.newapi.pro/en/docs/api/ai-model/embeddings/createembedding) -- [Rerank Interface (Rerank)](https://docs.newapi.pro/en/docs/api/ai-model/rerank/creatererank) -- [Realtime Conversation (Realtime)](https://docs.newapi.pro/en/docs/api/ai-model/realtime/createrealtimesession) -- [Claude Chat](https://docs.newapi.pro/en/docs/api/ai-model/chat/createmessage) -- [Google Gemini Chat](https://docs.newapi.pro/en/docs/api/ai-model/chat/gemini/geminirelayv1beta) - -
- ---- - -## 🚢 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 - ---- - -## 📜 License - -This project is licensed under the [GNU Affero General Public License v3.0 (AGPLv3)](./LICENSE). - -This is an open-source project developed based on [One API](https://github.com/songquanpeng/one-api) (MIT License). - -If your organization's policies do not permit the use of AGPLv3-licensed software, or if you wish to avoid the open-source obligations of AGPLv3, please contact us at: [support@quantumnous.com](mailto:support@quantumnous.com) - ---- - -## 🌟 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 - -
+本工程基于 `new-api` 上游能力演进,遵循对应许可证要求。企业使用前请完成内部合规审查。