litellm icon indicating copy to clipboard operation
litellm copied to clipboard

[Bug]: Unable to use image generation capabilities of gemini-2.5-flash-image

Open majdyousof opened this issue 1 month ago • 2 comments

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

majdyousof avatar Nov 17 '25 15:11 majdyousof

@Sameerlite you just added this on 1.80.0 right ?

ishaan-jaff avatar Nov 21 '25 22:11 ishaan-jaff

@Sameerlite you just added this on 1.80.0 right ?

I tried with litellm[proxy]==1.80.0 , it throws same error

nikhilcms avatar Nov 22 '25 06:11 nikhilcms

@nikhilcms @majdyousof Please try it with v1.80.5-nightly release. And if still getting error, please share the config/code to repro

Sameerlite avatar Nov 24 '25 02:11 Sameerlite

@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

nikhilcms avatar Nov 24 '25 04:11 nikhilcms

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

majdyousof avatar Nov 24 '25 11:11 majdyousof

@nikhilcms Can you try adding model name as "gemini/gemini-2.5-flash-image"

Sameerlite avatar Nov 25 '25 02:11 Sameerlite

@majdyousof I can see that image gen support is not there for vertex ai. Let me add that today

Sameerlite avatar Nov 25 '25 02:11 Sameerlite

@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

Sameerlite avatar Nov 25 '25 08:11 Sameerlite

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 ?

nikhilcms avatar Nov 27 '25 05:11 nikhilcms

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 avatar Dec 04 '25 09:12 nikhilcms

@nikhilcms We are tracking to add this by next week

Sameerlite avatar Dec 04 '25 12:12 Sameerlite

Hi @Sameerlite , I tried gemini 2.5 image with latest litellm version, still I see zero usage tokens, it seems changes not added yet ?

nikhilcms avatar Dec 16 '25 07:12 nikhilcms