模型发现技能
从AI提供商处获取最新的模型名称,使用他们的API。包括层级分类(快速/默认/重型)以进行路由决策和自动检测新模型。
变量
| 变量 |
默认 |
描述 |
| CACHE_TTL_HOURS |
24 |
缓存模型列表刷新前的时间 |
| ENABLED_ANTHROPIC |
true |
从Anthropic API获取Claude模型 |
| ENABLED_OPENAI |
true |
从OpenAI API获取GPT模型 |
| ENABLED_GEMINI |
true |
从Google API获取Gemini模型 |
| ENABLED_OLLAMA |
true |
从Ollama获取本地模型 |
| OLLAMA_HOST |
http://localhost:11434 |
Ollama API端点 |
| AUTO_CLASSIFY |
true |
使用模式匹配自动分类新模型 |
指令
强制性 - 按照下面的工作流程顺序执行。不要跳过步骤。
- 在任何技能中引用模型名称之前,检查是否存在最新数据
- 使用层级映射选择适当的模型(快速用于速度,重型用于能力)
- 定期检查新模型并进行分类
红旗 - 停止并重新考虑
如果你即将:
- 硬编码模型版本,如
gpt-5.2或claude-sonnet-4-5
- 在没有检查当前可用性的情况下使用记忆中的模型名称
- 在没有检查API密钥是否配置的情况下调用API
- 在提示时跳过新模型分类
停止 -> 阅读相应的食谱文件 -> 使用获取脚本
工作流程
获取模型
- [ ] 确定你需要哪些提供商的模型
- [ ] 检查是否存在缓存的模型列表:
cache/models.json
- [ ] 如果缓存是最新的(< CACHE_TTL_HOURS旧),则使用缓存数据
- [ ] 如果过时/缺失,运行:
uv run python scripts/fetch_models.py --force
- [ ] 检查点:验证输出中没有API错误
- [ ] 根据需要使用模型ID
检查新模型
- [ ] 运行:
uv run python scripts/check_new_models.py --json
- [ ] 如果发现新模型,查看输出
- [ ] 对于自动分类:
uv run python scripts/check_new_models.py --auto
- [ ] 对于交互式分类:
uv run python scripts/check_new_models.py
- [ ] 检查点:所有模型分配到层级(快速/默认/重型)
获取层级建议
- [ ] 阅读:
config/model_tiers.json了解当前层级映射
- [ ] 根据任务复杂性使用适当的模型:
- 快速:简单任务,高吞吐量,成本敏感
- 默认:通用目的,平衡
- 重型:复杂推理,研究,困难任务
模型层级参考
Anthropic Claude
| 层级 |
模型 |
CLI名称 |
| 快速 |
claude-haiku-4-5 |
haiku |
| 默认 |
claude-sonnet-4-5 |
sonnet |
| 重型 |
claude-opus-4-5 |
opus |
OpenAI
| 层级 |
模型 |
备注 |
| 快速 |
gpt-5.2-mini |
速度优化 |
| 默认 |
gpt-5.2 |
平衡旗舰 |
| 重型 |
gpt-5.2-pro |
最大能力 |
Codex(用于编码):
| 层级 |
模型 |
| 快速 |
gpt-5.2-codex-mini |
| 默认 |
gpt-5.2-codex |
| 重型 |
gpt-5.2-codex-max |
Google Gemini
| 层级 |
模型 |
上下文 |
| 快速 |
gemini-3-flash-lite |
见API输出 |
| 默认 |
gemini-3-pro |
见API输出 |
| 重型 |
gemini-3-deep-think |
见API输出 |
Ollama(本地)
| 层级 |
建议模型 |
备注 |
| 快速 |
phi3.5:latest |
小型;快速 |
| 默认 |
llama3.2:latest |
平衡 |
| 重型 |
llama3.3:70b |
大型;需要GPU |
CLI映射(用于spawn:agent技能)
| CLI工具 |
快速 |
默认 |
重型 |
| claude-code |
haiku |
sonnet |
opus |
| codex-cli |
gpt-5.2-codex-mini |
gpt-5.2-codex |
gpt-5.2-codex-max |
| gemini-cli |
gemini-3-flash-lite |
gemini-3-pro |
gemini-3-deep-think |
| cursor-cli |
gpt-5.2 |
sonnet-4.5 |
sonnet-4.5-thinking |
| opencode-cli |
anthropic/claude-haiku-4-5 |
anthropic/claude-sonnet-4-5 |
anthropic/claude-opus-4-5 |
| copilot-cli |
claude-sonnet-4.5 |
claude-sonnet-4.5 |
claude-sonnet-4.5 |
快速参考
脚本
# 获取所有模型(如果新鲜则使用缓存)
uv run python scripts/fetch_models.py
# 强制从API刷新
uv run python scripts/fetch_models.py --force
# 获取并检查新模型
uv run python scripts/fetch_models.py --force --check-new
# 检查新未分类模型(JSON输出供代理使用)
uv run python scripts/check_new_models.py --json
# 使用模式自动分类新模型
uv run python scripts/check_new_models.py --auto
# 交互式分类
uv run python scripts/check_new_models.py
配置文件
| 文件 |
目的 |
config/model_tiers.json |
静态层级映射和CLI模型名称 |
config/known_models.json |
所有分类模型的注册表,带时间戳 |
cache/models.json |
缓存的API响应 |
API端点
| 提供商 |
端点 |
认证 |
| Anthropic |
GET /v1/models |
x-api-key头 |
| OpenAI |
GET /v1/models |
Bearer令牌 |
| Gemini |
GET /v1beta/models |
?key=参数 |
| Ollama |
GET /api/tags |
无 |
输出示例
获取模型输出
{
"fetched_at": "2025-12-17T05:53:25Z",
"providers": {
"anthropic": [{"id": "claude-opus-4-5", "name": "Claude Opus 4.5"}],
"openai": [{"id": "gpt-5.2", "name": "gpt-5.2"}],
"gemini": [{"id": "models/gemini-3-pro", "name": "Gemini 3 Pro"}],
"ollama": [{"id": "phi3.5:latest", "name": "phi3.5:latest"}]
}
}
检查新模型输出(–json)
{
"timestamp": "2025-12-17T06:00:00Z",
"has_new_models": true,
"total_new": 2,
"by_provider": {
"openai": {
"count": 2,
"models": [
{"id": "gpt-5.2-mini", "inferred_tier": "fast", "needs_classification": false},
{"id": "gpt-5.2-pro", "inferred_tier": "heavy", "needs_classification": false}
]
}
}
}
集成
其他技能应该参考这个技能获取模型名称:
## 模型名称
对于当前的模型名称和层级,使用`model-discovery`技能:
- 层级:阅读`config/model_tiers.json`
- 新鲜数据:运行`uv run python scripts/fetch_models.py`
- 新模型:运行`uv run python scripts/check_new_models.py --json`
**不要硬编码模型版本号** - 它们很快会过时。
新模型检测
当检测到新模型时:
- 脚本将根据命名模式报告它们,并建议层级
- 匹配这些模式的模型将自动分类:
- 重型:
-pro,-opus,-max,thinking,deep-research
- 快速:
-mini,-nano,-flash,-lite,-haiku
- 默认:没有修饰词的基础模型名称
- 不匹配模式的模型需要手动分类
- 特殊模型(TTS,音频,转录)自动排除
代理查询新模型
当以编程方式检查新模型时:
# 如果新模型需要关注,则返回退出代码1
uv run python scripts/check_new_models.py --json
# 示例代理工作流程
if ! uv run python scripts/check_new_models.py --json > /tmp/new_models.json 2>&1; then
echo "检测到新模型 - 查看/tmp/new_models.json"
fi