Gemini API

Gemini API Ra Mắt Webhooks: Thay Polling Bằng Push Notification Cho Long-Running Jobs

06/05/2026 6 phút đọc Gemini, Google, API, Developer Tools
Gemini API Webhooks

TL;DR

Google ra mắt event-driven Webhooks trong Gemini API — thay thế polling không hiệu quả bằng push notifications real-time. Khi long-running jobs hoàn thành (Deep Research, video generation, Batch API), Gemini push HTTP POST thẳng đến server của bạn. Signed requests + at-least-once delivery với auto retries 24h.

Tại sao Webhooks thay đổi cuộc chơi

Trước đây, developers phải dùng polling — liên tục gọi GET operations để kiểm tra job xong chưa. Cách này:

  • Tốn resource — gọi API liên tục dù job chưa xong
  • Latency cao — phải chờ interval để check lần tiếp theo
  • Không scalable — hàng nghìn jobs = hàng nghìn polling requests

Giờ đây, Gemini push notification tức thì khi task kết thúc — không cần hỏi liên tục, không delay.

Use cases phù hợp

  • Deep Research — nghiên cứu sâu mất nhiều phút
  • Long video generation — tạo video dài
  • Batch API — xử lý hàng nghìn prompts cùng lúc

Security & reliability

Google build Webhooks này với security và reliability trong tâm:

  • Standard Webhooks spec — tuân thủ specification chuẩn ngành
  • Signed requests — mỗi request có webhook-signature, webhook-id, webhook-timestamp headers để verify
  • Idempotency — ngăn replay attacks
  • At-least-once delivery — guarantee delivery với automatic retries trong 24h

Cách config

Hai cách setup:

  • Project level (HMAC) — config global cho tất cả jobs trong project
  • Per-request (JWKS) — override dynamically để route specific jobs đến endpoints khác nhau
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}")

Cộng đồng phản ứng

@AI_Andrew: "This is nice, no more rigging a web of alerts, one less thing I have to bolt on. Big win for the DX!" — developers đánh giá cao việc đơn giản hóa workflow.

@InsiderPresider: "I have to wonder is this actually better than what we had before" — một số người còn hoài nghi về implementation.

Chốt một câu

Gemini API Webhooks giải quyết đúng pain point của developers làm việc với agentic workflows: long-running jobs không cần polling nữa. Push notifications real-time với security và reliability từ Google — đây là bước tiến tự nhiên khi Gemini shift sang agentic era. Batch processing hàng nghìn prompts với notification khi xong — đó mới là cách scalable để làm việc với AI.

Đọc tiếp Gemma 4 Chạy Hoàn Toàn On-Device Trong React Native — Mobile Developers Sắp Có Công Cụ Mới
Xem tất cả bài viết
Gemini Google API Webhooks Developer