Repository navigation
feat(volcengine): add Ark Seedream image generation, editing, and pricing (lts/1.108.x) - #54507
Conversation
Only the ensure_api_route helper of BerriAI#47535, which the Volcengine image configs use to append /api/v3 once. Partial backport of 66c8f5b (BerriAI#47535) to lts/1.108.x.
Backport to lts/1.108.x. The line has no image fan-out, so n above 1 answers 400 unless drop_params drops it, and the image_to_data_url helper main already had comes with this commit. (cherry picked from commit c9fb012) Co-Authored-By: AaronHowell <111272993+AaronHowell@users.noreply.github.com>
Backport to lts/1.108.x. The line routes image costs through an elif chain, so Volcengine gets its own branch there in place of main's provider match table. (cherry picked from commit 3900411) Co-Authored-By: AaronHowell <111272993+AaronHowell@users.noreply.github.com>
Co-Authored-By: AaronHowell <111272993+AaronHowell@users.noreply.github.com> (cherry picked from commit fb7707f)
…nd drop retired Seedream rows Ark does not bill images it failed to output, so the cost calculator now skips data items with no url or b64_json. In a layer decomposition every output, the z_index 0 base included, bills at the layer rate. Seedream 4.5, 5.0 lite and the 4.0 250828 snapshot were shut down on 2026-11-24 per Ark's deprecation notice, so their rows are removed and 4.0 is priced under its replacement IDs 260415 and 20260415. Backport to lts/1.108.x. The line's provider_endpoints_support.json keeps its own sparse rows, so only Volcengine's image_generations and image_edits flags are set instead of main's full regeneration. (cherry picked from commit 99e2d06)
…rl helper Partial backport of 8e8f6dc to lts/1.108.x, only its move of the fal_ai image data URL helper into litellm.images.utils, which the Volcengine image edit config also reads
…r own helper Mirrors the _get_model_independent_image_edit_config split from bbc68e2 on main, so adding the Volcengine edit config keeps get_provider_image_edit_config under the line's C901 limit
… table Mirrors main's _model_priced_image_cost_calculator from 8e8f6dc for the providers the line has, so adding the Volcengine image cost calculator keeps route_image_generation_cost_calculator under the C901 limit
Partial backport of BerriAI#50481 to lts/1.108.x. Ported from 94861ec (main), only the output_cost_per_image_1K and output_cost_per_image_2K fields on ModelInfo, CustomPricingLiteLLMParams, get_model_info and the dashboard API types. Without them the line dropped the Seedream tier prices before the Volcengine image cost calculator saw them, so a 1K image billed at the 2K price
…lcengine_seedream_images
…yment prices first, and keep stream away from Ark Image generation and edits now use api_base as given with the same default and key order as Volcengine chat, and no longer read ARK_API_BASE. A user longer than Ark's 64-character safety_identifier limit is sent as its sha256. stream is rejected (or dropped with drop_params) whether it arrives top-level or inside extra_body, and a multipart stream="false" is not a stream request. Edits forward extra_body fields to Ark. A deployment's own per-image and tier prices now win over the shared layer and tier rows On lts/1.108.x the line has no image fan-out, so n above 1 still answers a 400 unless drop_params, and the stream flag is read by a local helper since the line has no litellm/images/streaming.py (cherry picked from commit abf4325)
…BytePlus Seedream names Image generation sends deployment and caller extra_headers as HTTP headers again, so a caller Authorization header replaces the Ark key, and keeps them out of the JSON body. The endpoint falls back to VOLCENGINE_API_BASE, then ARK_API_BASE. BytePlus dola-* and seedream-* names get rows at BytePlus's USD list price, and the 2K tier starts past 1536^2 x 1.05^2 pixels as Ark's price page states. On lts/1.108.x the line has no _PROVIDERS_RESOLVING_THEIR_OWN_IMAGE_BASE, so it adds that tuple with Volcengine alone and keeps the caller's api_base for it, since get_llm_provider would otherwise fill in the Ark default and hide ARK_API_BASE (cherry picked from commit 2b825f0)
This reverts commit 2b49588.
…on Seedream images A deployment priced per pixel or per input image is billed by its own price again. Direct SDK generation retries a 429 or 5xx twice by default, honors max_retries and leaves retries to the router on proxy calls. Async generation runs on the async handler, and forwarded client headers reach Ark lts/1.108.x has no image fan-out, so the n fan-out cap and the edit stream drop from main are left out. n above 1 is still refused, or ignored with drop_params, as before (cherry picked from commit 08b98f8)
…on Seedream images A global litellm.api_key set for another provider no longer reaches Ark when VOLCENGINE_API_KEY or ARK_API_KEY is set, matching Volcengine chat. Adds a test for a deployment that sets both image prices. (cherry picked from commit cf88476)
[Medium impact] The latest changes appear safe to merge, with both previous retry defects fixed
|
| def ark_image_generation_url(api_base: str | None) -> str: | ||
| base: Final = ( | ||
| api_base or get_secret_str("VOLCENGINE_API_BASE") or get_secret_str("ARK_API_BASE") or ARK_DEFAULT_API_BASE | ||
| ).rstrip("/") | ||
| if base.endswith("/images/generations"): | ||
| return base | ||
| return join_api_base(base, "images/generations") |
There was a problem hiding this comment.
Required live proof is incomplete
The live proof at e846d7a2e3d covers BytePlus single-image generation, editing, and rejected n. It omits mainland Volcengine and layer billing. The repository requires live proxy/provider proof for the relevant changed paths, even when keys are unavailable. Add those commands and outputs before merging
Rule Used: Apply this rule only to PRs that fix LLM translation bugs or add LLM translation features. LLM translation means converting requests, responses, streaming events, tool calls, and errors between the API a caller uses on LiteLLM (any endpoint or SDK fu... (source)
There was a problem hiding this comment.
This backport gets one smoke per fix on the line. Layers ran live in #54076 (C6, C7, C12), and mainland is a Medium caveat
There was a problem hiding this comment.
You’re right that the line has one smoke for each of the main changed paths: generation, editing, and the n > 1 behavior. I don’t think those need to be repeated.
The remaining gap is narrower: the layer runs in #54076 are evidence for that PR, not this backport’s latest product commit (e846d7a2e3d); and the mainland caveat confirms that region was not live-tested here. The QA rule explicitly requires proof on this PR’s revision and says unavailable credentials do not waive it. So I’m keeping the finding, limited to a live layer-billing case and a mainland Volcengine smoke on e846d7a2e3d.
There was a problem hiding this comment.
Thanks—this closes the layer-billing gap: the live run at 972a6c9085d reports three layers billed at 0.064285713. Mainland Volcengine is still unverified at the latest product commit, 972a6c9085d, so that remains the outstanding QA item.
There was a problem hiding this comment.
The author ran cn-beijing live on main at 2b825f0, seven calls, all 200 and billed. We have no mainland key to rerun it here
There was a problem hiding this comment.
Thanks—that is useful evidence: seven live cn-beijing calls at 2b825f066c7 all returned 200 and billed, so mainland behavior was exercised on the source implementation. I understand there’s no mainland key to repeat that on this LTS branch; I’ll note the source-run evidence and retain the PR’s caveat that the backport itself was smoke-tested only against BytePlus.
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
… also prices input images A deployment that set input_cost_per_image with output_cost_per_image_1K or _2K fell back to the default image calculator, which billed only the input price. Tier prices now count as an output price for Volcengine, so the provider calculator bills each image at its tier. Also drops a test that only checked config classes (cherry picked from commit 07cd763)
|
bugbot run |
…Seedream image generation (cherry picked from commit 2431e89)
|
bugbot run |
…d let a call max_retries win (cherry picked from commit df875eb)
|
bugbot run |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 9741ace. Configure here.
Handwritten 1-3 sentence description
This brings Seedream image generation, image edits, and Seedream pricing from #54076 to lts/1.108.x, with every commit of #54076 picked. The line has no shared image fan-out, so
nabove 1 gets a 400 unlessdrop_paramsis setDetails
TLDR
Problem this solves:
How it solves it:
usertosafety_identifier, and return per-image fields inprovider_specific_fieldsapi_baseand the key from the deployment, then theVOLCENGINE_*andARK_*env varsUser Flow
Before: Ark's fields are lost, edits fail, and nothing is billed
POST https://litellm-domain/v1/images/generationsto a Seedream deployment"provider_specific_fields": nullandx-litellm-response-costis emptyPOST https://litellm-domain/v1/images/editsreturns HTTP 500,image edit is not supported for volcengineAfter: Ark's fields are kept, edits work, and both are billed
size,output_format, andbackgroundinprovider_specific_fields, andx-litellm-response-costshows the tier pricePOST https://litellm-domain/v1/images/editsreturns HTTP 200 with the edited image and its priceRelevant issues
LTS twin of #54076
Backport
Picks, every non-merge commit of #54076 through df875eb
nabove 1elifcost routingapi_baselookupAsyncHTTPHandlerparamsThe line has no shared image fan-out, so the first pick answers
nabove 1 with a 400 unlessdrop_paramsdrops it, and main's fan-out cap and edit stream drop are left out. Four commits bring narrow parts of main the picks build onSupporting commits and pick conflicts
cc9fcdf moves the fal_ai
image_to_data_urlhelper intolitellm/images/utils.pyand fdc4326 routes model-priced image calculators through one table, both as in 8e8f6dc66ed. d071edd splits out the model-independent image edit lookup as in #48998. a3cdf00 carries the 1K and 2K image tier prices throughget_model_infoas in #50481, without which a 1K Seedream image billed at the 2K price. 2b49588, anensure_api_routepick, is reverted by 6648cb6, so the pair changes nothing. b41bdce merges lts/1.108.x in cleanly. The 07cd763 pick conflicted only on where the line keeps the image price helper inutils.pyand on its single-image transformation test, so the helper change went in place and the line's assertions stayed. The 2431e89 pick conflicted only on context, so its client helper went in unchangedTests and make check
make checkpasses at 9741ace againstorigin/lts/1.108.x. The picked client test fails on 972a6c9 and passes on 8f375d8, the 3 pickedhttp_clienttests fail on 8f375d8 and pass on 2eb5b28, and 5 picked retry tests fail on 037504e and pass on 9741ace. At 972a6c9 the 450 test files the picks reach had 33143 passing and 11 failing, and all 11 pass when rerun alone on this branch, so none fails because of it. Before that pick, the full unit suite at e846d7a had 108005 passing and 40 failing, and the 75 picked Volcengine image tests all pass. Each failing test was rerun alone on this branch and on the line's merge base 5da336d, and none fails because of this branch. 38 pass when rerun alone, since they failed only under load, and 2 fail on the merge base tooPre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
uv run pytest tests/unit/<your_test_file>.py -v. Leave the suites (make test-unit-*,make test-unit) to CI: it finishes in ~15 minutes where a laptop takes an hour or moreDelays in PR merge?
If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).
Screenshots / Proof of Fix
One live smoke per fix on the line, with real BytePlus ModelArk calls. Before is the line's tip
14ed7dc64d1on port 29518 and After is this branch's tipe846d7a2e3don port 27454, each a 2-worker proxy on its own Postgres. The deployments are the ones in #54076's proof, andin.pngis a 1024x1024 Seedream 5.5 imagen=2, 5.0 flashBefore (14ed7dc)
C1, Seedream 5.5 edit
Steps and output
C2, Seedream 5.5 generation, 1K
Steps and output
C8,
n=2on 5.0 flashSteps and output
After (e846d7a)
C1, Seedream 5.5 edit
Steps and output
C2, Seedream 5.5 generation, 1K
Steps and output
C8,
n=2on 5.0 flashSteps and output
Tier prices fix, 972a6c9
Before is
e846d7a2e3dand After is972a6c9085d, on 2-worker proxies with real BytePlus calls. The tier deployment sets 0.01 per input image, 0.02 per 1K image and 0.05 per 2K imageL1 matches #54076's C6 price on main. Commands and output are in this gist
Supplied client fix, 8f375d8
No Volcengine or Ark env var is set, so the key and base URL come only from the client passed as
clientOpenAIclientAsyncOpenAIclientCommands and output are in this gist
Supplied client transport fix, 2eb5b28 to 9741ace
The call now goes through the client's own
http_client, sync and async, where 8f375d8 bypassed it (C37). 9741ace keeps a refused connection on that client, which 037504e retried around its proxy (C38)C37 and C38 steps and output
The client has its own
httpx.Client, whose request hook prints each request, andmax_retries=0. Dotenv loading is off and no Volcengine or Ark env var is setOpenAIclientAsyncOpenAIclientIn C38 the async client's proxy port refuses every connection, and the call passes no
max_retriesAPIConnectionErrorInternalServerErrorPicked unit tests against a gateway that answers 503 once prove a call's
max_retrieswins, else litellm retries twice, as on the base. Commands and output are in this gistType
🆕 New Feature
Caveats (if any)
Copied from #54076 and re-read against the line
Medium
nabove 1,quality, andstyleget a 400 withoutdrop_params, since the line has no image fan-out. The line's base got a 200 and 1 image from Ark (C8)Low
ARK_API_KEYbeforeVOLCENGINE_API_KEY, the other order from images. A follow-up is filedapi_base, BytePlus-only names get a 404 from cn-beijing, as beforeInternalServerError, as sync already did, notAPIConnectionError(C38). A follow-up is filedDecisions
nabove 1 instead of taking main's shared image fan-out, since that fan-out is a separate main feature that also changes Gemini. A 400 unlessdrop_paramsis litellm's rule for an unsupported param, and it beats the base's silent single imageFinal Attestation
Bugbot summary