Ingested cost_details without a pricing-table model match never populate effective cost – counted in aggregates but rendered as $0.00 in tab

该问题发生在通过 OTel ingestion 直接摄入 cost_details / usage_details ,但观测对象(observation)的 model 没有匹配到定价表时:公共 API 和 Metrics API 会统计这些成本,但 UI 表格读取的是 effective cost

快速结论:该问题发生在通过 OTel ingestion 直接摄入 cost_details / usage_details,但观测对象(observation)的 model 没有匹配到定价表时:公共 API 和 Metrics API 会统计这些成本,但 UI 表格读取的是 effective costDetails/totalCost,因此显示为 $0.00。核心表现为 Ingested cost_details without a pricing-table model match never populate effective cost - counted in aggregates but rendered as $0.00 in tab。优先排查该观测的 model 是否在自定义 pricing table 中有对应条目。

适用环境:Langfuse Cloud(us.cloud.langfuse.com),v4 project;Python SDK 4.14.2;OTel ingestion;涉及 generationtool 类型观测。

最快修复方案:暂无确认的一步修复方案。Issue 中已确认官方在 langfuse/langfuse#15717 中修复,需升级到包含该修复的版本;在此之前,可使用自定义 pricing table 的 model.name + usage_details 让系统计算 effective cost,从而使各表面渲染一致。

注意事项:定价表 workaround 已被 Issue 作者验证有效,但要求你的观测能对应到已配置的模型;对于 tool 类型观测,Python SDK 可能直接丢弃 usage_details / cost_details 参数,需要另行确认或单独上报。

问题场景

用户在 Langfuse Cloud v4 项目中使用 Python SDK 4.14.2 通过 OTel ingestion 写入观测数据,并直接传入 usage_detailscost_details,例如对非 LLM 的 API 调用(网页抓取、搜索服务)按次计费并记录到 tool 类型观测。同一个观测在不同 API 表面返回值不一致:公共 API 返回 costDetailscalculatedTotalCost,Metrics API 会计入 totalCost,但观测表格 / Trace 视图(TRPC generations.all)返回 costDetails: {}totalCost: 0,最终渲染成 $0.00。

报错原文

Ingested cost_details without a pricing-table model match never populate effective cost - counted in aggregates but rendered as $0.00 in tab

原因分析

可能原因:文档声明直接摄入的 cost_details 会被“按原样使用(verbatim)”,但实际 ingestion 流程只将其放入 provided_cost_details / provided_usage_details字段;只有观测的 model 匹配到定价表定义时,系统才会计算并填充 effective cost_details。Issue 中的对照实验表明,同样内容只要加上匹配自定义 pricing table 的 model.name + usage_details,就能正确计算并渲染,说明 promotion 逻辑被“模型匹配”这一条件卡住了,而不是观测类型限制。

环境排查

  • 确认 Langfuse 环境是否为 Cloud v4 project(us.cloud.langfuse.com)。
  • 确认 Python SDK 版本是否为 4.14.2,并确认是否走 OTel ingestion。
  • 确认观测对象写入时的 model 字段是否为空,或是否在自定义 pricing table 中有匹配定义。
  • 确认观测类型:Issue 中在 generation 类型上复现,tool 类型也可能受影响,但注意 SDK 对 tool 类型可能丢弃 cost_details 参数。
  • 对比同一观测的公共 API 响应和 TRPC generations.all 响应,检查 costDetails/providedCostDetails 字段。

解决步骤

  1. 在 UI 或公共 API 中查看该观测,确认 ingestion 是否写入了 providedUsageDetailsprovidedCostDetails
  2. 如果 cost 确实已写入 provided 字段但 effective 字段为空,先检查该观测的 model 值;尝试在自定义 pricing table 中为这个 model.name 配置价格定义,并传入匹配的 usage_details
  3. 如果不希望依赖 pricing table,可等待官方修复 langf

    参考来源

    langfuse/langfuse #15696

    GamsGo AI

    AI 工具推荐

    想把多个 AI 模型放在一个入口?

    GamsGo AI 集成 ChatGPT、DeepSeek、Gemini、Claude、Midjourney、Veo 等常用模型,适合写作、绘图、视频和日常 AI 工作流。

    了解 GamsGo AI

    推广链接:通过此链接购买,我可能获得佣金,不影响你的价格。

    这个方案解决了吗?

celebrityanime
celebrityanime
文章: 16744

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注