Reduce friction and latency for long-running jobs with Webhooks in Gemini API
Reduce friction and latency for long-running jobs with Webhooks in Gemini API
通过 Gemini API 的 Webhooks 减少长时间运行任务的摩擦与延迟
We’re making it easier and more efficient to build complex, long-running agentic applications with the Gemini API Webhooks. 我们正在通过 Gemini API Webhooks,让构建复杂且长时间运行的智能体(Agentic)应用变得更加简单高效。
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. 今天,我们正在通过 Gemini API 让构建复杂且长时间运行的智能体应用变得更加简单高效。我们引入了事件驱动的 Webhooks,这是一种基于推送的通知系统,消除了对低效轮询的需求。
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. 随着 Gemini 向智能体工作流和高吞吐量处理(如深度研究、长视频生成或通过 Batch API 处理数千个提示词)转型,相关操作可能需要数分钟甚至数小时才能完成。在此之前,开发者必须依赖持续轮询(例如重复调用 GET 操作)来检查任务是否完成。
Now, the Gemini API can simply push a real-time HTTP POST payload to your server the instant a task finishes. 现在,Gemini API 可以在任务完成的瞬间,直接向您的服务器推送实时的 HTTP POST 数据包。
We’ve built this with reliability and security in mind. Our implementation strictly adheres to the Standard Webhooks 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. 我们在构建此功能时充分考虑了可靠性和安全性。我们的实现严格遵循 Standard Webhooks 规范。每个请求都使用 webhook-signature、webhook-id 和 webhook-timestamp 标头进行签名,以确保幂等性并防止重放攻击。我们还通过长达 24 小时的自动重试机制,保证了“至少一次”的送达率。
How it works: 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). 工作原理:您可以在项目级别全局配置 Webhook(通过 HMAC 保护),也可以在每个请求的基础上动态覆盖它们,以路由特定的任务(通过 JWKS 保护)。
Get started today: This feature is available now for all developers using the Gemini API. 立即开始:此功能现已向所有使用 Gemini API 的开发者开放。
Read the guide: Check out the Webhooks documentation to explore the full event catalog and learn how to secure your endpoints. 阅读指南:查看 Webhooks 文档,探索完整的事件目录,并了解如何保护您的端点。
Hands-on practice: We’ve prepared a comprehensive Cookbook to help you build an end-to-end integration with webhooks. 动手实践:我们准备了一份全面的 Cookbook(实战指南),帮助您构建与 Webhooks 的端到端集成。