快速结论:该报错出现在 LobeChat 接入 OpenRouter 图像/视频生成模型时,由于其 catalog 适配器只读取文本 token 定价字段,导致图像/视频生成模型的单价显示为 0 或被错误标记为 “(free)”。优先排查 OpenRouter 适配器中的 `isFree` 判断逻辑及 `ModelPricing` 类型定义。
适用环境:LobeChat(lobehub/lobe-chat),OpenRouter 作为模型供应商,涉及模型库文件 `packages/model-runtime/src/providers/openrouter/index.ts` 和 `packages/model-bank/src/aiModels/openrouter.ts`。
最快修复方案:暂无确认的一步修复方案。该 Issue 为 Bug 报告,Dosu 机器人已给出根因分析和修复方向,但尚未提供已验证的补丁。
注意事项:修复需要同时修改类型定义、适配器逻辑和内置模型卡片数据,涉及多个包的协同改动,不要单独修改某一处。
问题场景
在 LobeChat 中使用 OpenRouter 的图像生成或视频生成模型时,模型详情面板中的定价单位显示错误、显示为缺失或金额为 0。由于这些生成模型的文本 token 价格确实为 0,适配器会将其误判为免费模型并追加 “(free)” 标签,导致 C 端用户无法看到真实的按图像/按视频计费价格。
报错原文
Image and video generator usage pricing is displayed incorrectly
Generator cards with zero prompt/completion rates therefore show missing or misleading usage amounts in Create.
Generator models are not classified as free because their text-token prices are zero.
原因分析
根因已定位:OpenRouter catalog 适配器(位于 `packages/model-runtime/src/providers/openrouter/index.ts`)在转换来自实时 API 的模型数据时,只读取了文本 token 的定价字段(`pricing.prompt`、`pricing.completion`、`pricing.input_cache_read`、`pricing.input_cache_write`)。虽然 `ModelPricing` 类型中定义了 `image` 字段,但适配器从未消费该字段,也没有处理视频生成的定价字段。
具体逻辑链:
- 图像/视频生成模型的文本 token 价格为 0;
- 适配器中的
isFree判断为inputPrice === 0 && outputPrice === 0 && !displayName.endsWith('(free)'); - 该判断对生成模型恒为 true,因此被误标记为免费;
- 实际计费通过模态专属字段(modality-specific fields)进行,但适配器完全忽略这些字段,导致价格显示丢失或误导。
需要注意:这是 Issue 讨论中 Dosu 机器人的代码追踪结论,修复方案属于推断,尚未经过真实验证。
环境排查
- 确认 LobeChat 源码版本是否包含
packages/model-runtime/src/providers/openrouter/index.ts中的isFree逻辑(约第 132 行)。 - 检查
packages/model-runtime/src/providers/openrouter/type.ts中的ModelPricing类型是否仅定义了image?字段,缺少视频定价字段。 - 确认
packages/model-bank/src/types/aiModel.ts中已定义PricingUnit[]数据类型(含imageOutput、videoGeneration、second、video、megapixel等单位)。 - 验证内置 OpenRouter 模型卡片(
packages/model-bank/src/aiModels/openrouter.ts)是否缺少approximatePricePerImage/approximatePricePerVideo字段。
解决步骤
- 扩展
ModelPricing类型:在packages/model-runtime/src/providers/openrouter/type.ts中,为 OpenRouter 暴露的视频定价字段添加类型定义(目前仅有image?)。 - 更新 catalog 适配器:修改
packages/model-runtime/src/providers/openrouter/index.ts:
a. 读取pricing.image及所有视频定价字段;
b. 使用packages/model-bank/src/types/aiModel.ts中已有的结构化定价类型,输出PricingUnit[]条目(例如imageOutput、videoGeneration);
c. 修正isFree判断,在追加 “(free)” 前同时检查模态专属价格。 - 持久化近似价格:在内置 OpenRouter 模型卡片(
packages/model-bank/src/aiModels/openrouter.ts)中,为所有图像/视频生成模型补充approximatePricePerImage/approximatePricePerVideo字段,避免实时 catalog 只返回 0 文本价格时显示错误。可参考 Gemini 图像模型的现有写法。 - 补充回归测试:覆盖图像输出 token、USD/美分视频秒、视频 token 计费等场景的定价断言。
验证方法
修复后,在 LobeChat 的模型列表(Create 页面)中打开 OpenRouter 图像/视频生成模型的详情面板,确认:
- 定价单位显示为图像生成或视频生成,而不是文本 token;
- 图像按张计价、视频按秒/美分/固定价格显示的金额正确;
- 生成模型不再被标记为 “
(free)“; - 执行一次实时 catalog 刷新后,内置模型的近似价格仍然保留。
参考来源
AI 工具推荐
想把多个 AI 模型放在一个入口?
GamsGo AI 集成 ChatGPT、DeepSeek、Gemini、Claude、Midjourney、Veo 等常用模型,适合写作、绘图、视频和日常 AI 工作流。
推广链接:通过此链接购买,我可能获得佣金,不影响你的价格。
这个方案解决了吗?
可以继续搜索完整报错,或查看同一工具的其他排查指南。


![[BUG]: Fetch Failed (or did it actuall not??)](https://www.chat-gpts.plus/wp-content/uploads/2026/08/6127-fc3f8e1f-768x403.jpg)