litellm - 💡(How to fix) Fix gpt-image-2 issue [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#26316Fetched 2026-04-24 05:52:34
View on GitHub
Comments
0
Participants
1
Timeline
2
Reactions
1
Participants
Timeline (top)
labeled ×1subscribed ×1

Error Message

AzureException - {
"error": {
"message": "The model 'gpt-image-2-1' does not exist.",
"type": "image_generation_user_error",
"param": "model",
"code": "invalid_value"
}
}

Root Cause

Root Cause

Code Example

AzureException - {                                                                                                                                                         
    "error": {                                                                                                                                                               
      "message": "The model 'gpt-image-2-1' does not exist.",                                                                                                                
      "type": "image_generation_user_error",                                                                                                                                 
      "param": "model",                                                                                                                                                      
      "code": "invalid_value"                                                                                                                                                
    }                                                                                                                                                                        
  }

---

curl "https://<endpoint>/openai/deployments/gpt-image-2-1/images/generations?api-version=2025-04-01-preview" \                                                             
    -H "api-key: <key>" -H "Content-Type: application/json" \                                                                                                                
    -d '{"prompt":"a red circle","n":1,"size":"1024x1024"}'                                                                                                                  
  # Returns 200 OK with base64 image

---

curl "https://<proxy>/v1/images/generations" \                                                                                                                             
    -H "Authorization: Bearer <key>" -H "Content-Type: application/json" \                                                                                                   
    -d '{"model":"gpt-image-2","prompt":"a red circle","n":1,"size":"1024x1024"}'                                                                                            
  # Returns 400 "The model 'gpt-image-2-1' does not exist."

---

- model_name: gpt-image-2                                                                                                                                                  
    model_info:                                                                                                                                                              
      mode: image_generation                                                                                                                                                 
    litellm_params:                                                                                                                                                          
      model: azure/gpt-image-2-1                                                                                                                                             
      api_base: https://<endpoint>.cognitiveservices.azure.com                                                                                                               
      api_key: os.environ/AZURE_API_KEY                                                                                                                                      
      api_version: 2025-04-01-preview
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?

When using LiteLLM proxy to call Azure OpenAI gpt-image-2 via /v1/images/generations, the request fails with:

AzureException - {                                                                                                                                                         
  "error": {                                                                                                                                                               
    "message": "The model 'gpt-image-2-1' does not exist.",                                                                                                                
    "type": "image_generation_user_error",                                                                                                                                 
    "param": "model",                                                                                                                                                      
    "code": "invalid_value"                                                                                                                                                
  }                                                                                                                                                                        
}

The same request works when calling Azure OpenAI directly (without LiteLLM proxy).

Root Cause

LiteLLM passes the deployment name (gpt-image-2-1) in the request body as the model parameter. Azure's image generation API does not accept a model field in the body — the deployment name should only be in the URL path (/openai/deployments/{deployment}/images/generations).

Relevant log output

Direct Azure call (works):

curl "https://<endpoint>/openai/deployments/gpt-image-2-1/images/generations?api-version=2025-04-01-preview" \                                                             
  -H "api-key: <key>" -H "Content-Type: application/json" \                                                                                                                
  -d '{"prompt":"a red circle","n":1,"size":"1024x1024"}'                                                                                                                  
# Returns 200 OK with base64 image

Via LiteLLM proxy (fails):

curl "https://<proxy>/v1/images/generations" \                                                                                                                             
  -H "Authorization: Bearer <key>" -H "Content-Type: application/json" \                                                                                                   
  -d '{"model":"gpt-image-2","prompt":"a red circle","n":1,"size":"1024x1024"}'                                                                                            
# Returns 400 "The model 'gpt-image-2-1' does not exist."

LiteLLM config

- model_name: gpt-image-2                                                                                                                                                  
  model_info:                                                                                                                                                              
    mode: image_generation                                                                                                                                                 
  litellm_params:                                                                                                                                                          
    model: azure/gpt-image-2-1                                                                                                                                             
    api_base: https://<endpoint>.cognitiveservices.azure.com                                                                                                               
    api_key: os.environ/AZURE_API_KEY                                                                                                                                      
    api_version: 2025-04-01-preview

Related Issues

  • #23709 (same issue with gpt-image-1.5)

Twitter / LinkedIn details

No response

extent analysis

TL;DR

Remove the model field from the request body when calling the Azure OpenAI image generation API via the LiteLLM proxy.

Guidance

  • Verify that the LiteLLM proxy is correctly configured to pass the deployment name only in the URL path, not in the request body.
  • Check the LiteLLM configuration to ensure that the model parameter is not being included in the request body.
  • Update the LiteLLM proxy to modify the request body and remove the model field before forwarding it to the Azure OpenAI API.
  • Test the updated LiteLLM proxy configuration with a sample request to ensure that it works as expected.

Example

curl "https://<proxy>/v1/images/generations" \
  -H "Authorization: Bearer <key>" -H "Content-Type: application/json" \
  -d '{"prompt":"a red circle","n":1,"size":"1024x1024"}'

Note that the model field has been removed from the request body.

Notes

This solution assumes that the LiteLLM proxy has the capability to modify the request body before forwarding it to the Azure OpenAI API. If this is not the case, additional modifications to the LiteLLM proxy may be necessary.

Recommendation

Apply workaround: Remove the model field from the request body when calling the Azure OpenAI image generation API via the LiteLLM proxy. This is because the Azure OpenAI API does not accept a model field in the request body, and including it causes the request to fail.

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