1
0
Files
nex/README.md
lanyuanxiaoyao 915b004924 feat: 初始化 AI Gateway 项目
实现支持 OpenAI 和 Anthropic 双协议的统一大模型 API 网关 MVP 版本,包含:
- OpenAI 和 Anthropic 协议代理
- 供应商和模型管理
- 用量统计
- 前端配置界面
2026-04-15 16:53:28 +08:00

106 lines
2.4 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Nex - AI Gateway
一个统一的大模型 API 网关,支持 OpenAI 和 Anthropic 双协议,让应用只需配置一个地址即可透明使用多个供应商的大模型服务。
## 项目结构
```
nex/
├── backend/ # Go 后端服务
│ ├── main.go
│ ├── go.mod
│ └── internal/
│ ├── handler/ # HTTP 处理器
│ ├── protocol/ # 协议适配器
│ ├── provider/ # 供应商客户端
│ ├── router/ # 模型路由
│ ├── stats/ # 统计记录
│ └── config/ # 配置与数据库
├── frontend/ # React 前端界面
│ ├── src/
│ │ ├── main.tsx
│ │ ├── App.tsx
│ │ ├── pages/
│ │ ├── components/
│ │ ├── api/
│ │ └── styles/
│ └── package.json
└── README.md # 本文件
```
## 功能特性
- **双协议支持**:同时支持 OpenAI 和 Anthropic 协议
- **透明代理**:对 OpenAI 兼容供应商透传请求
- **流式响应**:完整支持 SSE 流式传输
- **Function Calling**支持工具调用Tools
- **多供应商管理**:配置和管理多个供应商
- **用量统计**:按供应商、模型、日期统计请求数量
- **Web 配置界面**:提供供应商和模型配置管理
## 技术栈
### 后端
- **Go 1.21+**
- **Gin** - HTTP 框架
- **GORM** - ORM
- **SQLite** - 数据库
### 前端
- **Bun** - 运行时
- **Vite** - 构建工具
- **TypeScript** - 类型系统
- **React** - UI 框架
- **SCSS** - 样式预处理
## 快速开始
### 后端
```bash
cd backend
go mod download
go run main.go
```
后端服务将在 `http://localhost:9826` 启动。
### 前端
```bash
cd frontend
bun install
bun dev
```
前端开发服务器将在 `http://localhost:5173` 启动。
## API 接口
### 代理接口(对外部应用)
- `POST /v1/chat/completions` - OpenAI Chat Completions API
- `POST /v1/messages` - Anthropic Messages API
### 管理接口(对前端)
- `GET/POST/PUT/DELETE /api/providers` - 供应商管理
- `GET/POST/PUT/DELETE /api/models` - 模型管理
- `GET /api/stats` - 统计查询
## 配置存储
配置数据存储在用户目录:`~/.nex/config.db`
## 开发规范
详见各子项目的 README.md
- [后端 README](backend/README.md)
- [前端 README](frontend/README.md)
## 许可证
MIT