Registry / llm-agents / llama-index-embeddings-google-genai

llama-index-embeddings-google-genai

JSON →
library0.5.1pypypiunverified

This library provides the integration for Google Generative AI embedding models within LlamaIndex. It allows users to leverage Google's powerful text embedding capabilities, such as 'embedding-001' or 'text-embedding-004', for various RAG applications and data indexing tasks. The current version is 0.5.0, and it follows the LlamaIndex release cadence, often updating with new core versions or Google GenAI SDK updates.

pip install llama-index-embeddings-google-genai
INSTALL
IMPORT
SIG · LLAMA-INDEX-EMBEDD
L
llama-index-embeddings-google-genai
llm-agentspythonv0.5.1
Install
21.8s avg
Import
Disk
279MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.5.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 267.2MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 21.8s · import 0.000s · 264MB
279MB installed
● package 279MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

GoogleGenerativeAIEmbedding
from llama_index.embeddings.google_genai import GoogleGenerativeAIEmbedding
from llama_index.embeddings.google_genai import GoogleGenerativeAIEmbedding

This quickstart demonstrates how to initialize the `GoogleGenerativeAIEmbedding` model and set it as the default embedding model in LlamaIndex's global `Settings`. It then generates an embedding for a sample text. Ensure the `GOOGLE_API_KEY` environment variable is set for authentication with Google GenAI.

import os from llama_index.embeddings.google import GoogleGenerativeAIEmbedding from llama_index.core import Settings # Ensure GOOGLE_API_KEY environment variable is set # For testing purposes, you can uncomment and set it: # os.environ["GOOGLE_API_KEY"] = os.environ.get("GOOGLE_API_KEY", "YOUR_GOOGLE_API_KEY") try: # Initialize the embedding model # Optionally specify model_name, e.g., model_name="models/embedding-001" embed_model = GoogleGenerativeAIEmbedding(api_key=os.environ.get('GOOGLE_API_KEY')) # Set as the default embedding model for LlamaIndex operations Settings.embed_model = embed_model # Generate an embedding for a piece of text text_to_embed = "The quick brown fox jumps over the lazy dog." embedding = embed_model.get_text_embedding(text_to_embed) print(f"Successfully generated embedding.") print(f"Embedding dimension: {len(embedding)}") # print(f"First 5 values of embedding: {embedding[:5]}") # Uncomment to see values except ValueError as e: print(f"Error initializing or using model: {e}") if "API key not found" in str(e) or "authentication" in str(e): print("Please ensure GOOGLE_API_KEY environment variable is set and valid.") except Exception as e: print(f"An unexpected error occurred: {e}")
Debug
Known issues
breakingLlamaIndex v0.10+ modularized core components and integrations. The import path for `GoogleGenerativeAIEmbedding` changed from a potentially monolithic `llama_index.embeddings` (if it existed there) to `llama_index.embeddings.google`.
fix
Update your import statement to `from llama_index.embeddings.google import GoogleGenerativeAIEmbedding` and ensure `llama-index-embeddings-google-genai` is installed.
affects: llama-index-core < 0.10
gotchaGoogle API key authentication is typically handled via the `GOOGLE_API_KEY` environment variable. If it's not set, or is invalid, you will encounter authentication errors.
fix
Set the `GOOGLE_API_KEY` environment variable with a valid key. You can also pass it directly to the constructor: `GoogleGenerativeAIEmbedding(api_key="your_key")`.
affects: All
gotchaWhen specifying a model name, it's best practice to use the full resource name (e.g., 'models/embedding-001') as expected by the Google Generative AI API, though the library might sometimes infer it.
fix
Explicitly pass `model_name="models/embedding-001"` or `model_name="models/text-embedding-004"` to the `GoogleGenerativeAIEmbedding` constructor to avoid ambiguity.
affects: All
Upgrade
Version history
0.5.1latest on PyPI · released May 19, 2026
Audit
Dependencies
llama-index-corerequiredCore LlamaIndex functionalities, including Settings and schema definitions.
google-generativeairequiredOfficial Google Generative AI SDK for interacting with Google's models.
Agent activity
33 hits · last 30 days
node
27
OpenAI (training)
1
Resources
llama-index-embeddings-google-genai — pip install llama-index-embeddings-google-genai · libregistry