InferenceClient image_to_image example fails for Qwen/Qwen-Image-Edit-2511 with fal-ai provider

#20
by yurisoeda - opened

InferenceClient image_to_image fails for Qwen/Qwen-Image-Edit-2511 (fal-ai provider)

Description

I am trying to use the official Hugging Face API sample code for Qwen/Qwen-Image-Edit-2511 with the InferenceClient and the fal-ai provider, but the example does not work as expected.

The code is taken directly from the Hugging Face documentation / model page, but it fails with a KeyError: 'images'.


Reproduction Code

import os
from huggingface_hub import InferenceClient

client = InferenceClient(
    provider="fal-ai",
    api_key=os.environ["HF_TOKEN"],
)

with open("cat.jpg", "rb") as image_file:
    input_image = image_file.read()

# output is a PIL.Image object
image = client.image_to_image(
    input_image,
    prompt="Turn the cat into a tiger.",
    model="Qwen/Qwen-Image-Edit-2511",
)

Error Message

Traceback (most recent call last):
  File "d:\huggingface\qwen_img_edit.py", line 13, in <module>
    image = client.image_to_image(
            ^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\site-packages\huggingface_hub\inference_client.py", line 1327, in image_to_image
    response = provider_helper.get_response(response, request_parameters)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\site-packages\huggingface_hub\inference_providers\fal_ai.py", line 217, in get_response
    url = _as_dict(output)["images"][0]["url"]
          ~~~~~~~~~~~~~~~~~^^^^^^^^^^
KeyError: 'images'

Environment

  • OS: Windows 11
  • Python: 3.10
  • huggingface_hub: latest version
  • Provider: fal-ai
  • Model: Qwen/Qwen-Image-Edit-2511

Questions

  • Is this example still valid for Qwen/Qwen-Image-Edit-2511?
  • Is there an updated or working example for image editing with this model?
  • Is this a known issue with the fal-ai provider integration?
  • Has the fal-ai response schema changed?

Expected Behavior

The example should return a valid edited image as a PIL.Image object without raising an exception.


Additional Notes

The error occurs in:

huggingface_hub/inference_providers/fal_ai.py

This suggests a possible mismatch between the expected response schema and the actual response returned by fal-ai.


Thank you for your help.

Sign up or log in to comment