{"library":"google-ai-generativelanguage","title":"Google AI Generative Language API Client Library","description":"The `google-ai-generativelanguage` library is the low-level Python client for the Google Generative Language API. It provides programmatic access to Google's generative AI models, such as Gemini, allowing developers to perform tasks like text generation, multimodal content understanding, and more. Maintained by Google, it is currently at version 0.11.0 and is compatible with Python 3.9 and newer. While functional for direct API interaction, for a higher-level and more unified experience with Gemini models, the `google-genai` library is often recommended.","status":"active","version":"0.11.0","language":"en","source_language":"en","source_url":"https://github.com/googleapis/google-cloud-python/tree/main/packages/google-ai-generativelanguage","tags":["Google Cloud","AI","Generative AI","Gemini","LLM","GAPIC"],"install":[{"cmd":"pip install google-ai-generativelanguage","lang":"bash","label":"Install with pip"}],"dependencies":[{"reason":"Required Python version","package":"python","optional":false},{"reason":"Direct dependency for authentication","package":"google-auth","optional":false}],"imports":[{"note":"The `google.generativeai` package is deprecated. For the higher-level SDK, use `google-genai` (`from google import genai`). This library (`google-ai-generativelanguage`) provides the lower-level GAPIC client for direct API interaction.","wrong":"from google.generativeai import GenerativeModel","symbol":"GenerativeServiceClient","correct":"from google.ai import generativelanguage_v1beta as glm\nclient = glm.GenerativeServiceClient()"}],"quickstart":{"code":"import os\nfrom google.ai import generativelanguage_v1beta as glm\n\n# Initialize the client. This client will attempt to ascertain credentials \n# from the environment, e.g., via Application Default Credentials (ADC).\n# For local development, consider `gcloud auth application-default login`.\n# For API Key-based authentication (e.g., from Google AI Studio), the `google-genai` \n# library (pip install google-genai) is generally recommended.\nclient = glm.GenerativeServiceClient()\n\nmodel_name = \"models/gemini-pro\"  # Or another supported model like \"models/text-bison-001\"\n\n# Prepare the content for generation\ncontent = glm.Content(\n    parts=[glm.Part(text=\"Write a short poem about a cat sitting by a window.\")]\n)\n\ntry:\n    # Make the generate content request\n    response = client.generate_content(model=model_name, contents=[content])\n\n    # Extract the generated text\n    if response.candidates:\n        print(response.candidates[0].content.parts[0].text)\n    else:\n        print(\"No content generated.\")\n\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")\n    print(\"Ensure you have enabled the Generative Language API in your Google Cloud project and set up authentication.\")\n\n# It's good practice to explicitly close the client when done to release resources.\nclient.close()","lang":"python","description":"This quickstart demonstrates how to instantiate the `GenerativeServiceClient` and use it to generate text with the Gemini Pro model. It highlights the typical setup for authentication using Application Default Credentials (ADC), suitable for Google Cloud environments."},"warnings":[{"fix":"Migrate to the `google-genai` library (for the high-level SDK) or confirm `google-ai-generativelanguage` is the intended low-level client.","message":"The `google-generativeai` library (also known as the Google AI Python SDK for the Gemini API) was officially deprecated on November 30, 2025, in favor of the newer `google-genai` library. While `google-ai-generativelanguage` is the low-level GAPIC client, users migrating from `google-generativeai` might mistakenly try to use it as a direct replacement. Ensure you are using the correct library for your needs, preferably `google-genai` for high-level API access.","severity":"breaking","affected_versions":"<=0.8.6 of google-generativeai"},{"fix":"For ease of use and most common Gemini API interactions, consider using `pip install google-genai` and its corresponding API (`from google import genai`). Use `google-ai-generativelanguage` when fine-grained control or integration within a broader Google Cloud client ecosystem is required.","message":"This library (`google-ai-generativelanguage`) is a low-level GAPIC client, offering direct interaction with the Generative Language API. For simpler interactions with Gemini models (especially Gemini 2.0+ via AI Studio), the `google-genai` library offers a higher-level, more unified API that simplifies many common use cases. Using `google-ai-generativelanguage` directly requires more explicit handling of API requests/responses.","severity":"gotcha","affected_versions":"All versions"},{"fix":"For ADC, ensure `gcloud auth application-default login` is run or `GOOGLE_APPLICATION_CREDENTIALS` environment variable points to a service account key. For API key, switch to `google-genai` and set `GEMINI_API_KEY`.","message":"Authentication for `google-ai-generativelanguage` typically relies on Application Default Credentials (ADC), which are automatically discovered in Google Cloud environments or set up locally via `gcloud auth application-default login`. If you intend to use an API key (e.g., from Google AI Studio) for direct access, you should generally use the `google-genai` library, which is designed for API key-based authentication via the `GEMINI_API_KEY` environment variable.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Upgrade your Python environment to 3.9 or later.","message":"This library requires Python 3.9 or newer. Python versions 3.8 and older are no longer supported.","severity":"deprecated","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-05T00:00:00.000Z","next_check":"2026-07-04T00:00:00.000Z"}