refactor: 重构trapi模型配置技能

This commit is contained in:
OpenClaw Backup Bot
2026-07-15 11:33:14 +08:00
parent 30b28fc8eb
commit 1b321205a3
3 changed files with 340 additions and 629 deletions
+134 -68
View File
@@ -1,91 +1,157 @@
# Custom Provider 配置参考
# trapi 模型与配置参考
> 来源:OpenClaw 官方文档
> - https://docs.openclaw.ai/concepts/models
> - https://docs.openclaw.ai/concepts/model-providers
## 目录
## Custom Provider 配置方式
- [Provider 配置](#provider-配置)
- [预置模型](#预置模型)
- [别名](#别名)
- [图像模型](#图像模型)
- [当前 OpenClaw 写入方式](#当前-openclaw-写入方式)
- [故障排查](#故障排查)
`openclaw.json``models.providers` 中添加自定义 provider
## Provider 配置
trapi 使用混合模型适配器。Provider 级 `api` 只是默认值;模型级 `api` 优先。
```json
{
"models": {
"providers": {
"<provider_id>": {
"baseUrl": "https://api.example.com",
"apiKey": "sk-xxx",
"api": "anthropic-messages",
"models": [
{
"id": "model-name",
"name": "Display Name",
"api": "anthropic-messages",
"reasoning": false,
"input": ["text"],
"cost": { "input": 0, "output": 0, "cacheRead": 0, "cacheWrite": 0 },
"contextWindow": 200000,
"maxTokens": 64000
}
]
}
}
}
"baseUrl": "https://lapi.transiglobal.com",
"apiKey": {
"source": "env",
"provider": "default",
"id": "TRAPI_API_KEY"
},
"api": "anthropic-messages"
}
```
## API 格式(api 字段)
不要在配置示例中放真实 API Key。
| 值 | 说明 |
|----|------|
| `anthropic-messages` | Anthropic Messages API 格式 |
| `openai-completions` | OpenAI Chat Completions 格式 |
| `openai-responses` | OpenAI Responses API 格式 |
## 预置模型
## 模型字段说明
所有模型暂时保留零费用元数据。不要给任何模型写 `reasoning` 字段,让 OpenClaw 和上游按模型默认行为处理。
| 字段 | 类型 | 说明 |
|------|------|------|
| `id` | string | 模型 ID(必填),用于 provider/model 引用 |
| `name` | string | 显示名称 |
| `api` | string | API 格式,可覆盖 provider 级别设置 |
| `reasoning` | boolean | 是否支持推理/思考模式 |
| `input` | string[] | 支持的输入类型:`"text"`, `"image"` |
| `cost` | object | 费用设置,免费模型全部设为 0 |
| `contextWindow` | number | 上下文窗口大小(token 数) |
| `maxTokens` | number | 最大输出 token 数 |
| 模型 ID | API | 输入 | contextWindow | maxTokens |
|---|---|---|---:|---:|
| GLM-5-Turbo | anthropic-messages | text | 200000 | 64000 |
| GLM-5.2 | anthropic-messages | text | 200000 | 64000 |
| GLM-4.5-Air | anthropic-messages | text | 200000 | 64000 |
| MiniMax-M2 | anthropic-messages | text | 200000 | 64000 |
| MiniMax-M2.7 | anthropic-messages | text | 200000 | 64000 |
| MiniMax-M3 | anthropic-messages | text, image | 1000000 | 131072 |
| kimi-for-coding | anthropic-messages | text, image | 262144 | 32768 |
| GLM-5V-Turbo | anthropic-messages | text, image | 200000 | 64000 |
| PaddleOCR-VL-1.5 | anthropic-messages | text, image | 131072 | 8192 |
| deepseek-v4-pro | anthropic-messages | text | 1000000 | 384000 |
| deepseek-v4-flash | anthropic-messages | text | 1000000 | 384000 |
| gpt-5.5 | openai-responses | text | 200000 | 65536 |
| gpt-5.6-sol | openai-responses | text, image | 372000 | 128000 |
| gpt-5.6-terra | openai-responses | text, image | 372000 | 128000 |
| gpt-5.6-luna | openai-responses | text, image | 372000 | 128000 |
| mimo-v2.5-pro | anthropic-messages | text | 200000 | 64000 |
| mimo-v2.5 | anthropic-messages | text, image, video, audio | 200000 | 64000 |
| claude-opus-4.7 | anthropic-messages | text | 300000 | 64000 |
| qwen3.7-max | anthropic-messages | text | 1000000 | 100000 |
| qwen3.6-plus | anthropic-messages | text, image | 1000000 | 100000 |
## 模型别名配置
`agents.defaults.models` 中注册别名:
完整模型数组:
```json
{
"agents": {
"defaults": {
"models": {
"trapi/GLM-5-Turbo": { "alias": "glm5t" },
"trapi/GLM-5.1": { "alias": "glm51" }
}
}
}
}
[
{"id":"GLM-5-Turbo","name":"GLM-5-Turbo (Transiglobal)","api":"anthropic-messages","input":["text"],"cost":{"input":0,"output":0,"cacheRead":0,"cacheWrite":0},"contextWindow":200000,"maxTokens":64000},
{"id":"GLM-5.2","name":"GLM-5.2 (Transiglobal)","api":"anthropic-messages","input":["text"],"cost":{"input":0,"output":0,"cacheRead":0,"cacheWrite":0},"contextWindow":200000,"maxTokens":64000},
{"id":"GLM-4.5-Air","name":"GLM-4.5-Air (Transiglobal)","api":"anthropic-messages","input":["text"],"cost":{"input":0,"output":0,"cacheRead":0,"cacheWrite":0},"contextWindow":200000,"maxTokens":64000},
{"id":"MiniMax-M2","name":"MiniMax M2 (Transiglobal)","api":"anthropic-messages","input":["text"],"cost":{"input":0,"output":0,"cacheRead":0,"cacheWrite":0},"contextWindow":200000,"maxTokens":64000},
{"id":"MiniMax-M2.7","name":"MiniMax-M2.7 (Transiglobal)","api":"anthropic-messages","input":["text"],"cost":{"input":0,"output":0,"cacheRead":0,"cacheWrite":0},"contextWindow":200000,"maxTokens":64000},
{"id":"MiniMax-M3","name":"MiniMax M3 (Transiglobal)","api":"anthropic-messages","input":["text","image"],"cost":{"input":0,"output":0,"cacheRead":0,"cacheWrite":0},"contextWindow":1000000,"maxTokens":131072},
{"id":"kimi-for-coding","name":"kimi-for-coding (Transiglobal)","api":"anthropic-messages","input":["text","image"],"cost":{"input":0,"output":0,"cacheRead":0,"cacheWrite":0},"contextWindow":262144,"maxTokens":32768},
{"id":"GLM-5V-Turbo","name":"GLM-5V-Turbo (Transiglobal)","api":"anthropic-messages","input":["text","image"],"cost":{"input":0,"output":0,"cacheRead":0,"cacheWrite":0},"contextWindow":200000,"maxTokens":64000},
{"id":"PaddleOCR-VL-1.5","name":"PaddleOCR-VL-1.5 (Transiglobal)","api":"anthropic-messages","input":["text","image"],"cost":{"input":0,"output":0,"cacheRead":0,"cacheWrite":0},"contextWindow":131072,"maxTokens":8192},
{"id":"deepseek-v4-pro","name":"DeepSeek V4 Pro (Transiglobal)","api":"anthropic-messages","input":["text"],"cost":{"input":0,"output":0,"cacheRead":0,"cacheWrite":0},"contextWindow":1000000,"maxTokens":384000},
{"id":"deepseek-v4-flash","name":"DeepSeek V4 Flash (Transiglobal)","api":"anthropic-messages","input":["text"],"cost":{"input":0,"output":0,"cacheRead":0,"cacheWrite":0},"contextWindow":1000000,"maxTokens":384000},
{"id":"gpt-5.5","name":"GPT-5.5 (Transiglobal)","api":"openai-responses","input":["text"],"cost":{"input":0,"output":0,"cacheRead":0,"cacheWrite":0},"contextWindow":200000,"maxTokens":65536},
{"id":"gpt-5.6-sol","name":"GPT-5.6 Sol (Transiglobal)","api":"openai-responses","input":["text","image"],"cost":{"input":0,"output":0,"cacheRead":0,"cacheWrite":0},"contextWindow":372000,"maxTokens":128000},
{"id":"gpt-5.6-terra","name":"GPT-5.6 Terra (Transiglobal)","api":"openai-responses","input":["text","image"],"cost":{"input":0,"output":0,"cacheRead":0,"cacheWrite":0},"contextWindow":372000,"maxTokens":128000},
{"id":"gpt-5.6-luna","name":"GPT-5.6 Luna (Transiglobal)","api":"openai-responses","input":["text","image"],"cost":{"input":0,"output":0,"cacheRead":0,"cacheWrite":0},"contextWindow":372000,"maxTokens":128000},
{"id":"mimo-v2.5-pro","name":"MiMo 2.5 Pro (Transiglobal)","api":"anthropic-messages","input":["text"],"cost":{"input":0,"output":0,"cacheRead":0,"cacheWrite":0},"contextWindow":200000,"maxTokens":64000},
{"id":"mimo-v2.5","name":"MiMo 2.5 (Transiglobal)","api":"anthropic-messages","input":["text","image","video","audio"],"cost":{"input":0,"output":0,"cacheRead":0,"cacheWrite":0},"contextWindow":200000,"maxTokens":64000},
{"id":"claude-opus-4.7","name":"Claude Opus 4.7 (Transiglobal)","api":"anthropic-messages","input":["text"],"cost":{"input":0,"output":0,"cacheRead":0,"cacheWrite":0},"contextWindow":300000,"maxTokens":64000},
{"id":"qwen3.7-max","name":"Qwen 3.7 Max (Transiglobal)","api":"anthropic-messages","input":["text"],"cost":{"input":0,"output":0,"cacheRead":0,"cacheWrite":0},"contextWindow":1000000,"maxTokens":100000},
{"id":"qwen3.6-plus","name":"Qwen 3.6 Plus (Transiglobal)","api":"anthropic-messages","input":["text","image"],"cost":{"input":0,"output":0,"cacheRead":0,"cacheWrite":0},"contextWindow":1000000,"maxTokens":100000}
]
```
别名注册后可通过 `/alias` 快速切换模型。
## 别名
## 注意事项
| 模型 ID | 别名 |
|---|---|
| GLM-5-Turbo | glm5t |
| GLM-5.2 | glm52 |
| GLM-4.5-Air | glm45a |
| MiniMax-M2 | mxm2 |
| MiniMax-M2.7 | mxm27 |
| MiniMax-M3 | mxm3 |
| kimi-for-coding | kimi |
| GLM-5V-Turbo | glm5v |
| PaddleOCR-VL-1.5 | pocr |
| deepseek-v4-pro | dsv4p |
| deepseek-v4-flash | dsv4f |
| gpt-5.5 | gpt55 |
| gpt-5.6-sol | g56s |
| gpt-5.6-terra | g56t |
| gpt-5.6-luna | g56l |
| mimo-v2.5-pro | mimo25p |
| mimo-v2.5 | mimo25 |
| claude-opus-4.7 | opus47 |
| qwen3.7-max | qwn37 |
| qwen3.6-plus | qwn36 |
- `agents.defaults.models` 设置后成为 **allowlist**,只有列表中的模型才可用
- Provider 配置会写入 `models.json`,合并模式(merge)下不会覆盖已有配置
- API Key 会从 `models.providers` 和 auth profiles 两处解析
- 模型引用格式:`provider/model`(如 `trapi/GLM-5-Turbo`
别名没有强制五字符限制。优先简短、清晰、稳定,不自动改动用户已有别名。
## 相关 CLI 命令
对话中使用:
```text
/model glm5t
/model mxm3
/model g56s
```
## 图像模型
支持图片输入:
- MiniMax-M3
- kimi-for-coding
- GLM-5V-Turbo
- PaddleOCR-VL-1.5
- gpt-5.6-sol
- gpt-5.6-terra
- gpt-5.6-luna
- mimo-v2.5
- qwen3.6-plus
imageModel 仅用于图像理解,不等同于图像生成模型。
## 当前 OpenClaw 写入方式
优先使用:
```bash
openclaw models list # 查看已配置模型
openclaw models status # 查看当前模型和认证状态
openclaw models aliases list # 查看所有别名
openclaw models aliases add <alias> <provider/model> # 添加别名
openclaw config set models.providers.trapi '<provider-json>' --strict-json --merge
openclaw config set models.providers.trapi.models '<model-array-json>' --strict-json --merge
openclaw models aliases add <alias> trapi/<model-id>
openclaw models set-image trapi/<model-id>
openclaw models image-fallbacks add trapi/<model-id>
```
不要把模型或别名更新写成 Agent 侧 `gateway config.patch`。当前 OpenClaw 会保护全局模型配置路径,且 Patch 中数组不是按模型 ID 自动追加。
## 故障排查
- 401/403:检查 Gateway 服务是否能解析 `TRAPI_API_KEY` SecretRef。
- Model not found:核对模型 ID 大小写及 trapi 实际开放目录。
- 协议错误:核对模型级 `api`GPT 模型使用 `openai-responses`,其余目录条目使用各自声明值。
- 别名冲突:执行 `openclaw models aliases list --json`,由用户决定保留或重定向。
- 配置写入被拒绝:重新读取目标路径并使用 `--merge`;不要直接改用 `--replace`
- 图像未传入模型:确认模型 `input` 包含 `image`,并检查 imageModel 配置。
- `available: true` 但调用失败:该状态不证明上游推理可用,需要经用户确认后做最小实时请求。