{"id":142,"library":"google-generativeai","title":"Google Generative AI SDK (Gemini)","description":"DEPRECATED. The original Python SDK for Gemini API (AI Studio). Replaced by google-genai (the unified Google Gen AI SDK). End-of-life: November 30, 2025. All support permanently ended. New features like Live API, Veo, Imagen 3 are only available in google-genai. Last version: 0.8.6. Do not use for new projects.","status":"deprecated","version":"0.8.6","language":"python","source_language":"en","source_url":"https://github.com/googleapis/python-genai","tags":["google","gemini","llm","genai","python","vertex-ai","deprecated"],"install":[{"cmd":"pip install google-genai","lang":"bash","label":"Python (new unified SDK — use this)"},{"cmd":"pip install google-generativeai","lang":"bash","label":"Python (deprecated — do not use for new projects)"}],"dependencies":[{"reason":"Required for Vertex AI mode authentication in google-genai.","package":"google-auth","optional":true}],"imports":[{"note":"Old SDK uses module-level genai.configure() + GenerativeModel class. New SDK uses Client() instance pattern. Completely different API surface.","wrong":"import google.generativeai as genai\ngenai.configure(api_key='GEMINI_API_KEY')\nmodel = genai.GenerativeModel('gemini-2.5-flash')\nresponse = model.generate_content('Explain quantum computing')\nprint(response.text)","symbol":"genai.Client (new SDK)","correct":"from google import genai\nfrom google.genai import types\n\nclient = genai.Client(api_key='GEMINI_API_KEY')\nresponse = client.models.generate_content(\n    model='gemini-2.5-flash',\n    contents='Explain quantum computing',\n    config=types.GenerateContentConfig(temperature=0.1)\n)\nprint(response.text)"},{"note":"GenerationConfig renamed to GenerateContentConfig in new SDK. Class lives in google.genai.types not google.generativeai.","wrong":"import google.generativeai as genai\nconfig = genai.GenerationConfig(\n    temperature=0.1,\n    max_output_tokens=1024\n)","symbol":"GenerationConfig (new SDK)","correct":"from google.genai import types\nconfig = types.GenerateContentConfig(\n    temperature=0.1,\n    max_output_tokens=1024\n)"},{"note":"google-cloud-aiplatform generative AI module also deprecated June 24, 2026. Both old paths converge into google-genai with vertexai=True flag.","wrong":"import vertexai\nfrom vertexai.generative_models import GenerativeModel\nvertexai.init(project='your-project', location='us-central1')\nmodel = GenerativeModel('gemini-2.5-flash')","symbol":"Vertex AI mode (new SDK)","correct":"from google import genai\n\n# Vertex AI mode\nclient = genai.Client(\n    vertexai=True,\n    project='your-project-id',\n    location='us-central1'\n)\n\n# Gemini API mode (AI Studio)\nclient = genai.Client(api_key='GEMINI_API_KEY')"}],"quickstart":{"code":"# pip install google-genai\nfrom google import genai\nfrom google.genai import types\nimport os\n\nclient = genai.Client(api_key=os.environ['GEMINI_API_KEY'])\n\nresponse = client.models.generate_content(\n    model='gemini-2.5-flash',\n    contents='What is the capital of France?',\n    config=types.GenerateContentConfig(\n        temperature=0.1,\n        max_output_tokens=256\n    )\n)\nprint(response.text)","lang":"python","description":"Minimal Gemini call using the new google-genai SDK 1.x."},"warnings":[{"fix":"pip install google-genai and migrate. Full migration guide at ai.google.dev/gemini-api/docs/libraries","message":"google-generativeai is fully end-of-life as of November 30, 2025. No bug fixes, no security patches, no new features. The repo is archived at google-gemini/deprecated-generative-ai-python.","severity":"breaking","affected_versions":"all"},{"fix":"Use google-genai with vertexai=True for Vertex AI access.","message":"google-cloud-aiplatform generative AI module deprecated June 24, 2026. SDK releases after that date will not include generative AI modules.","severity":"breaking","affected_versions":"google-cloud-aiplatform all versions"},{"fix":"Replace genai.configure(api_key=...) with client = genai.Client(api_key=...). Replace model.generate_content() with client.models.generate_content(model=..., contents=...).","message":"API surface completely changed. genai.configure() removed. GenerativeModel class removed. New SDK uses Client() instance with client.models.generate_content().","severity":"breaking","affected_versions":"google-generativeai all vs google-genai all"},{"fix":"from google.genai import types; types.GenerateContentConfig(temperature=0.1)","message":"GenerationConfig renamed to GenerateContentConfig and moved to google.genai.types.","severity":"breaking","affected_versions":"google-generativeai all vs google-genai all"},{"fix":"Set GEMINI_API_KEY for AI Studio usage. Use gcloud auth application-default login for Vertex AI mode.","message":"Two separate env vars for API key depending on mode. Gemini API mode reads GEMINI_API_KEY. Google AI Studio also accepts GOOGLE_API_KEY. Vertex AI mode uses Application Default Credentials.","severity":"gotcha","affected_versions":"google-genai all"},{"fix":"Always verify generated Gemini code uses 'from google import genai' not 'import google.generativeai as genai'.","message":"LLMs trained before 2025 have no knowledge of google-genai SDK. Will generate google-generativeai code (old API) by default. High hallucination risk on import pattern and Client() usage.","severity":"gotcha","affected_versions":"google-genai all"}],"env_vars":null,"last_verified":"2026-05-12T08:29:10.662Z","next_check":"2026-06-24T00:00:00.000Z","problems":[{"fix":"Ensure the package is installed in your active Python environment: `pip install -U google-generativeai`. Verify your Python version is supported (Python 3.9+ is generally required for recent versions).","cause":"The `google-generativeai` package is either not installed, installed in a different Python environment, or there's a typo in the import statement.","error":"ModuleNotFoundError: No module named 'google.generativeai'"},{"fix":"Update the library to the latest version: `pip install --upgrade google-generativeai`. If this doesn't resolve it, verify the correct API usage for your installed version, or consider migrating to the `google-genai` SDK where model instantiation is typically handled differently (e.g., `genai.GenerativeModel('model_name')` might be replaced by `client.models.get('model_name')` in the new SDK).","cause":"You are likely using an outdated version of the `google-generativeai` library, or the `GenerativeModel` class has been renamed/moved in your specific version. This error is also common when migrating from `google-generativeai` to the newer `google-genai` SDK, where the client initialization and model access patterns differ.","error":"AttributeError: module 'google.generativeai' has no attribute 'GenerativeModel'"},{"fix":"Update to the latest `google-generativeai` version and adjust your code to use current methods for client initialization (e.g., `genai.configure(api_key=...)` and `genai.GenerativeModel(...)`). For new projects or if this persists, migrate to the `google-genai` SDK which has a different client and model instantiation approach.","cause":"The `get_default_text_client` function was a component of older versions of the `google-generativeai` library, often used for the deprecated PaLM API, and has since been removed or is not available in newer versions or the `google-genai` SDK.","error":"ImportError: cannot import name 'get_default_text_client' from 'google.generativeai.client'"},{"fix":"Ensure your Google API key is correctly set (e.g., via `genai.configure(api_key=\"YOUR_API_KEY\")` or as an environment variable `GOOGLE_API_KEY`). If using Google Cloud credentials, verify that the service account has roles like 'Vertex AI User' or 'AI Platform Developer' enabled, and that the Vertex AI API is enabled for your project.","cause":"This error indicates that the API key or service account used for authentication does not have the necessary permissions (scopes) to access the requested Generative AI API or that the API key is missing/invalid.","error":"403 Request had insufficient authentication scopes. [reason: \"ACCESS_TOKEN_SCOPE_INSUFFICIENT\"]"},{"fix":"Check the official Google Generative AI documentation for supported regions. If your region is not supported, you may need to use a proxy or configure your environment to route requests through a supported region, potentially using the Vertex AI SDK which allows specifying locations.","cause":"The Google Generative AI API might not be available in your geographical region or the specific model you are trying to use has regional restrictions.","error":"google.api_core.exceptions.FailedPrecondition: 400 User location is not supported for the API use."}],"ecosystem":"pypi","meta_description":null,"install_score":95,"install_tag":"verified","quickstart_score":80,"quickstart_tag":"verified","pypi_latest":null,"install_checks":{"last_tested":"2026-05-12","tag":"verified","tag_description":"installs cleanly on critical runtimes, fast import, recently tested","results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":3.27,"mem_mb":37.2,"disk_size":"125.1M"},{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":2.28,"mem_mb":37.2,"disk_size":"195M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":5.43,"mem_mb":39.2,"disk_size":"137.1M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":4.37,"mem_mb":39.2,"disk_size":"207M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":4.11,"mem_mb":38.7,"disk_size":"127.2M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":4.19,"mem_mb":38.7,"disk_size":"197M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":3.9,"mem_mb":39.3,"disk_size":"123.7M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":3.99,"mem_mb":39.3,"disk_size":"196M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":2.37,"mem_mb":32.2,"disk_size":"118.7M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":2.02,"mem_mb":32.2,"disk_size":"189M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null}]},"quickstart_checks":{"last_tested":"2026-04-23","tag":"verified","tag_description":"quickstart runs on critical runtimes, recently tested","results":[{"runtime":"python:3.10-alpine","exit_code":0},{"runtime":"python:3.10-slim","exit_code":0},{"runtime":"python:3.11-alpine","exit_code":0},{"runtime":"python:3.11-slim","exit_code":0},{"runtime":"python:3.12-alpine","exit_code":0},{"runtime":"python:3.12-slim","exit_code":0},{"runtime":"python:3.13-alpine","exit_code":0},{"runtime":"python:3.13-slim","exit_code":0},{"runtime":"python:3.9-alpine","exit_code":0},{"runtime":"python:3.9-slim","exit_code":0}]}}