Import Error: cannot import name 'genai' from 'google' (unknown location)

Inexperienced coder here, getting an error that I’ve not been able to google my way out of. Running on windows, with the most frequent versions of Python and all of the googles at this point. Any suggestions?

1 Like

Hi there @Frosty_Sloth .

You can follow the quick start guide for more detailed instructions.

First, you need to install the package:
pip install -q -U google-genai

Then, you will be able to use its functions. Here is an example:

from google import genai

client = genai.Client()

response = client.models.generate_content(
    model="gemini-2.5-flash",
    contents="Explain how AI works in a few words",
)

print(response.text)

Remember to set up your .env file first, so that it can read your api key

GEMINI_API_KEY=your-api-key-goes-here
1 Like