{"id":23978,"library":"llama-index-llms-gemini","title":"LlamaIndex LLMs Gemini","description":"LlamaIndex integration for Google Gemini LLMs. Provides a Gemini class that wraps the Google Generative AI SDK for use within LlamaIndex workflows. Current stable version is 0.6.2, released regularly alongside LlamaIndex ecosystem updates.","status":"active","version":"0.6.2","language":"python","source_language":"en","source_url":"https://github.com/run-llama/llama_index","tags":["llama-index","gemini","llm","google","ai"],"install":[{"cmd":"pip install llama-index-llms-gemini","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"Required for interacting with Gemini API","package":"google-generativeai","optional":false},{"reason":"Base LlamaIndex framework","package":"llama-index-core","optional":false}],"imports":[{"note":"Gemini is no longer directly exposed from llama_index.llms; must import from the subpackage.","wrong":"from llama_index.llms import Gemini","symbol":"Gemini","correct":"from llama_index.llms.gemini import Gemini"}],"quickstart":{"code":"import os\nfrom llama_index.llms.gemini import Gemini\n\napi_key = os.environ.get(\"GOOGLE_API_KEY\", \"\")\nllm = Gemini(api_key=api_key, model=\"models/gemini-pro\")\nresp = llm.complete(\"What is the capital of France?\")\nprint(resp)","lang":"python","description":"Initialize Gemini LLM with an API key and generate a completion."},"warnings":[{"fix":"Switch to `pip install llama-index-llms-google` and use `from llama_index.llms.google import Gemini`.","message":"In version 0.2.0+, the import path changed from `llama_index.llms.gemini` to `llama_index.llms.google` (for Google AI) or `llama_index.llms.vertex` (for Vertex AI). This package (`llama-index-llms-gemini`) is deprecated in favor of `llama-index-llms-google`.","severity":"breaking","affected_versions":">=0.2.0"},{"fix":"Use `pip install llama-index-llms-google` and import from `llama_index.llms.google`.","message":"The `llama-index-llms-gemini` package is deprecated. New projects should use `llama-index-llms-google`.","severity":"deprecated","affected_versions":"All versions"},{"fix":"Set `GOOGLE_API_KEY` environment variable or pass `api_key` to the Gemini constructor.","message":"Google API key must be set either via the `api_key` parameter or the `GOOGLE_API_KEY` environment variable. Not setting it results in an authentication error.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run `pip install llama-index-llms-gemini` (or switch to `llama-index-llms-google`) and use `from llama_index.llms.gemini import Gemini`.","cause":"The package is not installed or the import path is incorrect.","error":"ModuleNotFoundError: No module named 'llama_index.llms.gemini'"},{"fix":"Ensure GOOGLE_API_KEY is set correctly. If using Vertex AI, check your GCP service account permissions.","cause":"Invalid or missing API key.","error":"google.api_core.exceptions.PermissionDenied: 403"},{"fix":"Use model='models/gemini-pro' instead of 'gemini-pro'.","cause":"Model name must include the 'models/' prefix.","error":"ValueError: Model name 'gemini-pro' is not valid"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}