{"id":317,"library":"google-genai","title":"Google GenAI Python SDK","description":"The Google GenAI Python SDK provides an interface for developers to integrate Google's generative models into their Python applications. Current version: 1.69.0, released on March 27, 2026. The SDK is actively maintained with regular updates, typically on a monthly basis.","status":"active","version":"1.69.0","language":"python","source_language":"en","source_url":"https://github.com/googleapis/python-genai","tags":["Google","GenAI","Python SDK","Generative Models","AI Integration"],"install":[{"cmd":"pip install google-genai","lang":"bash","label":"Install google-genai"}],"dependencies":[{"reason":"Required for API interactions","package":"google-api-core"},{"reason":"Needed for HTTP requests","package":"requests"}],"imports":[{"note":"Ensure correct import path to access the SDK's functionalities","symbol":"genai","correct":"import google.generativeai as genai"}],"quickstart":{"code":"import google.generativeai as genai\n\n# Configure the API key\napi_key = os.environ.get('GENAI_API_KEY')\ngenai.configure(api_key=api_key)\n\n# Generate content using a model\nmodel = genai.GenerativeModel(model='gemini-1.5-flash')\nresponse = model.generate_text(prompt='Once upon a time')\nprint(response.text)","lang":"python","description":"This script demonstrates how to configure the Google GenAI SDK with your API key and generate text using the 'gemini-1.5-flash' model."},"warnings":[{"fix":"Update your code to use the new citation types as per the latest API documentation.","message":"Breaking change in Interactions API: Refactored TextContent annotations to use specific citation types in version 1.68.0.","severity":"breaking","affected_versions":"1.68.0"},{"fix":"Modify your code to accommodate the new union names as specified in the updated API.","message":"Breaking change in Interactions API: Renamed ContentDelta unions in version 1.68.0.","severity":"breaking","affected_versions":"1.68.0"},{"fix":"Install the 'google-generativeai' package using pip: `pip install google-generativeai`.","message":"The 'google.generativeai' library is not found. This typically means the package is not installed in the environment where the script is executed.","severity":"breaking","affected_versions":"all"},{"fix":"Install the 'google-generativeai' package using pip: `pip install google-generativeai`.","message":"The script failed with `ModuleNotFoundError: No module named 'google.generativeai'`, indicating that the required Python package is not installed in the environment.","severity":"breaking","affected_versions":"1.68.0"}],"env_vars":null,"last_verified":"2026-05-12T13:01:48.272Z","next_check":"2026-06-26T00:00:00.000Z","problems":[{"fix":"Ensure you have installed the correct and latest `google-genai` SDK using `pip install -U google-genai` and update your imports to `import google.generativeai as genai` (if using the older SDK, ensure it's installed and the Python version is compatible) or `from google import genai` for the newer unified SDK.","cause":"This error often occurs because developers are attempting to import the older `google.generativeai` package, which has been superseded by the `google-genai` SDK, or the package is not correctly installed in the current environment.","error":"ModuleNotFoundError: No module named 'google.generativeai'"},{"fix":"For the `google-genai` SDK, instantiate a client first and then access models through it. For example: `import google.generai as genai; client = genai.Client(api_key='YOUR_API_KEY'); model = client.models.GenerativeModel('gemini-pro')`.","cause":"This error typically arises when using the newer `google-genai` SDK with syntax from the older `google.generativeai` SDK, where `GenerativeModel` was a direct top-level class. In the current `google-genai` SDK, models are accessed via a client object.","error":"AttributeError: module 'google.genai' has no attribute 'GenerativeModel'"},{"fix":"If working with Vertex AI, ensure you are using Application Default Credentials (ADC) or OAuth2 for authentication. If you are intending to use a simple API key, ensure it is correct, active, and that the Generative Language API is enabled for your Google Cloud project. Verify if your API key has been reported as leaked and generate a new one if necessary.","cause":"This specific 401 error indicates that you are trying to use an API key in a context or with an endpoint that requires OAuth2 authentication (e.g., certain Vertex AI APIs) rather than a simple API key, or your API key is invalid/blocked.","error":"401 UNAUTHENTICATED. {'error': {'code': 401, 'message': 'API keys are not supported by this API. Expected OAuth2 access token or other authentication credentials.'}"},{"fix":"Pass your Google AI Studio API key explicitly during client instantiation or configure it via an environment variable. Example: `import google.generativeai as genai; genai.configure(api_key='YOUR_API_KEY')` or `client = genai.Client(api_key='YOUR_API_KEY')` or ensure `os.environ['GOOGLE_API_KEY']` is set.","cause":"This error means that the `google-genai` library was initialized or an API call was made without a properly provided `api_key` argument, which is essential for authentication with Google AI Studio.","error":"ValueError: Missing key inputs argument! To use the Google AI API, provide (api_key) arguments."},{"fix":"Implement exponential backoff and retry logic in your code. Check your project's quotas in Google AI Studio, consider upgrading your usage tier, or request a quota increase if your application requires higher limits.","cause":"You have exceeded the allocated rate limits (requests per minute, tokens per minute, or requests per day) for your project or usage tier in the Gemini API. This is common for free tier users or during periods of high usage.","error":"429 Quota exceeded for quota metric 'Generate Content API requests per minute'"}],"ecosystem":"pypi","meta_description":null,"install_score":0,"install_tag":"stale","quickstart_score":0,"quickstart_tag":"stale","pypi_latest":null,"install_checks":{"last_tested":"2026-05-12","tag":"stale","tag_description":"widespread failures or data too old to trust","results":[{"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":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":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":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":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":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":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":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":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":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":"stale","tag_description":"widespread failures or data too old to trust","results":[{"runtime":"python:3.10-alpine","exit_code":1},{"runtime":"python:3.10-slim","exit_code":1},{"runtime":"python:3.11-alpine","exit_code":1},{"runtime":"python:3.11-slim","exit_code":1},{"runtime":"python:3.12-alpine","exit_code":1},{"runtime":"python:3.12-slim","exit_code":1},{"runtime":"python:3.13-alpine","exit_code":1},{"runtime":"python:3.13-slim","exit_code":1},{"runtime":"python:3.9-alpine","exit_code":1},{"runtime":"python:3.9-slim","exit_code":1}]}}