developing-genkit-python
できること
Genkit SDKを使い、Pythonで AI機能を作る開発者を支援します。モデル呼び出し、ツール、エージェントをアプリに加えたいPythonのチーム向けです。
使う場面
- ✓GenkitでPythonのAI機能、フロー、ツールを作りたいとき。
- ✓Pythonのアプリで、履歴を持つ複数ターンのエージェントのチャットが必要なとき。
- ✓PythonのコードでGenkitのインポートエラーやAPIの問題を直しているとき。
スキルのリンク
https://github.com/google/skills/blob/main/skills/cloud/developing-genkit-python/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“Genkitを使い、プロンプトをGeminiに送って答えを表示するPythonのスクリプトを書いてください。”
毎週5つの新しいスキル。1分で読めます。
仕組み
エージェントは、Google GenAIプラグインを使い、Genkit APIでPythonのコードを書きます。セットアップと例については、参照ガイドを案内します。説明されたuvのツールの設定を使います。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)をGitHubからそのまま表示しています。
Genkit Python
Build AI features in Python — generate, stream, tools, flows, and multi-turn agents — with one SDK.
Prerequisites
- Python 3.10+ and
uv(install) - Genkit CLI:
npm install -g genkit-cliifgenkit --versionis missing
New app? Setup. Patterns? Examples.
Hello World
from genkit import Genkit
from genkit_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())
Agents (Beta)
Multi-turn chats with history, typed state, human approval, branching, and background work. Start here: Agents.
chat = agent.chat()
res = await chat.send('Hello') # AgentResponse
turn = chat.send_stream('Hello') # AgentTurn — .stream / .response
More: sessions · HITL · branching · background · state · artifacts · custom · HTTP
Imports
- Google AI:
from genkit_google_genai import GoogleAI - Agents:
from genkit.agent import InMemorySessionStore, ... - Middleware:
from genkit_middleware import Middleware, ToolApproval, ... - FastAPI:
from genkit_fastapi import serve_agent, serve_flow - Evals:
from genkit_evaluators import register_genkit_evaluators
Workflow
- Agent or flow? If the task is conversational, multi-turn, or described as
"an agent", "assistant", or "chatbot", build it with
ai.define_agent(see Agents) rather than hand-rolling agenerate+ tools loop inside a flow. Reach for a plain flow only for single-shot, stateless generation. - Set
GEMINI_API_KEY. Use prefixed model ids (googleai/gemini-flash-latest). - Enter via
ai.run_main(main())for Genkit apps (especially undergenkit start). See Common Errors. - Run with Dev Workflow (
genkit start+ Dev UI). - Verify with traces, not a blind run. Running the app directly (
uv run) does not capture dev traces. See Genkit CLI for how to run your app and capture traces. - Stuck? Common Errors first.
Genkit CLI (recommended)
genkit start unintrusively wraps any Python program that uses the Genkit library, running it unchanged while capturing traces from every Genkit action so you can prove tools were actually called and inspect model I/O from the terminal, even for headless checks. It forwards stdio, so interactive CLI tools that rely on stdin/stdout work without issues. Running the app directly (uv run) skips trace capture, so you're debugging blind.
Primary pattern (default): prefix genkit start -- to your normal run command. This collects telemetry from any Genkit code your program runs, whether triggered from the dev UI, your own web server/web UI, or a plain script:
genkit start -- uv run src/main.py
genkit start --noui -- uv run src/main.py # same, without the Dev UI (still a persistent server)
genkit start runs until you stop it with Ctrl+C. That is expected and correct for the common cases: a server your web/mobile app calls, or an interactive CLI you exit yourself. --noui only drops the Dev UI; it is not a one-shot command and will not exit on its own. Do not use genkit start as a blocking step in automated/non-interactive contexts; use flow:run (below) for that.
Non-interactive use (agents/CI): add the global --non-interactive flag before -- so the CLI uses defaults and never blocks on a prompt (e.g. the first-run analytics notice): genkit start --non-interactive -- uv run src/main.py (works with flow:run too).
Run a flow (flow:run): invoke a specific flow by name from the CLI. Append your run command after -- to spin up the runtime just for this run (the command runs as-is to register your flows):
genkit flow:run myFlow '{"data": "input"}' -- uv run src/main.py
This is self-terminating: i
よくある質問
Pythonのどのバージョンが必要ですか?
Python 3.10以上と、uvツールが必要です。
エージェントにも対応していますか?
はい。セッションや人の承認ステップを含む、Genkitのベータ版エージェントAPIに対応しています。
例は含まれていますか?
はい。よくある作業のための例のパターンを案内します。
詳細
作者による元の説明
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.
repo: google/skills
人気
- GitHubのスター
- 22k
- ランキング
- #10258
- ライセンス
- Apache-2.0
- 更新日
- 2026/11/2
コメント
- …
このリポジトリの他のスキル
finding-google-skills
22kセットアップ作業に合うGoogleの公式ガイドを探すようエージェントを支援します。ホスティング、データベース、ストレージ、サインイン、AIモデルの提供などが対象です。
gcloud
22kエージェントが、Google CloudのgcloudコマンドについてWeb検索に頼らず、正確な構文を確かめてから書いたり確認したりできるよう支援します。
google-cloud-recipe-auth
22kエージェントが、Google Cloudのアイデンティティとアクセス(人やサービスがどうサインインし、どの権限を得るか)について、手順を案内できるよう支援します。
google-cloud-recipe-onboarding
22k新しい開発者が、プロジェクトの選択、請求の設定、最初のリソースのデプロイなど、Google Cloudの最初の手順を進められるよう案内します。
似ているスキル
api-connector-builder
280kエージェントが既存のパターンに従って、新しいAPI連携を構築します。新しい方式を作らずに、もう一つ連携を追加したいときに使います。
api-design
280kエージェントがベストプラクティスに沿ってREST APIを設計できるようにします。APIの通信方法、エラーの表示方法、データの整理方法を決めるのに役立ちます。
backend-patterns
280kエージェントのサーバーサイドのアーキテクチャパターンとデータベースの最適化を支援します。サーバー上で動くコードを作成またはレビューするときに役立ちます。