litellm - ✅(Solved) Fix [Bug]: Azure AI FLUX.2-pro image edit silently ignores reference image — wrong JSON key "image" instead of "input_image" [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
BerriAI/litellm#26698Fetched 2026-04-29 06:12:44
View on GitHub
Comments
0
Participants
1
Timeline
3
Reactions
0
Timeline (top)
labeled ×2cross-referenced ×1

Error Message

The API does not return an error. It simply ignores the unknown "image" field and generates a new image from scratch, making the bug hard to detect.

Root Cause

The root cause is in litellm/llms/azure_ai/image_edit/flux2_transformation.py. The transform_image_edit_request method sends the base64-encoded image under the JSON key "image", but the Black Forest Labs API on Azure AI Foundry expects "input_image".

Fix Action

Fix / Workaround

I verified this by patching line 113 from "image" to "input_image" in a running LiteLLM proxy container. With the fix, the reference image is correctly preserved and edited. Without it, a completely different image is generated.

  1. Patch flux2_transformation.py:113 from "image" to "input_image", restart the proxy, and repeat. The reference image is now correctly used.

PR fix notes

PR #26744: fix(azure_ai): use correct 'input_image' key for FLUX.2-pro image editing

Description (problem / solution / changelog)

Problem

When calling the Azure AI FLUX.2-pro image editing endpoint, litellm sends the base64-encoded image under the JSON key "image", but the Black Forest Labs API actually expects the key "input_image".

Why this is hard to detect: The API silently ignores the unknown "image" field and returns a response without error — it simply processes the request as if no input image was provided. There is no validation error to alert the caller.

Fix

Changed the key in the request body from "image" to "input_image" in AzureFoundryFlux2ImageEditConfig.transform_request_body().

File: litellm/llms/azure_ai/image_edit/flux2_transformation.py (line ~115)

# Before
request_body: Dict[str, Any] = {
    "prompt": prompt,
    "image": image_b64,   # ❌ wrong key — silently ignored by API
    "model": model,
}

# After
request_body: Dict[str, Any] = {
    "prompt": prompt,
    "input_image": image_b64,   # ✅ correct key per BFL API spec
    "model": model,
}

References

Testing

Verified manually that the correct key is now sent in the JSON body when using litellm.image_edit() with an Azure AI FLUX.2-pro deployment.

Fixes #26698

Changed files

  • litellm/llms/azure_ai/image_edit/flux2_transformation.py (modified, +1/-1)

Code Example

- model_name: flux.2-pro
  litellm_params:
    model: azure_ai/flux.2-pro
    api_base: "os.environ/AZURE_AI_API_BASE"
    api_key: "os.environ/AZURE_AI_API_KEY"
    api_version: "preview"
  model_info:
    mode: "image_generation"

---

import os
import litellm

response = litellm.image_edit(
    model="azure_ai/flux.2-pro",
    image=open("car.png", "rb"),
    prompt="Make the car red.",
    api_base=os.environ["AZURE_AI_API_BASE"],
    api_key=os.environ["AZURE_AI_API_KEY"],
    api_version="preview",
)

---

- "image": image_b64,
+ "input_image": image_b64,

---

No errors logged. The API returns HTTP 200 with a valid but wrong image.
RAW_BUFFERClick to expand / collapse

What happened?

When using azure_ai/flux.2-pro for image editing via /v1/images/edits, the reference image is silently ignored. FLUX generates a completely new image from the prompt instead of editing the provided reference image.

The root cause is in litellm/llms/azure_ai/image_edit/flux2_transformation.py. The transform_image_edit_request method sends the base64-encoded image under the JSON key "image", but the Black Forest Labs API on Azure AI Foundry expects "input_image".

The API does not return an error. It simply ignores the unknown "image" field and generates a new image from scratch, making the bug hard to detect.

I verified this by patching line 113 from "image" to "input_image" in a running LiteLLM proxy container. With the fix, the reference image is correctly preserved and edited. Without it, a completely different image is generated.

References:

Steps to Reproduce

  1. Configure azure_ai/flux.2-pro in config.yaml:
- model_name: flux.2-pro
  litellm_params:
    model: azure_ai/flux.2-pro
    api_base: "os.environ/AZURE_AI_API_BASE"
    api_key: "os.environ/AZURE_AI_API_KEY"
    api_version: "preview"
  model_info:
    mode: "image_generation"
  1. Send an image edit request:
import os
import litellm

response = litellm.image_edit(
    model="azure_ai/flux.2-pro",
    image=open("car.png", "rb"),
    prompt="Make the car red.",
    api_base=os.environ["AZURE_AI_API_BASE"],
    api_key=os.environ["AZURE_AI_API_KEY"],
    api_version="preview",
)
  1. The returned image is a completely new image (different car, different scene) instead of the reference image with the color changed.

  2. Patch flux2_transformation.py:113 from "image" to "input_image", restart the proxy, and repeat. The reference image is now correctly used.

The fix (one-line change in flux2_transformation.py:113):

- "image": image_b64,
+ "input_image": image_b64,

Secondary issue: _convert_image_to_base64 discards all but the first image from a list (line 126-129). The BFL API supports up to 8 reference images via input_image, input_image_2, ..., input_image_8.

Relevant log output

No errors logged. The API returns HTTP 200 with a valid but wrong image.

What part of LiteLLM is this about?

Proxy

What LiteLLM version are you on?

v1.82.3-stable (also verified on current main branch, same code, same bug)

Twitter / LinkedIn details

No response

extent analysis

TL;DR

Update the flux2_transformation.py file to use the correct JSON key "input_image" instead of "image" to fix the issue with the reference image being ignored.

Guidance

  • Verify the fix by patching the flux2_transformation.py file and checking if the reference image is correctly preserved and edited.
  • Check the Azure Foundry FLUX Guide and BFL Image Editing Docs for more information on the correct API usage.
  • Consider updating the _convert_image_to_base64 function to support multiple reference images.
  • Test the fix with different input images and prompts to ensure it works as expected.

Example

- "image": image_b64,
+ "input_image": image_b64,

This one-line change in flux2_transformation.py:113 should fix the issue.

Notes

The fix assumes that the issue is only with the JSON key used in the transform_image_edit_request method. If there are other issues, additional debugging may be required.

Recommendation

Apply the workaround by updating the flux2_transformation.py file with the correct JSON key, as this is a simple and effective fix for the issue.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING