generative-ai-python icon indicating copy to clipboard operation
generative-ai-python copied to clipboard

In text generation docs, example multimodle input, is not working with genai,

Open rahulprodev opened this issue 6 months ago • 0 comments

Description of the bug:

it's not working with genai, it was fixed by generativeai module

https://ai.google.dev/gemini-api/docs/text-generation

`from PIL import Image from google import genai

client = genai.Client(api_key =
│ "AIzaSyCcz313_srMUs3X_paBF0CBsHQ4_aDOx9c")

image = Image.open("shivsatri.jpg") response = client.models.generate_content( model="gemini-2.5-flash", contents=[image, "Tell me about this instrument"] ) print(response.text)`

it was fixed like this: ╭──────────────────────────────────────────────────── │ ✔ Edit imageai.py: from PIL import Image... => from PIL import Image...

│ 1 from PIL import Image
│ 2 - from google import genai
│ 2 + import google.generativeai as genai
│ 3
│ 4 + genai.configure(api_key =
│ "AIzaSyCcz313_srMUs3X_paBF0CBsHQ4_aDOx9c")
│ 5
│ 5 -
│ 6 - client = genai.Client(api_key =
│ "AIzaSyCcz313_srMUs3X_paBF0CBsHQ4_aDOx9c")
│ 7 -
│ 6 image = Image.open("shivsatri.jpg")
│ 7
│ 10 - response = client.models.generate_content(
│ 11 - model = "gemini-2.5-flash",
│ 12 - contents = [image, "Tell me about this instrument"]
│ 8 + model = genai.GenerativeModel('gemini-1.5-flash-latest')
│ 9 +
│ 10 + response = model.generate_content(
│ 11 + [image, "Tell me about this instrument"]
│ 12 )
│ 13
│ 14 print(response.text)
╰───────────────────────────────────────────────────────────────

Actual vs expected behavior:

No response

Any other information you'd like to share?

No response

rahulprodev avatar Jul 03 '25 03:07 rahulprodev