To install from PyPI, run pip install google-generativeai. Obtain an API key from AI Studio, then configure it here.

Also, your import statement is wrong. You did import google.generative as genai but it should be import google.generativeai as genai. See PyPi.

Answer from Uchenna Adubasim on Stack Overflow
🌐
PyPI
pypi.org › project › google-genai
google-genai · PyPI
2 weeks ago - from google import genai # Only run this block for Gemini Developer API client = genai.Client(api_key='GEMINI_API_KEY')
      » pip install google-genai
    
Published   Jun 24, 2026
Version   2.10.0
🌐
PyPI
pypi.org › project › google-generativeai
google-generativeai · PyPI
Google Generative AI High level API client library and tools.
      » pip install google-generativeai
    
Published   Dec 16, 2025
Version   0.8.6
🌐
GitHub
github.com › googleapis › python-genai
GitHub - googleapis/python-genai: Google Gen AI Python SDK provides an interface for developers to integrate Google's generative models into their Python applications. · GitHub
1 month ago - from google import genai # Only run this block for Gemini Developer API client = genai.Client(api_key='GEMINI_API_KEY')
Starred by 3.8K users
Forked by 929 users
Languages   Python
🌐
Google AI
ai.google.dev › gemini api › gemini api libraries
Gemini API libraries | Google AI for Developers
April 28, 2026 - The Google GenAI SDK is available for the Python, JavaScript/TypeScript, Go and Java languages.
🌐
Google AI
ai.google.dev › gemini api › migrate to the google genai sdk
Migrate to the Google GenAI SDK | Gemini API | Google AI for Developers
April 28, 2026 - #pip install https://github.com/google-gemini/generative-ai-python@imagen import google.generativeai as genai imagen = genai.ImageGenerationModel( "imagen-3.0-generate-001") gen_images = imagen.generate_images( prompt="Robot holding a red skateboard", number_of_images=1, safety_filter_level="block_low_and_above", person_generation="allow_adult", aspect_ratio="3:4", ) After ·
🌐
PyPI
pypi.org › project › google-genai-aipy
google-genai-aipy · PyPI
Documentation: https://googleapis.github.io/python-genai/ Google Gen AI Python SDK provides an interface for developers to integrate Google's generative models into their Python applications.
      » pip install google-genai-aipy
    
Published   May 22, 2025
Version   1.9.0
🌐
Analytics Vidhya
analyticsvidhya.com › home › google gen ai python sdk: a complete guide
Google Gen AI Python SDK: A Complete Guide
August 17, 2025 - The above command will install the Google Gen AI Python SDK package using pip. This command downloads everything you need for the Python environment to start up the Google generative AI services, including the resources and all dependencies.
Find elsewhere
🌐
Google
docs.cloud.google.com › gemini enterprise agent platform › google gen ai sdk
Google Gen AI SDK | Gemini Enterprise Agent Platform | Google Cloud Documentation
1 month ago - from google import genai # TODO(developer): Update below line API_KEY = "YOUR_API_KEY" client = genai.Client(vertexai=True, api_key=API_KEY) response = client.models.generate_content( model="gemini-3.5-flash", contents="Explain bubble sort to me.", ) print(response.text) # Example response: # Bubble Sort is a simple sorting algorithm that repeatedly steps through the list
🌐
GitHub
github.com › google-gemini › genai-processors
GitHub - google-gemini/genai-processors: GenAI Processors is a lightweight Python library that enables efficient, parallel content processing. · GitHub
The GenAI Processors library requires Python 3.10+.
Starred by 2.1K users
Forked by 215 users
Languages   Python 77.7% | Jupyter Notebook 14.0% | HTML 8.3%
🌐
GitHub
github.com › google-gemini › generative-ai-python › blob › main › docs › api › google › generativeai.md
deprecated-generative-ai-python/docs/api/google/generativeai.md at main · google-gemini/deprecated-generative-ai-python
Google AI Python SDK · pip install google-generativeai · Use genai.GenerativeModel to access the API: import google.generativeai as genai import os genai.configure(api_key=os.environ['API_KEY']) model = genai.GenerativeModel(model_name='g...
Author   google-gemini
🌐
Google AI
ai.google.dev › gemini api › getting started with gemini api
Getting started with Gemini API | Google AI for Developers
2 weeks ago - The Interactions API is available through the Python and JavaScript SDKs, as well as through REST. To use the Gemini API, you need an API key. Create one for free to get started: ... Install the SDK and generate text with a single API call. ... from google import genai client = genai.Client() interaction = client.interactions.create( model="gemini-3.5-flash", input="Explain how AI works in a few words" ) print(interaction.output_text)
🌐
GitHub
github.com › googleapis › python-genai › blob › main › codegen_instructions.md
python-genai/codegen_instructions.md at main · googleapis/python-genai
Installation: Incorrect: pip install google-generativeai · Incorrect: pip install google-ai-generativelanguage · Correct: pip install google-genai · APIs and Usage: Incorrect: import google.generativeai as genai-> Correct: from google import ...
Author   googleapis
🌐
Android Experto
androidexperto.com › home › google gen ai python sdk: a complete guide
Google Gen AI Python SDK: A Complete Guide
May 25, 2026 - Install the official SDK with pip install google-genai. In new projects, prefer this package over older Gemini-specific SDKs because it is the current Google-supported client for working with Gemini models through the Gen AI API and Vertex AI.
🌐
Google Cloud
cloud.google.com › gemini enterprise agent platform › google gen ai libraries
Google Gen AI libraries | Gemini Enterprise Agent Platform | Google Cloud Documentation
Install our Python library by running: pip install google-genai · Install our Go library by running: go get google.golang.org/genai · Install our JavaScript/TypeScript library by running: npm install @google/genai · The new JavaScript and ...
🌐
GitHub
github.com › google-gemini › generative-ai-python
GitHub - google-gemini/deprecated-generative-ai-python: This SDK is now deprecated, use the new unified Google GenAI SDK. · GitHub
This SDK is now deprecated, use the new unified Google GenAI SDK. - google-gemini/deprecated-generative-ai-python
Starred by 2.3K users
Forked by 519 users
Languages   Python
🌐
Priyanshu
priyanshu.com.np › home › how to set up and use google generative ai in python
How to Set Up and Use Google Generative AI in Python - Priyanshu
July 11, 2024 - First, you need to install the necessary Python packages. Open your terminal or command prompt and run the following commands: pip install google-generativeai pip install python-dotenv