Setup — Genkit Python
New project
Always use a virtual environment — never install Genkit into the system
interpreter. With uv, uv add and uv run manage .venv automatically.
mkdir my-app && cd my-app
uv init
# Genkit requires Python 3.10+. If `uv init` pins a newer interpreter in
# pyproject.toml or .python-version than you have installed, adjust it first.
uv venv --python 3.12 .venv
uv add 'genkit==0.13.*' 'genkit-google-genai==0.13.*'
export GEMINI_API_KEY=your_key_hereKeep genkit and every genkit-* package on the same 0.13.* release.
pydantic is installed automatically with genkit, though adding pydantic
directly to pyproject.toml is fine when defining your own BaseModel schemas.
Place your entrypoint at src/main.py (or match the file generated by
uv init) and run it under genkit start -- uv run src/main.py.
pyproject.toml
[project]
name = "my-app"
version = "0.1.0"
requires-python = ">=3.10"
dependencies = [
"genkit==0.13.*",
"genkit-google-genai==0.13.*",
]Packages and Imports
PyPI distribution names use hyphens (genkit-*); Python import modules use
underscores (genkit_*). Import everything from each package's top-level module
(or .exp for experimental agent integrations):
genkit-google-genai:from genkit_google_genai import GoogleAI, VertexAI, GeminiConfig(Gemini API viaGEMINI_API_KEY, or Google Cloud Vertex AI via ADC).genkit-vertexai:from genkit_vertexai import ModelGarden(third-party models on Vertex AI Model Garden). Install the extra matching the models you call:uv add 'genkit-vertexai[anthropic]'for Claude modelsuv add 'genkit-vertexai[openai]'for Llama, Mistral, and OpenAI-compatible models
genkit-anthropic:from genkit_anthropic import Anthropic, AnthropicConfig(ANTHROPIC_API_KEY).genkit-openai:from genkit_openai import OpenAI, OpenAIConfig(OPENAI_API_KEYor custombase_url=).genkit-ollama:from genkit_ollama import Ollama, OllamaConfig(local Ollama server; auto-discovers pulled models).genkit-amazon-bedrock:from genkit_amazon_bedrock import Bedrock, BedrockConfig, StabilityImageConfig.genkit-middleware:from genkit_middleware import Middleware, Retry, Fallback, ToolApproval, Skills, Filesystem(plusfrom genkit_middleware.exp import Artifactsfor agent sessions).genkit-fastapi:from genkit_fastapi import serve_flow, genkit_fastapi_handler, handle_genkit_request(plusfrom genkit_fastapi.exp import serve_agent).genkit-flask:from genkit_flask import genkit_flask_handler(requiresflask[async]; does not installgenkit-google-genaiautomatically; add your model plugin explicitly).genkit-django:from genkit_django import genkit_django_handler.genkit-mcp:from genkit_mcp import McpClient, McpHost, define_mcp_client, define_mcp_host(Model Context Protocol clients and tool hosts).genkit-google-cloud:from genkit_google_cloud import enable_google_cloud_telemetry(plusfrom genkit_google_cloud.exp import FirestoreSessionStore).genkit-otel:from genkit_otel import GenAiInstrumentation, ContentCapturingMode, OtelEventLogger(OpenTelemetry GenAI spans and metrics).genkit-evaluators:from genkit_evaluators import register_genkit_evaluators. Last release with evaluators; Genkit 1.0 cuts evaluators from the 1.0 release (evaluation will return as an additive feature in a later release). Requiresgenkit<1(see Evals).
Python version
Python 3.10+. Upgrading an existing 0.12 app? Follow Migrating from 0.12 to 0.13.