Gemini API の Webhooks で長時間実行ジョブの摩擦と遅延を削減
本文の状態
日本語全文を表示中
詳細モードで約2分の本文を読めます。
同じ出来事の情報源
この情報源を基点に整理
TLDR AI
Google は Gemini API に Webhook 機能を追加し、開発者が長時間実行されるジョブの処理における待ち時間や複雑さを軽減できるようにした。これにより、非同期タスクの実行効率が向上する。
Source Article
元記事を日本語で読む
本文に関係しない購読案内、埋め込み通知、サイト内プロモーションは除いています。
本日、Gemini API を用いて複雑で長時間実行されるエージェント型アプリケーションを構築する際、より容易かつ効率的になるよう取り組みを行いました。私たちは、非効率なポーリングの必要性を排除するプッシュ型の通知システムであるイベント駆動 Webhooks を導入します。
Gemini が Deep Research や長編動画生成、Batch API を通じて数千ものプロンプトを処理するなど、エージェント型ワークフローや高ボリューム処理へと移行するにつれ、操作には数分乃至数時間かかることもあります。これまで開発者は、ジョブが完了したかを確認するために継続的なポーリング(例:GET 操作の繰り返し呼び出し)に頼る必要がありました。
今後は、Gemini API はタスクが完了した瞬間に、リアルタイムの HTTP POST ペイロードを直接サーバーへプッシュできるようになります。
この機能は信頼性とセキュリティを念頭に構築されました。実装は「Webhooks 仕様」に厳密に従っており、すべてのリクエストは webhook-signature、webhook-id、webhook-timestamp ヘッダーを使用して署名され、冪等性が保証されるとともにリプレイ攻撃が防止されます。また、最大 24 時間にわたる自動再試行により、「少なくとも 1 回」の配信を保証します。
Webhooks はプロジェクトレベルでグローバルに設定可能(HMAC によって保護)であり、特定のジョブをルーティングするために個別のリクエスト単位で動的に上書きすることも可能です(JWKS によって保護)。
Python SDK を使用してバッチタスクに対して Webhook を動的に構成する簡単な例を示します:
python
from google import genai
from google.genai import types
client = genai.Client()
file_batch_job = client.batches.create(
model="gemini-3-flash-preview",
src=inline_requests,
config={
"display_name": "My Setup",
"webhook_config": {
"uris": ["https://my-api.com/gemini-webhook-dynamic"],
"user_metadata": {"job_group": "nightly-eval", "priority": "high"},
},
},
)
print(f"Created batch job: {file_batch_job.name}")
この機能は、Gemini API を利用するすべての開発者に対して現在利用可能です:
- ガイドを読む:イベントカタログ全体を確認し、エンドポイントをどのように保護するかを学ぶには、こちらをご覧ください。
- ハンズオン演習:Webhook を使用したエンドツーエンドの統合を構築するための包括的なガイドを用意しました。
原文を表示
Today, we're making it easier and more efficient to build complex, long-running agentic applications with the Gemini API. We are introducing event-driven Webhooks, a push-based notification system that eliminates the need for inefficient polling.
As Gemini shifts toward agentic workflows and high-volume processing — like Deep Research, long video generation, or processing thousands of prompts via the Batch API — operations can take minutes or even hours. Until now, developers had to rely on continuous polling (e.g., repeatedly calling GET operations) to check if a job was completed.
Now, the Gemini API can simply push a real-time HTTP POST payload to your server the instant a task finishes.
We’ve built this with reliability and security in mind. Our implementation strictly adheres to the
specification. Every request is signed using webhook-signature, webhook-id, and webhook-timestamp headers, ensuring idempotency and preventing replay attacks. We also guarantee "at-least-once" delivery with automatic retries for up to 24 hours.
You can configure webhooks globally at the project level (secured via HMAC), or override them dynamically on a per-request basis to route specific jobs (secured via JWKS).
Here's a quick example of how you can dynamically configure a webhook for a batch task using the Python SDK:
python
from google import genai
from google.genai import types
client = genai.Client()
file_batch_job = client.batches.create(
model="gemini-3-flash-preview",
src=inline_requests,
config={
"display_name": "My Setup",
"webhook_config": {
"uris": ["https://my-api.com/gemini-webhook-dynamic"],
"user_metadata": {"job_group": "nightly-eval", "priority": "high"},
},
},
)
print(f"Created batch job: {file_batch_job.name}")This feature is available now for all developers using the Gemini API:
- Read the guide: Check out the to explore the full event catalog and learn how to secure your endpoints.
- Hands-on practice: We've prepared a comprehensive to help you build an end-to-end integration with webhooks.
関連記事
今日のまとめ
AIデイリーブリーフで今日の重要ニュースをまとめ読み