Skip to main content

elizaOS Google GenAI Plugin - Gemini API client for text generation, embeddings, and image analysis

Project description

elizaOS Google GenAI Plugin (Python)

Python implementation of the elizaOS Google Generative AI plugin for Gemini models.

Installation

pip install elizaos-plugin-google-genai

Quick Start

import asyncio
from elizaos_plugin_google_genai import GoogleGenAIClient, GoogleGenAIConfig

async def main():
    # Load config from environment
    config = GoogleGenAIConfig.from_env()

    async with GoogleGenAIClient(config) as client:
        # Generate text
        response = await client.generate_text_large("What is the meaning of life?")
        print(response.text)

        # Generate embeddings
        embedding = await client.generate_embedding("Hello, world!")
        print(f"Embedding dimension: {len(embedding.embedding)}")

        # Generate structured JSON
        from elizaos_plugin_google_genai import ObjectGenerationParams

        result = await client.generate_object_small(ObjectGenerationParams(
            prompt="Generate a person profile with name and age",
            json_schema={
                "type": "object",
                "properties": {
                    "name": {"type": "string"},
                    "age": {"type": "number"}
                }
            }
        ))
        print(result.object)

asyncio.run(main())

Configuration

Set the following environment variables:

Variable Required Description
GOOGLE_GENERATIVE_AI_API_KEY Yes Your Google AI API key
GOOGLE_SMALL_MODEL No Override small model (default: gemini-2.0-flash-001)
GOOGLE_LARGE_MODEL No Override large model (default: gemini-2.5-pro-preview-03-25)
GOOGLE_EMBEDDING_MODEL No Override embedding model (default: text-embedding-004)
GOOGLE_IMAGE_MODEL No Override image model
GOOGLE_TIMEOUT_SECONDS No Request timeout (default: 60)

Features

  • Text Generation: Generate text using Gemini models
  • Embeddings: Generate text embeddings for semantic search
  • Image Analysis: Analyze and describe images
  • JSON Object Generation: Generate structured JSON with schema validation
  • Async/Await: Full async support for efficient I/O
  • Type Safety: Full type hints with Pydantic models

Development

# Install dev dependencies
pip install -e ".[dev]"

# Run tests
pytest

# Type checking
mypy elizaos_plugin_google_genai

# Linting
ruff check .
ruff format .

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

elizaos_plugin_google_genai-2.0.0a4.tar.gz (10.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

elizaos_plugin_google_genai-2.0.0a4-py3-none-any.whl (11.2 kB view details)

Uploaded Python 3

File details

Details for the file elizaos_plugin_google_genai-2.0.0a4.tar.gz.

File metadata

File hashes

Hashes for elizaos_plugin_google_genai-2.0.0a4.tar.gz
Algorithm Hash digest
SHA256 d101e9c2962efb629273ee550886e202d3490332ea9f239ea5edb807ea94d01a
MD5 650b987876ddc0d4d4bdfaf57d26b17f
BLAKE2b-256 681eea698c4de1b7920bfbcdb7ebe6380680a6fec417ae739caf87fa29f7ea04

See more details on using hashes here.

File details

Details for the file elizaos_plugin_google_genai-2.0.0a4-py3-none-any.whl.

File metadata

File hashes

Hashes for elizaos_plugin_google_genai-2.0.0a4-py3-none-any.whl
Algorithm Hash digest
SHA256 017da104fbadd77a6ca313224fe566d4ef72413d4331ae279231a9e4d15e832b
MD5 3b71a044736e65462c46f69e2f6e70a4
BLAKE2b-256 1dd9ab2386eebeea1ba7b1000e1201f875c1c16b85f6019404dcada25fe10510

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page