mirror of
https://gitcode.com/JianFeeeee/ModelRouter.git
synced 2026-09-20 00:48:00 +00:00
feat: ModelRouter — unified OpenAI-compatible multi-source LLM gateway
- Lua adapters per upstream (transform_request/response/stream_chunk, build_headers signing hooks) - AUTO priority routing with per-model kind (chat/image), explicit source/model routing - Per-source concurrency caps with queueing, exponential backoff, AUTO failover - OpenAI-compatible API: chat completions, SSE streaming, image generations, models - Gateway key auth, web UI for adapter/source management, runtime persistence - e2e test running the real binary against mocked upstreams
This commit is contained in:
72
config.example.yaml
Normal file
72
config.example.yaml
Normal file
@ -0,0 +1,72 @@
|
||||
# llmsproxy — 统一 OpenAI 兼容网关配置
|
||||
|
||||
# 网关监听地址(默认 :8080,建议绑内网/回环)
|
||||
listen: 127.0.0.1:8080
|
||||
|
||||
# 客户端访问本网关所需的 API Key(Bearer)。留空数组 = 不鉴权(仅内网)。
|
||||
gateway_keys:
|
||||
- sk-gw-local-0001
|
||||
|
||||
# 默认模型选择:具体模型 id 或 AUTO(按各源模型的 priority 自动选最高可用源)
|
||||
default_model: AUTO
|
||||
|
||||
# Lua 适配器目录(默认 adapters/,首次启动自动写入内置适配器)
|
||||
adapter_dir: adapters
|
||||
|
||||
# 运行时持久化文件(WebUI 新增/编辑的源会写入此文件,重启后仍生效)
|
||||
runtime_file: runtime.json
|
||||
|
||||
# 全局并发上限(0 = 不限)
|
||||
max_concurrent: 0
|
||||
|
||||
# ---- 上游 LLM 源列表 ----
|
||||
# 每个源对应一个 Lua 适配器(adapter);同一个适配器可被多个源复用。
|
||||
sources:
|
||||
- name: deepseek
|
||||
base_url: https://api.deepseek.com
|
||||
api_key: sk-your-deepseek-key
|
||||
adapter: deepseek
|
||||
max_concurrent: 8
|
||||
models:
|
||||
- id: deepseek-v4-flash
|
||||
priority: 100 # 数字越大越优先被 AUTO 选中
|
||||
kind: chat
|
||||
- id: deepseek-reasoner
|
||||
priority: 60
|
||||
kind: chat
|
||||
meta: { thinking: true }
|
||||
|
||||
- name: ollama
|
||||
base_url: http://127.0.0.1:11434
|
||||
api_key: ""
|
||||
adapter: ollama
|
||||
endpoint: /api/chat
|
||||
models:
|
||||
- id: llama3
|
||||
priority: 50
|
||||
kind: chat
|
||||
|
||||
# 演示:KimiCode 校验调用方 app,通过 Lua build_headers 钩子做签名
|
||||
- name: kimicode
|
||||
base_url: https://api.moonshot.cn
|
||||
api_key: sk-your-kimi-key
|
||||
adapter: kimicode
|
||||
models:
|
||||
- id: kimi-k2
|
||||
priority: 90
|
||||
kind: chat
|
||||
meta:
|
||||
app_id: your-app-id
|
||||
app_secret: your-app-secret
|
||||
app_agent: code-agent
|
||||
api_key: sk-your-kimi-key
|
||||
|
||||
# 生图示例:OpenAI 兼容生图源(flux/dall-e 等)
|
||||
- name: imagegen
|
||||
base_url: https://api.example.com
|
||||
api_key: sk-image
|
||||
adapter: openai
|
||||
models:
|
||||
- id: flux-1
|
||||
priority: 80
|
||||
kind: image
|
||||
Reference in New Issue
Block a user