[Bug]: Unable to use image generation capabilities of gemini-2.5-flash-image
What happened?
When prompting gemini-2.5-flash-image, you can only access the chat completion endpoint and not the image generation endpoint, which has not been made available through LiteLLM. When attempting to use it, you get the error provided in this issue. Logs are from using the llm playground in the admin UI
Relevant log output
Error fetching response:Error: 400 litellm.BadRequestError: Vertex_aiException BadRequestError - {
"error": {
"code": 400,
"message": "Gemini cannot be accessed through Vertex Predict/RawPredict API. Please follow https://cloud.google.com/vertex-ai/docs/generative-ai/start/quickstarts/quickstart-multimodal for Gemini usage.",
"status": "FAILED_PRECONDITION"
}
}
. Received Model Group=gemini-2.5-flash-image
Available Model Group Fallbacks=None
Are you a ML Ops Team?
No
What LiteLLM version are you on ?
v1.79.3-stable
Twitter / LinkedIn details
No response
@Sameerlite you just added this on 1.80.0 right ?
@Sameerlite you just added this on 1.80.0 right ?
I tried with litellm[proxy]==1.80.0 , it throws same error
@nikhilcms @majdyousof Please try it with v1.80.5-nightly release. And if still getting error, please share the config/code to repro
@Sameerlite I tried with litellm[proxy]==1.80.5.
and using openai client:
`client = OpenAI()
result = client.images.generate( model="gemini-2.5-flash-image", prompt=prompt ) `
and inside litellm pod I can still see below error:
04:27:09 - LiteLLM Proxy:ERROR: endpoints.py:175 - litellm.proxy.proxy_server.image_generation(): Exception occured - litellm.BadRequestError: Vertex_aiException BadRequestError - { "error": { "code": 400, "message": "Gemini cannot be accessed through Vertex Predict/RawPredict API. Please follow https://cloud.google.com/vertex-ai/docs/generative-ai/start/quickstarts/quickstart-multimodal for Gemini usage.", "status": "FAILED_PRECONDITION" } } . Received Model Group=gemini-2.5-flash-image Available Model Group Fallbacks=None, LiteLLM Max Retries: 1 INFO: 172.16.1.8:41203 - "POST /v1/images/generations HTTP/1.1" 400 Bad Request
default config look like this:
- model_name: gemini-2.5-flash-image litellm_params: model: vertex_ai/gemini-2.5-flash-image vertex_ai_project: 'project_name' vertex_ai_location: 'server_location' rpm:100 tpm: 10000
packages inside pod: pip list | grep litellm litellm 1.80.5 litellm-enterprise 0.1.22 litellm-proxy-extras 0.4.6
Likewise, I still get the same error:
assistant Error fetching response:Error: 400 litellm.BadRequestError: Vertex_aiException BadRequestError - { "error": { "code": 400, "message": "Gemini cannot be accessed through Vertex Predict/RawPredict API. Please follow https://cloud.google.com/vertex-ai/docs/generative-ai/start/quickstarts/quickstart-multimodal for Gemini usage.", "status": "FAILED_PRECONDITION" } } . Received Model Group=gemini-2.5-flash-image Available Model Group Fallbacks=None
my configs are as follows:
- model_name: gemini-2.5-flash-image litellm_params: model: vertex_ai/gemini-2.5-flash-image vertex_credentials: foo vertex_project: bar vertex_location: baz drop_params: True
@nikhilcms Can you try adding model name as "gemini/gemini-2.5-flash-image"
@majdyousof I can see that image gen support is not there for vertex ai. Let me add that today
@majdyousof Added. if you want , you can pull the code from this branch and test. This way if any other errors are present, I can solve them in this PR itself
Hi @Sameerlite Thanks for fixing imege generation endpoint for gemini-2.5-flash, currently with your latest changes image generation endpoint works but usage data not populated correctly, it showing zero output token. could you that as well ?
Hi @Sameerlite could you fix the usage issue of gemini-2.5-flash, I tried with latest litellm version, I was getting zero usage token in response.
I tried using openai image genaration endpoint
@nikhilcms We are tracking to add this by next week
Hi @Sameerlite , I tried gemini 2.5 image with latest litellm version, still I see zero usage tokens, it seems changes not added yet ?