Offer Seedream 5.0 in two resolution tiers, defaulting to the cheaper one - #165
Merged
Merged
Conversation
… one
ModelArk prices Seedream 5.0 pro by output pixel count: $0.045/image up
to 2.61 MP ("1.5K or lower"), $0.09 above (pricing page, model
dola-seedream-5-0-pro-260628). The gateway pinned `size: "2K"` (~4.2 MP)
on every request, so every image paid the upper rate with no way to ask
for the cheaper one. It is the only registered image model with such a
split — Seedream 4.5 and 5.0 Lite accept nothing under 2560x1440 — so it
is the only one that gains tiers.
`ModelConfig` grows `image_resolutions` / `image_default_resolution`:
each `ImageResolutionTier` carries its per-image price, its ratio ->
pixels table and the request params that select it (for ModelArk the
bare `size` keyword). The default tier's price and table are mirrored in
`per_image_price_usd` / `image_aspect_ratios`, pinned by a test, so
every code path that knows nothing about tiers keeps billing and shaping
the default correctly. Seedream 5.0 gets "1.5K" ($0.045, default, with
an exact-ratio table built inside ModelArk's [921,600, 4,624,220] window
and under the 2.61 MP line) and "2K" ($0.09, the old behaviour).
Requests select a tier with an optional `resolution` field, validated
before any provider work like `aspect_ratio` (400 for an unknown tier,
and for any value on a single-resolution model — it names a price, and
silently running at another one would bill something other than what
the client was quoted). The ratio resolves through the selected tier's
table; billing reads the tier's price. Omitted means the default, so
existing clients are unaffected — beyond their Seedream 5.0 images now
costing $0.045 at ~2.4 MP instead of $0.09 at ~4.2 MP.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YDiksXcrjvAhZEYYwg4mni
adambalogh
marked this pull request as ready for review
September 21, 2026 07:37
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
ModelArk prices Seedream 5.0 pro by output pixel count: $0.045/image up to 2.61 MP ("1.5K or lower"), $0.09 above (ModelArk pricing, model
dola-seedream-5-0-pro-260628). The gateway pinnedsize: "2K"(~4.2 MP) on every request, so every image paid the upper rate and no client could ask for the cheaper one.It is the only registered image model with such a split — Seedream 4.5 and 5.0 Lite accept nothing under 2560×1440 (image API docs) — so it is the only model that gains tiers.
What
model_registry.py: newImageResolutionTier(per-image price, ratio→pixels table, request params that select the tier) andModelConfig.image_resolutions/image_default_resolution, plusModelConfig.image_tier(resolution). Seedream 5.0 gets"1.5K"($0.045, default, exact-ratio table inside ModelArk's[921,600, 4,624,220]window and under the 2.61 MP line) and"2K"($0.09, the previous behaviour). The default tier's price/table are mirrored inper_image_price_usd/image_aspect_ratios— pinned by a test — so tier-unaware code paths keep billing and shaping the default correctly.resolutionfield on/v1/chat/completions(request model,_parse_chat_request,_chat_request_to_dict, OpenAPI). Validated before any provider work likeaspect_ratio: 400 for an unknown tier, and for any value on a single-resolution model (it names a price tier; silently running at another one would bill something other than what the client was quoted).image_generation.py: the tier supplies thesizekeyword on the auto path; a picked ratio resolves through the tier's table (2048x1152at 1.5K vs2560x1440at 2K for 16:9). Both the JSON generations and multipart edits paths.pricing.py: bills the tier's price.resolution= default tier, so existing clients are unaffected — beyond Seedream 5.0 images now costing $0.045 at ~2.4 MP instead of $0.09 at ~4.2 MP.The x402 challenge amount is the fixed
CHAT_COMPLETIONS_OPG_SESSION_MAX_SPEND, not derived from the per-image price, so the higher-tier settlement needs no change there.Tests
make lint(ruff + mypy) clean; the CI test command passes (456 passed, 6 skipped). New coverage: tier keyword and per-tier ratio sizes, 400s for unknown tier / tier on a single-resolution model, per-tier billing, the 1.5K table staying under the price line and the 2K table above it, and the default-tier mirroring invariant.Companion PRs
chat-api serves the tiers in the catalog; chat-app reads them and quotes the model "from" its default price. Neither sends
resolutionyet, so every request still runs at the default tier — the size control in Image Studio is a follow-up.🤖 Generated with Claude Code
https://claude.ai/code/session_01YDiksXcrjvAhZEYYwg4mni
Generated by Claude Code