GeminiEmbeddings class, which is a wrapper around the Google GenAI API.
Installation
Gemini embeddings require thegoogle-genai and numpy libraries. See the Installation Guide for more information.
Embed text using Google Gemini embeddings via GenAI API
GeminiEmbeddings class, which is a wrapper around the Google GenAI API.
google-genai and numpy libraries. See the Installation Guide for more information.
pip install "chonkie[gemini]"
from chonkie import GeminiEmbeddings
# Initialize Gemini embeddings
embeddings = GeminiEmbeddings(
model="gemini-embedding-exp-03-07", # Optional: specify model
api_key="YOUR_GEMINI_API_KEY", # Optional: or set GEMINI_API_KEY env var
task_type="SEMANTIC_SIMILARITY", # Optional: task type
)
# Embed a single text
vector = embeddings.embed("Your text here")
texts = ["Hello world", "Goodbye world"]
embeddings = GeminiEmbeddings()
vectors = embeddings.embed_batch(texts)
Was this page helpful?