CJackHwang / ds2api
CJackHwang / ds2api
DS2API 语言 / Language: 中文 | English
Converts DeepSeek Web conversation capabilities into OpenAI, Claude, and Gemini compatible APIs. The backend is fully implemented in Go, and the frontend is a React WebUI management console (source code in webui/, automatically built into static/admin during deployment).
文档入口:文档导航 / 架构说明 / 接口文档 Documentation Entry: Documentation Navigation / Architecture Description / API Documentation
【感谢Linux.do社区及GitHub社区各位开发者对项目的支持与贡献】 [Thanks to all developers in the Linux.do community and GitHub community for their support and contributions to the project.]
重要免责声明 / Important Disclaimer
本仓库仅供学习、研究、个人实验和内部验证使用,不提供任何形式的商业授权、适用性保证或结果保证。 This repository is for learning, research, personal experimentation, and internal verification purposes only. It does not provide any form of commercial authorization, warranty of fitness, or guarantee of results.
作者及仓库维护者不对因使用、修改、分发、部署或依赖本项目而产生的任何直接或间接损失、账号封禁、数据丢失、法律风险或第三方索赔负责。 The author and repository maintainers are not responsible for any direct or indirect losses, account bans, data loss, legal risks, or third-party claims arising from the use, modification, distribution, deployment, or reliance on this project.
请勿将本项目用于违反服务条款、协议、法律法规或平台规则的场景。商业使用前请自行确认 LICENSE、相关协议以及你是否获得了作者的书面许可。 Please do not use this project in scenarios that violate terms of service, agreements, laws, regulations, or platform rules. Before commercial use, please confirm the LICENSE, relevant agreements, and whether you have obtained written permission from the author.
架构概览(摘要) / Architecture Overview (Summary)
(Flowchart omitted for brevity, please refer to the original repository for the diagram)
详细架构拆分与目录职责见 docs/ARCHITECTURE.md。
For detailed architecture breakdown and directory responsibilities, see docs/ARCHITECTURE.md.
- 后端 (Backend): Go (
cmd/ds2api/,api/,internal/), no dependency on Python runtime. - 前端 (Frontend): React management console (
webui/), runtime hosts static build artifacts. - 部署 (Deployment): Local execution, Docker, Vercel Serverless, Linux systemd.
核心能力 / Core Capabilities
| 能力 / Capability | 说明 / Description |
|---|---|
| OpenAI 兼容 | GET /v1/models, POST /v1/chat/completions, POST /v1/embeddings, POST /v1/files, etc. |
| Claude 兼容 | GET /anthropic/v1/models, POST /anthropic/v1/messages, etc. |
| Gemini 兼容 | POST /v1beta/models/{model}:generateContent, etc. |
| 多账号轮询 | 自动 token 刷新、邮箱/手机号双登录方式 / Automatic token refresh, email/phone dual login methods. |
| 并发队列控制 | 每账号 in-flight 上限 + 等待队列,动态计算建议并发值 / Per-account in-flight limit + wait queue, dynamic calculation of recommended concurrency. |
| DeepSeek PoW | 纯 Go 高性能实现(DeepSeekHashV1),毫秒级响应 / Pure Go high-performance implementation (DeepSeekHashV1), millisecond-level response. |
| Admin API | 配置管理、运行时设置热更新、代理管理、账号测试等 / Configuration management, runtime hot-updates, proxy management, account testing, etc. |
平台兼容矩阵 / Platform Compatibility Matrix
| 级别 / Level | 平台 / Platform | 当前状态 / Status |
|---|---|---|
| P0 | Codex CLI/SDK | ✅ |
| P0 | OpenAI SDK (JS/Python) | ✅ |
| P0 | Vercel AI SDK | ✅ |
| P0 | Anthropic SDK | ✅ |
| P0 | Google Gemini SDK | ✅ |
| P1 | LangChain / LlamaIndex / OpenWebUI | ✅ |
快速开始 / Quick Start
部署方式优先级建议 / Deployment Priority Recommendation
- 下载 Release 构建包运行: 最省事,产物已编译完成。 / Download Release build: Easiest, artifacts are pre-compiled.
- Docker / GHCR 镜像部署: 适合需要容器化、编排或云环境部署。 / Docker/GHCR: Suitable for containerization, orchestration, or cloud environments.
- Vercel 部署: 适合已有 Vercel 环境且接受其平台约束的场景。 / Vercel: Suitable for existing Vercel environments.
- 本地源码运行 / 自行编译: 适合开发、调试。 / Local source/Self-compile: Suitable for development and debugging.
通用第一步(所有部署方式) / General First Step (All methods)
把 config.json 作为唯一配置源:
Use config.json as the sole configuration source:
cp config.example.json config.json
# 编辑 config.json / Edit config.json
方式一:下载 Release 构建包 / Method 1: Download Release
# 下载对应平台的压缩包后 / After downloading the archive for your platform
tar -xzf ds2api_<tag>_linux_amd64.tar.gz
cd ds2api_<tag>_linux_amd64
cp config.example.json config.json
./ds2api
方式二:Docker 运行 / Method 2: Docker
# 1. 准备环境变量和配置文件 / Prepare environment variables and config
cp .env.example .env
cp config.example.json config.json