developing-genkit-python
Original:🇺🇸 English
Translated
Develop AI-powered applications using Genkit in Python. Use when the user asks about Genkit, AI agents, flows, or tools in Python, or when encountering Genkit errors, import issues, or API problems.
277installs
Sourcefirebase/agent-skills
Added on
NPX Install
npx skill4agent add firebase/agent-skills developing-genkit-pythonTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →Genkit Python
Prerequisites
- Runtime: Python 3.14+, for deps (install).
uv - CLI: — install via
genkit --versionif missing.npm install -g genkit-cli
New projects: Setup (bootstrap + env). Patterns and code samples: Examples.
Hello World
python
from genkit import Genkit
from genkit.plugins.google_genai import GoogleAI
ai = Genkit(
plugins=[GoogleAI()],
model='googleai/gemini-flash-latest',
)
async def main():
response = await ai.generate(prompt='Tell me a joke about Python.')
print(response.text)
if __name__ == '__main__':
ai.run_main(main())Critical: Do Not Trust Internal Knowledge
The Python SDK changes often — verify imports and APIs against the references here or upstream docs. On any error, read Common Errors first.
Development Workflow
- Default provider: Google AI (),
GoogleAI()in the environment.GEMINI_API_KEY - Model IDs: always prefixed, e.g. (always-on-latest Flash alias; same pattern as other skills).
googleai/gemini-flash-latest - Entrypoint: for Genkit-driven apps (not
ai.run_main(main())for long-lived servers started withasyncio.run()— see Common Errors).genkit start - After generating code, follow Dev Workflow for and the Dev UI.
genkit start - On errors: step 1 is always Common Errors.
References
- Examples: Structured output, streaming, flows, tools, embeddings.
- Setup: New project bootstrap and plugins.
- Common Errors: Read first when something breaks.
- FastAPI: HTTP, , parallel flows.
genkit_fastapi_handler - Dotprompt: files and helpers.
.prompt - Evals: Evaluators and datasets.
- Dev Workflow: , Dev UI, checklist.
genkit start