Skip to main content
Embed text and generate completions using Google’s Gemini models. See the API reference for Gemini UDFs and Embedding UDFs for all parameters.
pip install 'geneva[udf-text-gemini]'
Gemini UDFs make API calls that incur per-token costs. Each row processed results in one or more API requests billed to your account. Review Gemini pricing before running on large tables.
Set the GEMINI_API_KEY environment variable before calling any factory function below. The key is read at UDF creation time and serialized with the UDF — no cluster-level env_vars configuration is needed.

Embeddings

Embed text with optional task-type hints for retrieval, classification, and clustering scenarios. See the API reference for all parameters. Multiple embeddings tuned for different retrieval tasks:
from geneva.udfs import gemini_embedding_udf

table.add_columns({
    # Full-dimension embedding for document retrieval
    "embedding_doc": gemini_embedding_udf(
        column="body",
        model="gemini-embedding-001",
        task_type="RETRIEVAL_DOCUMENT",
    ),
    # Compact embedding for semantic similarity
    "embedding_sim_256": gemini_embedding_udf(
        column="body",
        model="gemini-embedding-001",
        task_type="SEMANTIC_SIMILARITY",
        output_dimensionality=256,
    ),
})

Generation

Generate text from Gemini models. Supports text, image, audio, video, and document inputs. See the API reference for all parameters. Enrich a table with sentiment, captions, and transcriptions at once:
from geneva.udfs import gemini_udf

table.add_columns({
    # Classify review sentiment with a fast model
    "sentiment": gemini_udf(
        column="review",
        prompt="Classify the sentiment as positive, negative, or neutral. Return only the label.",
        model="gemini-2.5-flash",
    ),
    # Caption product images with a more capable model
    "caption": gemini_udf(
        column="image",
        prompt="Describe the main subject of this image in one sentence",
        model="gemini-2.5-pro",
        mime_type="image/jpeg",
    ),
    # Transcribe audio clips
    "transcript": gemini_udf(
        column="audio",
        prompt="Transcribe this audio clip",
        model="gemini-2.5-flash",
        mime_type="audio/mp3",
    ),
})