Skip to content

Offer Seedream 5.0 in two resolution tiers, defaulting to the cheaper one - #165

Merged
adambalogh merged 1 commit into
mainfrom
og/zen-noether-uptroo
Sep 21, 2026
Merged

adambalogh merged 1 commit into
mainfrom
og/zen-noether-uptroo

Conversation

@adambalogh

Copy link
Copy Markdown
Contributor

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 pinned size: "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: new ImageResolutionTier (per-image price, ratio→pixels table, request params that select the tier) and ModelConfig.image_resolutions / image_default_resolution, plus ModelConfig.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 in per_image_price_usd / image_aspect_ratios — pinned by a test — so tier-unaware code paths keep billing and shaping the default correctly.
  • Request: optional resolution field on /v1/chat/completions (request model, _parse_chat_request, _chat_request_to_dict, OpenAPI). 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 tier; silently running at another one would bill something other than what the client was quoted).
  • image_generation.py: the tier supplies the size keyword on the auto path; a picked ratio resolves through the tier's table (2048x1152 at 1.5K vs 2560x1440 at 2K for 16:9). Both the JSON generations and multipart edits paths.
  • pricing.py: bills the tier's price.
  • Omitted 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 resolution yet, 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

… 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
adambalogh marked this pull request as ready for review September 21, 2026 07:37
@adambalogh
adambalogh merged commit 7dde82f into main Sep 21, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant