litellm - 💡(How to fix) Fix [Bug]: response_format Ignored When Calling the Image Generation Endpoint [2 comments, 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#24640Fetched 2026-04-08 01:37:27
View on GitHub
Comments
2
Participants
1
Timeline
6
Reactions
0
Author
Participants
Timeline (top)
labeled ×3commented ×2closed ×1

Error Message

curl -sS -X POST "https://my-litellm/images/generations" -H "Content-Type: application/json" -H "Authorization: Bearer sk-s3cr3t" -d '{ "prompt": "un chat", "response_format": "b64_json", "model": "z-image-turbo" }'

{"error":{"message":"litellm.BadRequestError: OpenAIException - Error code: 400 - {'detail': "response_format='url' requires cloud storage to be configured."} ....

Root Cause

  1. Call the image‑generation endpoint with response_format: "b64_json".
  2. The call fails because response_format is not sent, so the API falls back to the default format url.
  3. Test the model’s health check. It also fails for the same reason, since the b64_json format cannot be specified in the health‑check request.

Code Example

curl -sS -X POST "https://my-litellm/images/generations"   -H "Content-Type: application/json"   -H "Authorization: Bearer sk-s3cr3t"   -d '{
          "prompt": "un chat",
          "response_format": "b64_json", "model": "z-image-turbo"
        }'

{"error":{"message":"litellm.BadRequestError: OpenAIException - Error code: 400 - {'detail': \"response_format='url' requires cloud storage to be configured.\"} ....
RAW_BUFFERClick to expand / collapse

Check for existing issues

  • I have searched the existing issues and checked that my issue is not a duplicate.

What happened?

The response_format parameter is ignored – LiteLLM does not forward it to the OpenAI‑compatible image generation model, so the request never receives the expected b64_json output.

I cannot specify that parameter for the Health Check too.

Steps to Reproduce

  1. Deploy Sglang with Z‑Image‑Turbo.

  2. Add it to the Litellm proxy as follows:

    • model_name: z-image-turbo litellm_params: model: openai/Tongyi-MAI/Z-Image-Turbo api_base: http://sglang-prod-sglang/v1 api_key: S3CR3T model_info: mode: image_generation
  3. Call the image‑generation endpoint with response_format: "b64_json".

  4. The call fails because response_format is not sent, so the API falls back to the default format url.

  5. Test the model’s health check. It also fails for the same reason, since the b64_json format cannot be specified in the health‑check request.

Relevant log output

curl -sS -X POST "https://my-litellm/images/generations"   -H "Content-Type: application/json"   -H "Authorization: Bearer sk-s3cr3t"   -d '{
          "prompt": "un chat",
          "response_format": "b64_json", "model": "z-image-turbo"
        }'

{"error":{"message":"litellm.BadRequestError: OpenAIException - Error code: 400 - {'detail': \"response_format='url' requires cloud storage to be configured.\"} ....

What part of LiteLLM is this about?

Proxy

What LiteLLM version are you on ?

v1.81.12

Twitter / LinkedIn details

No response

extent analysis

Fix Plan

To fix the issue, we need to modify the LiteLLM proxy to forward the response_format parameter to the OpenAI-compatible image generation model.

Here are the steps:

  • Update the LiteLLM proxy configuration to include the response_format parameter in the request to the image generation model.
  • Modify the health check request to allow specifying the response_format parameter.

Example Code

# Update the LiteLLM proxy configuration
def generate_image(prompt, model, response_format):
    # Forward the response_format parameter to the image generation model
    params = {
        "prompt": prompt,
        "response_format": response_format
    }
    response = requests.post(f"{api_base}/images/generations", 
                             headers={"Authorization": f"Bearer {api_key}"},
                             json=params)
    return response

# Modify the health check request
def health_check(model, response_format):
    # Allow specifying the response_format parameter in the health check request
    params = {
        "response_format": response_format
    }
    response = requests.get(f"{api_base}/models/{model}/health", 
                            headers={"Authorization": f"Bearer {api_key}"},
                            params=params)
    return response

Verification

To verify that the fix worked, call the image generation endpoint with the response_format parameter set to "b64_json" and check that the response is in the expected format. Also, test the model's health check with the response_format parameter specified.

Extra Tips

  • Make sure to update the LiteLLM proxy configuration to include the response_format parameter in the request to the image generation model.
  • Verify that the response_format parameter is correctly forwarded to the image generation model by checking the request logs.
  • Test the health check with different response_format values to ensure that it works as expected.

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