轻量级 OpenAI API 格式标准化代理 / Lightweight OpenAI API Format Standardization Proxy
|
完整中文文档,包含原理介绍、使用方法、部署指南等 |
Full English documentation with principles, usage, deployment guide, etc. |
ModelStandardization 是一个轻量级的 Rust 代理服务器,用于将内网部署的非标准 OpenAI 兼容模型 API 转换为标准 OpenAI API 格式。
ModelStandardization is a lightweight Rust proxy server that converts non-standard OpenAI-compatible model APIs deployed in private networks into standard OpenAI API format.
中文:企业内网部署的大模型接口通常是类 OpenAI 格式,但会返回多余的非标准字段,导致 Dify、Open WebUI 等标准客户端无法正确接入。
English: LLM interfaces deployed in enterprise private networks typically return extra non-standard fields, causing standard clients like Dify and Open WebUI to fail when integrating.
从 GitHub Releases 下载二进制文件。
Download from GitHub Releases.
创建 config.toml:
[server]
listen_address = "0.0.0.0"
listen_port = 8819
[upstream]
base_url = "http://your-model-server:8000"
api_key = "sk-xxx" # optional
timeout = 300
[response]
strip_fields = [
"system_fingerprint",
"service_tier",
"usage.completion_tokens_details",
"usage.prompt_tokens_details",
]
[request]
strip_fields = []chmod +x model-standardization
./model-standardizationcurl http://localhost:8819/health
# {"ok":true,"service":"model-standardization"}┌─────────────────────────────────────────────────────────────────────────────┐
│ 客户端 / Client (Dify / Open WebUI / LangChain) │
│ │ │
│ │ 标准 OpenAI 请求 / Standard Request │
│ ▼ │
│ ┌───────────────────────────────────────────────────────────────────────┐ │
│ │ ModelStandardization │ │
│ │ │ │
│ │ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │ │
│ │ │ 接收请求 │───▶│ 字段剥离 │───▶│ 转发上游 │ │ │
│ │ └─────────────┘ └─────────────┘ └─────────────┘ │ │
│ │ │ │ │
│ │ ▼ │ │
│ │ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │ │
│ │ │ 响应返回 │◀───│ 字段剥离 │◀───│ 接收响应 │ │ │
│ │ └─────────────┘ └─────────────┘ └─────────────┘ │ │
│ │ │ │
│ └───────────────────────────────────────────────────────────────────────┘ │
│ │ │
│ │ 非标准请求/响应 / Non-standard │
│ ▼ │
│ 内网大模型 / Private LLM Service │
└─────────────────────────────────────────────────────────────────────────────┘
| 功能 / Feature | 说明 / Description |
|---|---|
| ✅ 字段剥离 / Field Stripping | 支持从请求和响应中剥离任意配置的字段 |
| ✅ 嵌套路径 / Nested Paths | 支持点分隔的嵌套字段路径(如 usage.prompt_tokens_details) |
| ✅ 流式支持 / Streaming | 完整支持 SSE 流式响应的字段剥离 |
| ✅ 透明代理 / Transparent | 对客户端完全透明,无需修改客户端代码 |
| 🚀 高性能 / High Performance | 基于 Rust + Tokio,低内存占用,延迟 < 1ms |
| 📦 轻量级 / Lightweight | 二进制文件仅约 3.8MB,完全静态链接 |
| 端点 / Endpoint | 方法 / Method | 说明 / Description |
|---|---|---|
/v1/chat/completions |
POST | 聊天补全 / Chat completions |
/chat/completions |
POST | 同上(无版本前缀)/ Same (no prefix) |
/v1/models |
GET | 模型列表 / Model list |
/models |
GET | 同上(无版本前缀)/ Same (no prefix) |
/health |
GET | 健康检查 / Health check |
sudo vim /etc/systemd/system/model-standardization.service
sudo systemctl enable --now model-standardizationdocker build -t model-standardization .
docker run -d -p 8819:8819 model-standardizationdocker compose up -d📖 完整文档请访问 / For full documentation visit: