Skip to content

gpt-image-1-mini incorrect price estimation in UI #5

@xinpehr

Description

@xinpehr

Description

The model selector displays 3 credits as the estimated price per image for gpt-image-1-mini, but the actual cost deducted is ~10 credits. This causes confusion and a poor user experience.

Root Cause

The estimation in ImagineView.php only calculates output token cost:

// src/Presentation/RequestHandlers/App/ImagineView.php (line 111-114)
$model['estimation'] = $this->calc->estimate(
    $model['key'],
    CostCalculator::OUTPUT  // only output tokens — misses image_input tokens!
)->value;

Estimation formula:

multiplier (1875) × output_rate (0.0016) = 3 credits  ← shown in UI

However, OpenAI charges for 3 token types, which are all summed in ImageService.php:

// src/Ai/Infrastructure/Services/OpenAi/ImageService.php (line 154-157)
$tc = $this->calc->calculate($resp->usage->input_tokens_details->text_tokens,  $model, CostCalculator::INPUT);
$ic = $this->calc->calculate($resp->usage->input_tokens_details->image_tokens,  $model, CostCalculator::IMAGE);
$oc = $this->calc->calculate($resp->usage->output_tokens,                       $model, CostCalculator::OUTPUT);
$cost = new CreditCount($tc->value + $ic->value + $oc->value);

Actual cost breakdown for a real generation (1536×1024):

Token type Tokens Rate Cost
Text input (prompt) ~500 0.0004 ~0.20 credits
Image input ~13,480 0.0005 ~6.74 credits
Output ~1,875 0.0016 ~3.00 credits
Total ~9.94 credits

The image_input_tokens (~13,480) returned by the OpenAI API (usage.input_tokens_details.image_tokens) represent internal generation compute and are never accounted for in the estimation.

Fix Applied

Updated multiplier for gpt-image-1-mini from 18756250 in:

  • config/registry.json
  • config/registry.base.json
- "multiplier": 1875,
+ "multiplier": 6250,

New estimation: 6250 × 0.0016 = 10 credits ✓

Affected Models

Model Status Was affected
gpt-image-1-mini ✅ Active ✅ Fixed
gpt-image-1.5 ✅ Active No (already had multiplier 6250)
gpt-image-1 ❌ Disabled
dall-e-3, fal.ai, Stable Diffusion, etc. No (flat-rate pricing)

Long-term Recommendation

The estimation logic should be refactored to separately estimate all three token types (INPUT + IMAGE + OUTPUT) using dedicated multipliers per token type in the model registry, rather than relying on a single multiplier value applied only to the output rate.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions