llm: get costs from server
Calculating costs on the client has the advantage
that it works when not using skaband.
It requires that we maintain multiple sources of truth, though.
And it makes it very challenging to add serverside tools,
such as Anthropic's web tool.
This commit switches sketch to rely on the server for all costs.
If not using skaband, no costs will be calculated, which also
means that budget constraints won't work.
It's unfortunate, but at the moment it seems like the best path.
diff --git a/llm/gem/gem.go b/llm/gem/gem.go
index 178df68..1621f2d 100644
--- a/llm/gem/gem.go
+++ b/llm/gem/gem.go
@@ -431,14 +431,9 @@
}
}
- // For Gemini 2.5 Pro Preview pricing: $1.25 per 1M input tokens, $10 per 1M output tokens
- // Convert to dollars
- costUSD := float64(inputTokens)*1.25/1_000_000.0 + float64(outputTokens)*10/1_000_000.0
-
return llm.Usage{
InputTokens: inputTokens,
OutputTokens: outputTokens,
- CostUSD: costUSD,
}
}
@@ -573,6 +568,7 @@
ensureToolIDs(content)
usage := calculateUsage(gemReq, gemRes)
+ usage.CostUSD = llm.CostUSDFromResponse(gemRes.Header())
stopReason := llm.StopReasonEndTurn
for _, part := range content {