developing-genkit-python

Build AI agents, flows, and streaming applications in Python using the Genkit SDK.

Updated May 11, 2026
One-click install
npx skills add https://github.com/alon3153/upe-social-publisher --skill developing-genkit-python-alon3153
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: developing-genkit-python
Source: https://github.com/alon3153/upe-social-publisher/tree/main/.agents/skills/developing-genkit-python
Command: npx skills add https://github.com/alon3153/upe-social-publisher --skill developing-genkit-python-alon3153

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Building AI-powered Python applications involves juggling model calls, tool loops, streaming, session state, and debugging without visibility. This Skill provides structured guidance for developing with the Genkit Python SDK, covering everything from first setup to multi-turn agents with human approval, plus trace-based debugging workflows. ## Core Features & Use Cases - Agent Development: Define multi-turn agents with tools, typed session state, human-in-the-loop approvals, branching, background tasks, and artifacts using ai.define_agent. - Flows & Streaming: Create single-shot flows with structured output, streaming via ctx.send_chunk, and serve them over FastAPI with SSE. - Dev Workflow & Debugging: Run apps under genkit start to capture traces, inspect model I/O with genkit trace:get, and resolve common errors like wrong imports or missing model prefixes. - Use Case: You want to build a support chatbot in Python that remembers conversation history, asks for approval before executing sensitive tools, and can be served over HTTP. This Skill walks you through defining the agent, attaching a session store, adding ToolApproval middleware, and verifying behavior with traces. ## Quick Start Ask the assistant to create a Genkit Python app that defines an agent with a tool and runs it under genkit start with trace inspection.

Frequently Asked Questions about developing-genkit-python

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I build a multi-turn AI agent in Python with Genkit?▼

Use ai.define_agent with a model, system prompt, tools, and a session store like InMemorySessionStore. Then call agent.chat() and use chat.send or chat.send_stream for each turn; history is persisted automatically when a store is attached.

How do I add human approval for tool calls in a Genkit agent?▼

Register the Middleware plugin and pass ToolApproval with an allowed_tools list in the agent's use parameter. Tools not in the list pause with an INTERRUPTED finish reason, and you resume with chat.resume using restart or respond parts built from res.interrupts.

How do I serve a Genkit flow or agent over HTTP with FastAPI?▼

Install genkit-fastapi and mount actions with serve_flow or serve_agent on a FastAPI router. Endpoints accept {"data": ...} and return {"result": ...}, streaming via SSE when the client sends Accept: text/event-stream.

Why does my Genkit tool call fail with a schema error on Gemini?▼

Gemini requires tool parameters to be a JSON object, so bare scalar arguments like str or float fail. Wrap parameters in a Pydantic BaseModel subclass, even for a single field, and decorate the function with @ai.tool().

How do I debug Genkit Python apps and see model inputs and outputs?▼

Run the app under genkit start, which captures traces from every Genkit action. Then use genkit trace:list and genkit trace:get <traceId> --format json to inspect prompts, tool calls, latencies, and errors from the terminal.

Can I run a Genkit agent directly from the CLI for testing?▼

genkit flow:run only executes flows, not agents. To test an agent from the CLI, wrap one chat turn in a throwaway @ai.flow() function and run that flow with genkit flow:run, which is self-terminating and prints a trace ID.