skills/api-provider-setup/SKILL.md
添加和配置第三方 API 中转站供应商到 OpenClaw。当用户需要添加新的 API 供应商、配置中转站、设置自定义模型端点时使用此技能。支持 Anthropic 兼容和 OpenAI 兼容的 API 格式。
npx skillsauth add aaaaqwq/claude-code-skills api-provider-setupInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
为 OpenClaw 添加和配置第三方 API 中转站供应商。
配置文件:~/.openclaw/openclaw.json
在 models.providers 部分添加自定义供应商。
{
"models": {
"mode": "merge",
"providers": {
"供应商名称": {
"baseUrl": "https://api.example.com",
"apiKey": "sk-your-api-key",
"auth": "api-key",
"api": "anthropic-messages",
"models": [
{
"id": "model-id",
"name": "显示名称",
"reasoning": false,
"input": ["text"],
"contextWindow": 200000,
"maxTokens": 8192,
"cost": {
"input": 0,
"output": 0,
"cacheRead": 0,
"cacheWrite": 0
}
}
]
}
}
}
}
{
"models": {
"mode": "merge",
"providers": {
"供应商名称": {
"baseUrl": "https://api.example.com/v1",
"apiKey": "sk-your-api-key",
"auth": "api-key",
"api": "openai-completions",
"models": [
{
"id": "gpt-4",
"name": "GPT-4",
"reasoning": false,
"input": ["text"],
"contextWindow": 128000,
"maxTokens": 4096
}
]
}
}
}
}
| 字段 | 必填 | 说明 |
|------|------|------|
| baseUrl | ✅ | API 端点地址(不含 /v1/messages 等路径) |
| apiKey | ✅ | API 密钥 |
| auth | ✅ | 认证方式,通常为 api-key |
| api | ✅ | API 格式:anthropic-messages 或 openai-completions |
| models | ✅ | 该供应商支持的模型列表 |
| models[].id | ✅ | 模型 ID(调用时使用) |
| models[].name | ❌ | 显示名称 |
| models[].contextWindow | ❌ | 上下文窗口大小 |
| models[].maxTokens | ❌ | 最大输出 token 数 |
| models[].reasoning | ❌ | 是否支持推理模式 |
在 agents.defaults.models 中添加别名:
{
"agents": {
"defaults": {
"models": {
"供应商/模型id": {
"alias": "简短别名"
}
}
}
}
}
⚠️ 重要约束:
alias字段必须是字符串,不能是数组!// ✅ 正确 "alias": "opus46" // ❌ 错误 - 会导致 Config validation failed "alias": ["opus46", "<provider>/model"]如果需要多个别名指向同一模型,需要在
models中添加多条记录:"供应商/模型id": { "alias": "别名1" }
在 agents.defaults.model 中设置:
{
"agents": {
"defaults": {
"model": {
"primary": "供应商/模型id",
"fallbacks": [
"备选供应商1/模型id",
"备选供应商2/模型id"
]
}
}
}
}
获取供应商信息
使用 gateway config.patch 添加
gateway config.patch 添加供应商配置
重启 Gateway 生效
gateway restart
测试新模型
session_status(model="新供应商/模型id")
"anapi": {
"baseUrl": "https://anapi.9w7.cn",
"apiKey": "sk-xxx",
"auth": "api-key",
"api": "anthropic-messages",
"models": [{"id": "opus-4.5", "name": "Opus 4.5", "contextWindow": 200000}]
}
"zai": {
"baseUrl": "https://open.bigmodel.cn/api/anthropic",
"apiKey": "xxx.xxx",
"auth": "api-key",
"api": "anthropic-messages",
"models": [{"id": "glm-4.7", "name": "GLM-4.7", "contextWindow": 200000}]
}
"openrouter-vip": {
"baseUrl": "https://openrouter.vip/v1",
"apiKey": "sk-xxx",
"auth": "api-key",
"api": "openai-completions",
"models": [{"id": "gpt-5.2", "name": "GPT-5.2", "contextWindow": 200000}]
}
"wow": {
"baseUrl": "https://linuxdoapi-api-wow.223387.xyz/v1",
"apiKey": "pass show api/wow",
"auth": "api-key",
"api": "openai-completions",
"models": [
{"id": "grok-4.1-thinking", "name": "grok-4.1-thinking", "reasoning": true, "contextWindow": 128000},
{"id": "grok-imagine-1.0", "name": "grok-imagine-1.0", "input": ["text","image"], "contextWindow": 128000},
{"id": "kimi-k2.5", "name": "kimi-k2.5", "contextWindow": 128000}
]
}
别名配置(agents.defaults.models):
"<provider>/kimi-k2.5": { "alias": "wow-k2.5" },
"<provider>/grok-4.1-thinking": { "alias": "wow-grok-4.1-thinking" },
"<provider>/grok-imagine-1.0": { "alias": "wow-grok-imagine-1.0" }
背景:OpenClaw 运行时优先读 ~/.openclaw/agents/<agent>/agent/auth-profiles.json 中缓存的 key,而非 openclaw.json。改了 openclaw.json 的 apiKey 后必须同步。
脚本:~/clawd/skills/api-provider-setup/scripts/sync-agent-auth.sh
# 改了 openclaw.json 的 key 后,一键同步所有 agent
~/clawd/skills/api-provider-setup/scripts/sync-agent-auth.sh
# 只同步指定 provider(如改了 zai 的 key)
~/clawd/skills/api-provider-setup/scripts/sync-agent-auth.sh --provider zai
# 只同步指定 agent
~/clawd/skills/api-provider-setup/scripts/sync-agent-auth.sh --agent quant
# 预览(不实际修改)
~/clawd/skills/api-provider-setup/scripts/sync-agent-auth.sh --dry-run
# 同步后重启
openclaw gateway restart
配置优先级链:
auth-profiles.json (缓存key) > models.json (provider定义) > openclaw.json (全局配置)
完整改 Key 流程:
openclaw.json → models.providers.<provider>.apiKeysync-agent-auth.sh [--provider <name>]openclaw gateway restart完整改模型流程:
openclaw.json → agents.list[] 或 agents.defaults.modelsync-agent-auth.sh(清除旧 auth 缓存+错误计数)openclaw gateway restart症状:消息发送成功,但 AI 返回 404 status code (no body)
原因:供应商的 API 格式配置错误。
诊断:
# 测试 Anthropic Messages API 格式
curl -X POST "https://your-api-endpoint/v1/messages" \
-H "Content-Type: application/json" \
-H "x-api-key: YOUR_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-d '{"model":"model-id","max_tokens":10,"messages":[{"role":"user","content":"hi"}]}'
# 测试 OpenAI Completions API 格式
curl -X POST "https://your-api-endpoint/v1/chat/completions" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{"model":"model-id","messages":[{"role":"user","content":"hi"}],"max_tokens":10}'
解决:
确认供应商使用的 API 格式:
/v1/messages,请求体包含 messages 数组/v1/chat/completions,请求体包含 messages 数组修改 models.json 中的 api 字段:
{
"providers": {
"your-provider": {
"api": "anthropic-messages" // 或 "openai-completions"
}
}
}
重启 Gateway:
openclaw gateway restart
案例:
"api": "anthropic-messages""api": "openai-completions""api": "anthropic-messages"testing
通用自媒体文章自动发布工具。支持百家号、搜狐号、知乎、微信公众号、小红书、抖音号六个平台的自动化发布流程。使用Playwright自动化实现平台导航和发布,支持通过storageState管理Cookie实现账号切换。
development
# SKILL.md - Model Configuration Status (mcstatus) ## 触发条件 - `/mcstatus` 命令 - 用户询问模型配备、模型配置、model status、模型列表等 ## 功能 实时生成 Agent + Cron 的模型配置报告,展示当前所有 agent 的主模型/fallback链和所有 cron 任务的模型分配。 ## 执行步骤 ### Step 1: 收集 Agent 模型配置 读取各 agent 的 models.json 获取主模型和 fallback 链: ```bash for agent in main ops code quant data research content market finance pm law product sales batch; do config=$(cat ~/.openclaw/agents/$agent/agent/models.json 2>/dev/null) if [ -n "$config" ]; then echo "=== $agent
tools
MCP 服务器智能管理助手。自动检测 MCP 可用性、智能开关、功能问答,提供人性化的 MCP 管理体验。
tools
从GitHub搜索并自动安装配置MCP(Model Context Protocol)服务器工具到Claude配置文件。当用户需要安装MCP工具时触发此技能。工作流程:搜索GitHub上的MCP项目 -> 提取npx配置 -> 添加到~/.claude.json -> 处理API密钥(如有)。