-
-
Notifications
You must be signed in to change notification settings - Fork 181
Closed
Labels
Description
Summary
The current billing logic does not correctly handle image generation models like gemini-3-pro-image-preview. The system treats IMAGE output tokens the same as TEXT tokens, resulting in ~7.6x undercharging.
Price Configuration
[models."gemini-3-pro-image-preview"]
mode = "image_generation"
input_cost_per_token = 0.000002
output_cost_per_token = 0.000012
output_cost_per_image = 0.134
output_cost_per_image_token = 0.00012Example usageMetadata
{
"promptTokenCount": 326,
"candidatesTokenCount": 2340,
"totalTokenCount": 3003,
"promptTokensDetails": [
{ "modality": "TEXT", "tokenCount": 326 }
],
"candidatesTokensDetails": [
{ "modality": "IMAGE", "tokenCount": 2000 }
],
"thoughtsTokenCount": 337
}Current vs Expected Billing
| Item | Current Calculation | Expected Calculation |
|---|---|---|
| Input TEXT | 326 × $0.000002 = $0.000652 | 326 × $0.000002 = $0.000652 |
| Output IMAGE | 2000 × $0.000012 = $0.024 | 2000 × $0.00012 = $0.24 |
| Output TEXT | (included above) | 340 × $0.000012 = $0.00408 |
| Thoughts | 337 × $0.000012 = $0.00404 | 337 × $0.000012 = $0.00404 |
| Total | $0.0328 | $0.2488 |
Difference: ~7.6x undercharging
Root Cause
response-handler.ts:extractUsageMetricsdoes not parsecandidatesTokensDetailsto distinguish IMAGE vs TEXT modalitycost-calculation.ts:calculateRequestCostdoes not useoutput_cost_per_image_tokenfield for IMAGE tokens
Suggested Fix
- Extend
UsageMetricstype to includeoutput_image_tokens - Parse
candidatesTokensDetailsinextractUsageMetricsto extract IMAGE token count - Update
calculateRequestCostto applyoutput_cost_per_image_tokenfor image output tokens
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Projects
Status
Done