Skip to main content
Embeddings are handled by the GeminiEmbeddings class, which is a wrapper around the Google GenAI API.

Installation

Gemini embeddings require the google-genai and numpy libraries. See the Installation Guide for more information.
pip install "chonkie[gemini]"

Usage

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")

Example

texts = ["Hello world", "Goodbye world"]
embeddings = GeminiEmbeddings()
vectors = embeddings.embed_batch(texts)
I