Skip to main content

Google GenAI Plugin

This Genkit plugin provides a unified interface for Google AI (Gemini) and Vertex AI models, embedding, and other services.

Setup environment

uv add genkit genkit-google-genai

Configuration

Google AI (AI Studio)

To use Google AI models, obtain an API key from Google AI Studio and set it in your environment:

export GEMINI_API_KEY='<your-api-key>'

Vertex AI (Google Cloud)

To use Vertex AI models, ensure you have a Google Cloud project and Application Default Credentials (ADC) set up:

gcloud auth application-default login

Quickstart

from genkit import Genkit
from genkit_google_genai import GoogleAI

ai = Genkit(plugins=[GoogleAI()], model=GoogleAI.gemini_model('gemini-flash-latest'))


@ai.flow()
async def greet(name: str) -> str:
    res = await ai.generate(prompt=f'Say hello to {name}.')
    return res.text

Features

Dynamic Models

The plugin automatically discovers available models from the API upon initialization. You can use any model name supported by the API (e.g., GoogleAI.gemini_model('gemini-flash-latest'), VertexAI.gemini_model('gemini-2.5-pro')).

Dynamic Configuration

Unrecognized provider parameters on the family config are forwarded to the API:

from genkit_google_genai import GeminiConfigSchema

config = GeminiConfigSchema.model_validate({
    'temperature': 1.0,
    'response_modalities': ['TEXT', 'IMAGE'],
})

Video generation (Veo)

Video is a job, not a round-trip. generate_operation hands back a ticket; check_operation is how you find out when the video is ready. When the job finishes, operation.output has a playable media.url — Studio sends a download URL, Vertex often sends the mp4 inline.

With GoogleAI:

from genkit import Genkit
from genkit_google_genai import GoogleAI

ai = Genkit(plugins=[GoogleAI()])

operation = await ai.generate_operation(
    model=GoogleAI.veo_model('veo-3.1-fast-generate-preview'),
    prompt='A paper airplane gliding through a bright classroom',
)
while not operation.done:
    operation = await ai.check_operation(operation)
print(operation.output)

With VertexAI:

from genkit import Genkit
from genkit_google_genai import VertexAI

ai = Genkit(plugins=[VertexAI()])

operation = await ai.generate_operation(
    model=VertexAI.veo_model('veo-3.1-generate-001'),
    prompt='A paper airplane gliding through a bright classroom',
)
while not operation.done:
    operation = await ai.check_operation(operation)
print(operation.output)

Runnable version: google-genai-media.

Vertex AI Evaluators

Built-in evaluators for assessing model output quality. Evaluators are automatically registered when using the VertexAI plugin and are accessed via ai.evaluate():

from genkit import Genkit
from genkit.evaluator import BaseDataPoint
from genkit_google_genai import VertexAI

ai = Genkit(plugins=[VertexAI(project='my-project')])

# Prepare test dataset
dataset = [
    BaseDataPoint(
        input='Write about AI.',
        output='AI is transforming industries through intelligent automation.',
    ),
]

# Evaluate fluency (scores 1-5)
results = await ai.evaluate(
    evaluator='vertexai/fluency',
    dataset=dataset,
)

for result in results.root:
    print(f'Score: {result.evaluation.score}')

Runnable snippets are in py/samples.

Metadata

Release files for genkit-google-genai 0.12.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for genkit-google-genai 0.12.0
File Size Uploaded Provenance Actions
genkit_google_genai-0.12.0.tar.gz 133.9 kB With provenance Details for genkit_google_genai-0.12.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for genkit-google-genai 0.12.0
File Interpreter ABI Platform Actions
genkit_google_genai-0.12.0-py3-none-any.whl Python 3 none any Details for genkit_google_genai-0.12.0-py3-none-any.whl

Total release size: 235.2 kB

Release files / genkit_google_genai-0.12.0.tar.gz

Download URL genkit_google_genai-0.12.0.tar.gz
Size 133.9 kB
Tags Source
SHA-256 checksum
How to use checksums
287e44b4680d2084c7381eca24c68b53778cad9286bf8054e13f929106bcf9a7
BLAKE2b-256 checksum
How to use checksums
6d95d0c5c0b722456a5e822cdbf6738c34473463f7cafdedd7ec305b888a3326
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 24, 2026.

Transparency log

Release files / genkit_google_genai-0.12.0-py3-none-any.whl

Download URL genkit_google_genai-0.12.0-py3-none-any.whl
Size 101.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b42b0084590633792824b61874d1187fa5864f86118a0c92a5d4d4b5ab86399f
BLAKE2b-256 checksum
How to use checksums
a5313ba9623516d4a89c3f5af1af6fabb464666912cddea94eaf2424edaa5142
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 24, 2026.

Transparency log

Security for genkit-google-genai 0.12.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for genkit_google_genai-0.12.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 24, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page