Skip to content

Commit 0c85b87

Browse files
authored
fix(frontend): provider-reported cost tooltip shows $0 for usage.cost_details format (#440)
When provider-reported cost arrives via `usage.cost_details` (not SSE `: cost`), the tooltip read `data.request_cost_usd` which was undefined, causing it to display **$0** while the logs row correctly showed the real cost. **Fix:** Read cost from both formats: - `data.request_cost_usd` — SSE `: cost` comments - `data.cost_details?.total_cost` — `usage.cost_details` path **File changed:** - `packages/frontend/src/components/ui/CostToolTip.tsx`
1 parent 3317d14 commit 0c85b87

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

packages/frontend/src/components/ui/CostToolTip.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,14 @@ export const CostToolTip: React.FC<CostToolTipProps> = ({ source, costMetadata,
113113
</div>
114114
);
115115
} else if (s === 'provider_reported') {
116+
// Support both SSE `: cost` format (request_cost_usd) and usage.cost_details format
117+
const reportedCost = data.request_cost_usd ?? data.cost_details?.total_cost;
116118
content = (
117119
<div style={containerStyle}>
118120
<div style={headerStyle}>Source: Provider Reported</div>
119121
<div style={gridStyle}>
120122
<span style={labelStyle}>Cost:</span>
121-
<span style={valueStyle}>${formatRate(data.request_cost_usd)}</span>
123+
<span style={valueStyle}>${formatRate(reportedCost)}</span>
122124

123125
{data.cache_savings_usd !== undefined && (
124126
<>

0 commit comments

Comments
 (0)