Repository navigation
fix(providers): replace shut-down gpt-image-1, correct model prices, catch dead models at boot - #154
Merged
Merged
Conversation
OpenAI bills gpt-5.4-mini at $0.75 input, $0.075 cached input and $4.50 output per 1M tokens; the old $0.15/$0.60 table recorded text costs 5-7.5x too low. Prices now live in a dated, sourced catalog, cached prompt tokens bill at the cached rate, and an unpriced response snapshot falls back to the configured model instead of raising after the call was paid for. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
OpenAI shut gpt-image-1 down on 2026-10-23, so image generation with the shipped default failed. gpt-image-2.5-flare is OpenAI's named replacement. GPT Image models bill per token, so cost now comes from response.usage at catalog rates, falling back to a labelled per-image estimate only when usage is missing; PNG output is requested to match the stored extension. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An unknown or unpriced model was only discovered after the paid API call, and nothing flagged a configured model past its shutdown date. Settings now checks both OpenAI models against the catalog in openai mode: a shut-down model fails in every environment, and an unknown, wrong-kind or unpriced one fails outside local. Errors name the env var and replacement. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gpt-image-1's shutdown went unnoticed until image generation broke. check_model_lifecycle fails if a configured model is unknown, unpriced, retired or within --days of a catalogued shutdown, or if OpenAI's deprecations page lists it as deprecated (substitute-only mentions don't count; an unreadable page fails as "could not verify"). Runs weekly in CI. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Eslam93
marked this pull request as ready for review
November 6, 2026 18:56
This was referenced Nov 7, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Two bugs, and a gap that let the first one happen:
OPENAI_IMAGE_MODEL=gpt-image-1was shut down by OpenAI on 2026-10-23.gpt-5.4-miniwas priced at $0.15 / $0.60 per 1M tokens; OpenAI's price is $0.75 input, $0.075 cached input and $4.50 output.Every price, model id and date comes from OpenAI's own docs, read on 2026-11-06: the pricing page, the model pages for gpt-5.4-mini and gpt-image-2.5-flare, the image-generation guide, the Images API reference and the deprecations page.
What changed
fix(pricing)backend/app/core/model_catalog.py: one dated catalog of model ids, prices, shutdown dates and replacements, each with a source URL.gpt-5.4-miniis priced correctly, and cached prompt tokens bill at the cached rate. Cost lookup tries the snapshot the API reports, then the configured model, so a new snapshot id never fails a call that's already paid for.fix(images)gpt-image-2.5-flare, OpenAI's named replacement for gpt-image-1 and labelled "Default" on its model page. GPT Image models bill per token, so cost now comes fromresponse.usage: text in $5, image in $8, image out $30 per 1M, with text output unbilled. Ifusageis ever missing, a clearly labelled per-image estimate is recorded and a warning logged. PNG output is requested explicitly, because storage saves.png. Retry and error handling are unchanged.feat(config)AI_PROVIDER_MODE=openaionly). A shut-down model fails in every environment, with a message naming the env var, the shutdown date and the replacement. Unknown, unpriced or wrong-kind models fail outsidelocal.cipython -m app.scripts.check_model_lifecycleplus.github/workflows/model-lifecycle.yml, running weekly, manually, and on PRs that touch the catalog, the script orconfig.py. It checks the configured models against the catalog and against OpenAI's deprecations page. A model that appears only as a substitute there doesn't trip it. If the page can't be fetched or parsed, the job fails loudly instead of passing blind.Docs updated for current-state claims only: README, ARCHITECTURE and
.env.example. DEVLOG history is left alone. The old ~$0.005-per-piece and ~$3–8-per-week estimates were calculated from the wrong price table, so they were removed rather than re-guessed.Behaviour changes to know about
.envwithOPENAI_IMAGE_MODEL=gpt-image-1, copied from the old.env.example, now refuses to boot, even inlocal. The error says to setgpt-image-2.5-flare.httpxmoved from the dev group to the runtime dependencies, because the lifecycle script, which ships inapp/, imports it.Verification
ruff check,ruff format --checkandmypy app(strict) pass.pytest: 466 passed (331 on main). Coverage is 89.05%, up from 86.84%, with integration tests run against a local Postgres. New modules:model_catalog.pyandcheck_model_lifecycle.pyat 100%.gpt-image-1(2026-10-23) and does not flaggpt-image-2.5-flare.Not verified: no live OpenAI API call was made, because no API key was used. Before relying on image generation in production, generate one image with
gpt-image-2.5-flareand check that the recorded cost matches the usage tokens.Stack
This is PR 1 of 3. Next is backend hardening, #155 (stacked on this one), then frontend hardening, #156 (stacked on that). Merge them in order.
🤖 Generated with Claude Code