Search code examples
pythongoogle-gemini

Gemini returns error: 400 Multiturn chat is not enabled for models/gemini-pro-vision


I am trying to send a request to gemini-pro-vision model and it keeps returning this error

400 Multiturn chat is not enabled for models/gemini-pro-vision

My code.

# Create a client
client = generativelanguage_v1beta.GenerativeServiceAsyncClient()
content1 = build_content("user", image, text)
contents2 = build_content("model", image, "This is a dog")
contents3 = build_content("user", image, "Are you Sure?")

request = generativelanguage_v1beta.GenerateContentRequest(
    model="models/gemini-pro-vision",
    contents=[content1, contents2, contents3],
    generation_config=generation_config,
    safety_settings=safety_settings
)

# Make the request
response = await client.generate_content(request=request)

# Handle the response
return response.candidates[0].content.parts[0].text

Solution

  • The issue here is that unlike the gemini-pro model gemini-pro-image has not been optimized for multi-turn conversations. It only supports single requests.

    So in my case I had sent it

    • What do you see + Image
    • It responded with an incorrect answers.
    • so i asked it if it was sure.

    You cant do this with gemini-pro-vision it doesn't support it.

    If you want to do chat you must use Gemini-pro

    Please see model-variations

    enter image description here