Skip to main content

Documentation Index

Fetch the complete documentation index at: https://agno-v2-fix-update-output-review.mintlify.app/llms.txt

Use this file to discover all available pages before exploring further.

The GeminiEmbedder class is used to embed text data into vectors using the Gemini API. You can get one from here.

Usage

gemini_embedder.py
from agno.knowledge.knowledge import Knowledge
from agno.vectordb.pgvector import PgVector
from agno.knowledge.embedder.google import GeminiEmbedder

# Embed sentence in database
embeddings = GeminiEmbedder().get_embedding("The quick brown fox jumps over the lazy dog.")

# Print the embeddings and their dimensions
print(f"Embeddings: {embeddings[:5]}")
print(f"Dimensions: {len(embeddings)}")

# Use an embedder in a knowledge base
knowledge = Knowledge(
    vector_db=PgVector(
        db_url="postgresql+psycopg://ai:ai@localhost:5532/ai",
        table_name="gemini_embeddings",
        embedder=GeminiEmbedder(),
    ),
    max_results=2,
)

Params

ParameterTypeDefaultDescription
dimensionsint768The dimensionality of the generated embeddings
modelstrmodels/text-embedding-004The name of the Gemini model to use
task_typestr-The type of task for which embeddings are being generated
titlestr-Optional title for the embedding task
api_keystr-The API key used for authenticating requests.
request_paramsOptional[Dict[str, Any]]-Optional dictionary of parameters for the embedding request
client_paramsOptional[Dict[str, Any]]-Optional dictionary of parameters for the Gemini client
gemini_clientOptional[Client]-Optional pre-configured Gemini client instance
enable_batchboolFalseEnable batch processing to reduce API calls and avoid rate limits
batch_sizeint100Number of texts to process in each API call for batch operations.

Developer Resources