developing-genkit-python
Genkit Python
Prerequisites
- Runtime: Python 3.14+,
uvfor deps (install). - CLI:
genkit --version— install vianpm install -g genkit-cliif missing.
New projects: Setup (bootstrap + env). Patterns and code samples: Examples.
Hello World
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()),GEMINI_API_KEYin the environment. - Model IDs: always prefixed, e.g.
googleai/gemini-flash-latest(always-on-latest Flash alias; same pattern as other skills). - Entrypoint:
ai.run_main(main())for Genkit-driven apps (notasyncio.run()for long-lived servers started withgenkit start— see Common Errors). - After generating code, follow Dev Workflow for
genkit startand the Dev UI. - 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,
genkit_fastapi_handler, parallel flows. - Dotprompt:
.promptfiles and helpers. - Evals: Evaluators and datasets.
- Dev Workflow:
genkit start, Dev UI, checklist.
More from firebase/skills
firebase-hosting-basics
Skill for working with Firebase Hosting (Classic). Use this when you want to deploy static web apps, Single Page Apps (SPAs), or simple microservices. Do NOT use for Firebase App Hosting.
562firebase-ai-logic
Official skill for integrating Firebase AI Logic (Gemini API) into web applications. Covers setup, multimodal inference, structured output, and security.
489firebase-data-connect
Builds and deploys Firebase SQL Connect (aka Firebase Data Connect) backends with PostgreSQL securely. Use when designing schemas with tables and relations, writing authorized queries and mutations, configuring real-time data updates, or generating type-safe SDKs. Use when you need a relational database with Firebase, or when the user mentions SQL Connect or Data Connect.
486firebase-firestore-basics
Comprehensive guide for Firestore basics including provisioning, security rules, and SDK usage. Use this skill when the user needs help setting up Firestore, writing security rules, or using the Firestore SDK in their application.
279