Skip to content

fix(azure_ai): translate size param to width/height for flux.2-pro image edits - #36645

Closed
guptaishaan wants to merge 1 commit into
BerriAI:litellm_internal_stagingfrom
guptaishaan:fix/issue-36644-5767
Closed

guptaishaan wants to merge 1 commit into
BerriAI:litellm_internal_stagingfrom
guptaishaan:fix/issue-36644-5767

Conversation

@guptaishaan

Copy link
Copy Markdown
Contributor

TLDR

Problem this solves:

AzureFoundryFlux2ImageEditConfig.map_openai_params was passing size verbatim into the request body, but the Azure AI Foundry FLUX 2 endpoint (backed by BFL's API) does not accept a size key. It only accepts width and height as separate integers. As a result, every images.edit call through this config produced a 1024x1024 image regardless of what size was passed.

How it solves it:

In map_openai_params, when the size key is encountered it is now split on "x" and emitted as width/height integers instead. Direct width/height params are also accepted and forwarded unchanged. Both keys are added to get_supported_openai_params so they are not dropped earlier in the pipeline.

User Flow

Call litellm.image_edit(model="azure_ai/flux.2-pro", ..., size="896x1184") and receive an image at 896x1184 instead of the default 1024x1024.

Relevant issues

Fixes #36644

Linear ticket

Pre-Submission checklist

  • I have added meaningful tests
  • My PR passes all CI/CD checks (e.g., lint, format, unit tests)
  • My PR's scope is as isolated as possible; it only solves 1 specific problem
  • I have received a Greptile Confidence Score of at least 4/5 before requesting a maintainer review

Screenshots / Proof of Fix

Run python litellm/proxy/proxy_cli.py --config litellm/proxy/dev_config.yaml --detailed_debug and:

curl -s -X POST http://localhost:4000/v1/images/edits \
  -H "Authorization: Bearer $LITELLM_KEY" \
  -F model=azure_ai/flux.2-pro \
  -F prompt="Add a red hat" \
  -F image=@non_square.jpg \
  -F size=896x1184

The returned image should be 896x1184 instead of 1024x1024.

Type

🐛 Bug Fix

Caveats (if any)

If size is passed in a non-WxH format, it is silently dropped (not forwarded). This matches the behavior of the MAI config's _map_size_param.

…age edits

## TLDR

Signed-off-by: Ishaan <ishaangupta0408@gmail.com>
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@greptile-apps

greptile-apps Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR translates Azure FLUX 2 image-edit size values into provider-native integer dimensions and adds direct dimension handling.

  • Converts valid WxH strings into width and height.
  • Adds focused tests for size translation and direct dimension mapping.
  • Direct width and height remain unreachable through the public image-edit parameter filter.

Confidence Score: 4/5

The size translation itself is sound, but direct width and height support does not work through the public API and should be fixed before merging.

The shared image-edit filter removes width and height before the Azure FLUX 2 mapper runs, so one of the newly claimed supported input paths silently falls back to provider defaults; the new branch also conflicts with the repository's immutability convention.

Files Needing Attention: litellm/llms/azure_ai/image_edit/flux2_transformation.py, litellm/types/images/main.py, litellm/images/utils.py

Important Files Changed

Filename Overview
litellm/llms/azure_ai/image_edit/flux2_transformation.py Correctly translates size locally, but newly advertised direct width and height parameters are removed upstream and the implementation violates the repository's immutability convention.
tests/test_litellm/llms/azure_ai/image_edit/test_azure_ai_image_edit_transformation.py Adds useful mapper-level happy-path coverage, but the direct-dimension test bypasses the public filtering stage that makes those parameters unreachable in actual image-edit calls.

Reviews (1): Last reviewed commit: "fix(azure_ai): translate size param to w..." | Re-trigger Greptile

Comment on lines +35 to +36
"width",
"height",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Direct dimensions are filtered out

When callers pass the newly supported width and height parameters through the public image_edit API, the shared request filter removes them because ImageEditOptionalRequestParams does not define those keys, causing the provider request to omit the requested dimensions and use its default size.

Knowledge Base Used: LLM Provider Adapters

Comment on lines +53 to +54
mapped_params["width"] = int(w)
mapped_params["height"] = int(h)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Dimension mapping mutates final state

The new assignments incrementally mutate the Final dictionary, contrary to the repository's immutability convention and making the mapping logic dependent on mutation order; construct the mapped dimensions without mutating local state.

Context Used: CLAUDE.md (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@codecov

codecov Bot commented Aug 12, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.71429% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...m/llms/azure_ai/image_edit/flux2_transformation.py 85.71% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@codspeed

codspeed Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 31 untouched benchmarks


Comparing guptaishaan:fix/issue-36644-5767 (d14bcaa) with litellm_internal_staging (f64479e)

Open in CodSpeed

@yuneng-berri
yuneng-berri deleted the branch BerriAI:litellm_internal_staging September 13, 2026 04:41
@yuneng-berri yuneng-berri reopened this Sep 13, 2026
@mateo-berri

Copy link
Copy Markdown
Contributor

Superseded by #39424, which merged with the same size to width and height mapping for FLUX.2 image edits plus flex routing

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.

[Bug]: azure_ai/flux.2-pro images.edit drops width/height and forwards unsupported size key — output is always 1024x1024 (input gets cropped/zoomed)

4 participants