# OpenRouter图片链路预检器
# OpenRouter 图片链路预检器:诊断流程样例
## 场景
用户反馈扩展里点击生成图片后长时间无结果,UI 只报 `OpenRouter returned no generated image`。
## 输入
| 项目 | 示例 |
| --- | --- |
| key 来源 | extension-config |
| 模型列表 | `openai/gpt-5.4-image-2`, `openai/gpt-5-image-mini` |
| 超时 | 180s |
| prompt | `simple product icon on white background` |
## 流程
1. 运行 `python scripts/openrouter_image_route_smoke.py --key-source extension-config --models openai/gpt-5.4-image-2,openai/gpt-5-image-mini --timeout-seconds 180`。
2. 工具先发轻量 chat 请求,确认 key/account 可用;如果这里失败,直接归因为认证、额度或 OpenRouter 基础链路。
3. 工具按模型发图片请求,记录耗时、HTTP 状态、错误体、finish_reason 和响应字段路径。
4. 解析器同时检查 `message.images[0].image_url.url` 与 `message.content` 中可能存在的图片字段,避免把 parse miss 误报成 provider 无图。
## 结果判读
| 结果 | 结论 | 下一步 |
| --- | --- | --- |
| key check 失败 | key/account 不通 | 更换 key、查额度、查 OpenRouter 账号状态 |
| A 模型 180s timeout,B 模型 48s 成功 | provider/model 路由差异 | 默认切到可用模型,并记录不可用模型给配置层降级 |
| HTTP 成功但解析不到图片 | 解析器缺字段 | 扩展 `message.images` 与 `message.content` 的图片字段解析 |
| 所有模型都成功 | 当前链路健康 | 回到业务 prompt、前端状态管理或下载展示层排查 |
## 期望输出片段
```json
{
"key_check": "ok",
"models": [
{"model": "openai/gpt-5.4-image-2", "status": "timeout", "elapsed_seconds": 180.0},
{"model": "openai/gpt-5-image-mini", "status": "ok", "elapsed_seconds": 48.7, "image_path": "message.images[0].image_url.url"}
],
"verdict": "key_ok_model_route_issue"
}
```