Resources / Blog & comparisons
Asynchronous Task Architecture

Polling vs Webhooks for AI Video APIs: When to Use Each

Compare webhook delivery and task polling on Giky API for AI video jobs, covering HMAC checks, retries, deduplication, and reconciliation.

THE VERDICT

Event-driven callbacks vs private worker checks

Choose webhooks when your backend exposes a public HTTPS listener to process finished renders without continuously checking task status. Use polling when services run behind private networks without public endpoints or need strict control over check intervals.

Ocean waves from above, illustrating a camera and motion brief
Editorial illustration. This image is not an output comparison or a benchmark result.

Submitting a video job to Giky API starts work in the background. A POST /v1/tasks call returns HTTP 202 with a task id while rendering runs asynchronously across queued, submitting, and running states. Because render times vary and responses do not include a percentage bar or a file-expiry timestamp, your backend cannot simply hold a request open until the clip is ready.

That leaves an architectural choice for how your application learns when a job finishes, fails, or lands in needs_review. Here is how push webhooks and pull polling fit real video pipelines on Giky API, where each path breaks down, and how combining them keeps state accurate without wasted work.

Side-by-side comparison

Swipe horizontally to compare all columns →

Polling vs webhooks for asynchronous video tasks on Giky API
Decision factorWebhooksPolling
Endpoint setupRequires public HTTPS endpoint in Dashboard to Webhooks or approved callback URLNo callback URL required; queries GET /v1/tasks/{id} with Bearer API key
Completion signalDelivers signed events such as task.succeeded and task.failedReads current status across queued, submitting, running, succeeded, failed, needs_review
Auth and integrityVerifies hex HMAC-SHA256 over timestamp + "." + raw body and five-minute windowAuthenticates via Authorization: Bearer YOUR_API_KEY scoped to the owning key
Retry and deliveryRetries up to eight attempts; delivery failure does not equal generation failureRepeated polling at five seconds or longer never triggers another generation
Long video jobsAvoids continuous polling loops while waiting for completion eventsUses bounded poll windows with saved task IDs to resume later or paginate GET /v1/tasks
Audit and recoveryInspects delivery records via GET /v1/tasks/{id}/events when events are missedDirectly reads latest outputs or error_code and reconciles uncertain states
Operational burdenRequires public TLS endpoint, raw-body signature check, and event deduplicationRequires scheduled HTTP reads, state transitions, and worker concurrency control

Contract details checked November 26, 2026. Available combinations and prices can change; confirm the current model reference before submitting a task.

Webhook Push vs Task Polling Flow

Webhooks
  1. 01Submit task with callback endpoint_id
  2. 02Verify HMAC and five-minute window
  3. 03Deduplicate ID and store outputs
Polling
  1. 01Persist task id from HTTP 202
  2. 02Poll GET /v1/tasks/{id} every 5s+
  3. 03Resume bounded check or reconcile
Editorial workflow diagram illustrating push and pull paths; not a benchmark or generated output.
01

Should your video pipeline use push alerts or polling?

Pick between webhooks and polling based on what your infrastructure can run reliably, not which pattern sounds newer. Webhooks shine when your service already has a reachable HTTPS endpoint, can grab raw request bytes before JSON parsing, and writes incoming events to durable storage before sending back a 2xx response. When those pieces work together, downstream workers react quickly without sitting in idle read loops.

Polling fits internal batch jobs, cron scripts, and teams that want outbound-only workers without opening inbound callback routes. A worker using GET /v1/tasks/{id} with the owning Bearer API key simply reads current task state at intervals of five seconds or longer, with zero risk of kicking off a second render.

Even when webhooks are your main path, networks drop packets and containers restart mid-deployment. Combining webhook notifications for fast updates with scheduled polling on older open task IDs lets your system converge cleanly without hammering the API for every active render.

  • Preserve raw request bytes before JSON parsing so signature checks do not break
  • Favor polling when outbound-only workers simplify firewall and ingress setup
  • Use the same Bearer API key that created the task when reading status
02

How do you verify incoming alerts and skip duplicates?

Any public callback URL faces untrusted traffic, so your handler must prove a request came from Giky before changing task state. Deliveries carry X-Webhook-Id, X-Webhook-Timestamp, and X-Webhook-Signature. Giky generates X-Webhook-Signature as a hex HMAC-SHA256 digest over the timestamp string, a literal dot, and the exact raw request body using your endpoint secret.

If middleware parses JSON and re-encodes it before hashing, small shifts in whitespace or key order will mismatch the signature. Hash the raw bytes directly, compare digests in constant time, and reject timestamps outside a five-minute window to cut down replay risk.

Because deliveries can repeat and Giky retries up to eight times, deduplicate incoming requests by X-Webhook-Id and commit the receipt to durable storage before returning 2xx. Acknowledging only after durable writes prevents a dropped event if a database write or queue push fails mid-request.

  • Reject requests whose X-Webhook-Timestamp sits outside a five-minute window
  • Compute hex HMAC-SHA256 over timestamp + "." + exact raw body bytes with constant-time comparison
  • Deduplicate by X-Webhook-Id after durable persistence before returning 2xx
Verify raw-body HMAC signature, five-minute replay window, and deduplicate X-Webhook-Idjavascript
import { createHmac, timingSafeEqual } from "node:crypto";

// Adapter contract: store.insertIfAbsent must atomically and durably
// insert a pending event, returning false if its ID already exists.
// Process pending events in a worker with its own idempotent writes.
export async function verifyAndHandleWebhook(rawBody, headers, secret, store) {
  const eventId = headers["x-webhook-id"];
  const timestamp = headers["x-webhook-timestamp"];
  const signature = headers["x-webhook-signature"];
  if (!eventId || !/^\d+$/.test(timestamp || "") ||
      !/^[a-f0-9]{64}$/i.test(signature || "")) {
    return { status: 400 };
  }
  const seconds = Number(timestamp);
  if (!Number.isSafeInteger(seconds) ||
      Math.abs(Math.floor(Date.now() / 1000) - seconds) > 300) {
    return { status: 401 };
  }
  const expected = createHmac("sha256", secret)
    .update(timestamp + ".").update(rawBody).digest();
  if (!timingSafeEqual(expected, Buffer.from(signature, "hex"))) {
    return { status: 401 };
  }
  let payload;
  try { payload = JSON.parse(rawBody.toString("utf8")); }
  catch { return { status: 400 }; }
  if (payload.id !== eventId) return { status: 400 };
  // A storage failure must throw: return 5xx, never acknowledge a lost event.
  const inserted = await store.insertIfAbsent(eventId, payload);
  return { status: 200, duplicate: !inserted };
}

Illustrative Node.js verifier, tested with local fixtures. Preserve the exact raw request bytes. Implement insertIfAbsent as a durable atomic inbox insert with a unique event ID; a separate worker processes pending events idempotently. The HTTP adapter must return 5xx if storage throws.

03

How can you track render progress without overloading workers?

When calling GET /v1/tasks/{id}, let the returned status field guide your logic rather than guessing duration from clip length or resolution. A job moves through queued, submitting, and running before reaching a terminal or review outcome, and polling every five seconds or more never starts another generation.

If a task sits in submitting, wait for that handoff to settle or inspect status using the existing id instead of firing a replacement job. For longer renders, avoid tying up a worker forever: run a bounded poll window, save the task id, and check back later or page through GET /v1/tasks using limit between 1 and 100 and next_cursor.

Once status reads succeeded, fetch and store the HTTPS URLs from outputs right away in your own asset storage. Task responses do not expose provider routing or a file-expiry timestamp, so saving your own references avoids broken links later.

  • Space GET /v1/tasks/{id} polls at five seconds or longer
  • Wait through queued, submitting, and running; never resubmit while submitting
  • Use bounded poll windows and save task IDs to resume or paginate GET /v1/tasks
Bounded Polling and Resume Loop: Active Poll Window compared with Resume and Terminal
Editorial workflow diagram of bounded polling and saved-ID resumption; not a benchmark or generated output.
04

What should happen when updates stall or need review?

A missing webhook does not mean the render failed. Callback delivery can stall or fail on its own, and Giky retries up to eight times. If task.succeeded or task.failed does not show up when expected, check GET /v1/tasks/{id} and review GET /v1/tasks/{id}/events before deciding what happened.

When a task lands in needs_review, stop automatic retries and hold onto the task id so a reconciliation job or operator can inspect it. Blindly retrying a needs_review job can trigger unwanted charges or clashing state updates.

If POST /v1/tasks times out or returns HTTP 5xx, the server may have already accepted the job. Replay the exact same request with the same Idempotency-Key and identical JSON body within the 64 KiB cap rather than generating a new key, then read the task once id comes back.

  • Check GET /v1/tasks/{id} and GET /v1/tasks/{id}/events when callbacks are late or absent
  • Halt automatic retries on needs_review and keep the task id for review
  • Replay identical requests with the same Idempotency-Key on timeouts or HTTP 5xx
05

How do you recover after timeouts and server restarts?

Picture a media orchestrator backed by a durable task ledger keyed by a pre-generated Idempotency-Key, moving jobs through pending_submit, active, awaiting_reconciliation, and completed. At t=0s, it saves the payload and Idempotency-Key before calling POST /v1/tasks, where REST creation uses no confirmation flag unlike an MCP call that requires confirm_charge:true. At t=6s, the connection times out before returning an HTTP 202 body, leaving the orchestrator without a task id even though the job may already be queued or submitting. Instead of calling POST /v1/tasks/{id}/cancel—which only works before upstream submission and returns HTTP 409 once submitted—it marks the record awaiting_reconciliation and replays the exact body with the same Idempotency-Key at t=10s, recovering the original task id from HTTP 202.

At t=42s, rendering completes and Giky sends task.succeeded, but the webhook receiver crashes right after checking X-Webhook-Signature over the timestamp and raw body and writing the event durably, before returning HTTP 200. Because no 2xx came back, Giky schedules a retry while the receiver restarts at t=45s and reloads its durable event table from disk. At t=50s, the retry arrives carrying the same X-Webhook-Id; the restarted handler sees the ID already stored, skips duplicate asset ingestion, and returns HTTP 200 so retries stop.

At t=55s, a scheduled reconciliation sweep checks any record still sitting in awaiting_reconciliation, calls GET /v1/tasks/{id} and GET /v1/tasks/{id}/events, and confirms both the succeeded state and the recorded delivery. Keeping separate durable stores for event receipts and task state prevents duplicate work and duplicate renders when both enforce uniqueness and recovery checks them.

06

How many workers handle a busy batch of renders?

When you skip webhooks or use them alongside scheduled status sweeps, capacity depends on bounded check windows and worker concurrency rather than guessing unverified rate limits. Take a hypothetical batch run of 120 concurrent video tasks (N = 120), each assumed to run for 90 seconds, polled on GET /v1/tasks/{id} every 6 seconds (I = 6s, respecting the five-second minimum) inside a 120-second active window. Under those labeled assumptions, steady-state traffic is N / I = 120 / 6 = 20 GET requests per second, and each 90-second job takes 90 / 6 = 15 polls, or 1,800 reads across the batch of 120.

With an assumed average GET /v1/tasks/{id} round-trip time of 150 ms (L = 0.15s), Little's Law gives a minimum of 20 req/s x 0.15s = 3 busy HTTP workers; sizing to 6 or 8 workers gives breathing room for network hiccups without missing the 6-second cadence. A shared scheduler table storing task_id, lease_expires_at, and next_poll_at lets multiple worker instances claim due items atomically instead of double-polling the same task. Any job still running past the 120-second window can move to a slower background sweep or paginated GET /v1/tasks (limit up to 100 with next_cursor), keeping read concurrency steady even when clip lengths swing.

07

How do you match settings to each video model?

Your update strategy also sits on top of the task contract you send to POST /v1/tasks. Across active models on Giky API—including Kling 4.0, MiniMax H3, Seedance 2.0, Seedance 2.5, Veo 3.1 Standard, and Wan 3.0—allowed operations, resolutions, aspect ratios, durations, and optional inputs like keyframe_urls, last_image_urls, or generate_audio vary by model.

Checking required fields and allowed enum values before posting avoids avoidable client or validation errors before a job starts. Also check generationAvailable in the catalog: Grok Video 2.0 appears with generationAvailable set to false, so confirm availability before pointing production traffic at a model.

Keep each POST /v1/tasks body to a single JSON object up to 64 KiB with no base64 uploads, multipart bodies, or batch arrays. Note also that POST /v1/tasks/{id}/cancel only cancels prior to submission—returning HTTP 409 once past that point and setting status to failed with error_code cancelled_before_submit.

  • Check model slug, operation, required fields, and enums against the model contract
  • Verify generationAvailable before routing traffic (Grok Video 2.0 has generationAvailable: false)
  • Keep JSON payloads at or under 64 KiB with no base64, multipart, or batch arrays
Submit an image-to-video task with Idempotency-Key and saved webhook endpoint_idcurl
curl --fail-with-body -X POST 'https://gikyapi.com/v1/tasks' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -H 'Idempotency-Key: vid-order-20261126-0042' \
  -d '{
    "model": "kling-4-0",
    "operation": "image-to-video",
    "callback": {
      "endpoint_id": "YOUR_ENDPOINT_ID"
    },
    "input": {
      "prompt": "Camera slowly pushes in across the ceramic studio table while steam rises from the cup.",
      "image_urls": ["https://assets.example.com/studio-start.png"],
      "last_image_urls": ["https://assets.example.com/studio-end.png"],
      "resolution": "1080p",
      "aspect_ratio": "16:9",
      "duration_seconds": 8
    }
  }'

Illustrative curl request matching kling-4-0 image-to-video fields and callback endpoint_id; verify current schema and endpoint_id before sending.

08

How can creative teams separate urgent and batch clips?

Imagine a creative operations team producing seasonal teaser clips across two lanes. Urgent social edits need transcoding and asset-library cataloging right away when a clip finishes, while secondary camera angles can wait for scheduled batch checks.

For urgent jobs, the team sets up a public HTTPS webhook endpoint in Dashboard, saves the signing secret in server environment variables, and sends callback.endpoint_id on POST /v1/tasks. Once task.succeeded passes signature and timestamp checks, a worker grabs the URLs in outputs and updates the catalog immediately.

For background jobs, the team leaves out callback and records the returned task id with a next_poll_at at least five seconds out. If an urgent callback runs late, a reconciliation worker queries GET /v1/tasks/{id} and GET /v1/tasks/{id}/events instead of submitting a fresh render.

  • Send urgent pipelines through verified webhooks with a polling safety net
  • Store task IDs and schedule checks for non-urgent or batch renders
  • Check GET /v1/tasks/{id}/events before treating a late callback as a failure
09

When is simple status checking better than live alerts?

Push webhooks can look strictly better than polling on paper because your server does not poll active jobs. Still, running a public webhook receiver adds overhead—and can slow teams down—when volume is light, no stable public HTTPS endpoint exists, or raw request bytes are hard to preserve before JSON parsing.

Polling every five seconds or longer inside a bounded window is easy to trace because every step is a read on GET /v1/tasks/{id} using your existing Bearer API key. It avoids opening another public endpoint, avoids clock-skew trouble on webhook timestamps, and keeps state updates in one pull loop.

Even webhook-first teams need polling for edge cases: recovering after up to eight webhook retries finish, inspecting tasks in needs_review, or paging GET /v1/tasks to rebuild local state.

  • Start with polling if you lack a public HTTPS endpoint or clean raw-body access
  • Keep poll intervals at five seconds or longer and bound each check window
  • Page GET /v1/tasks with limit (1 to 100) and next_cursor when sweeping cataloged jobs
Missed Webhook Reconciliation Sequence: Webhook Path compared with Task State Path
Editorial workflow diagram of reconciling delayed or failed webhook deliveries; not a benchmark or generated output.
10

How do you protect budget across retries and reruns?

Jobs on Giky API draw from your prepaid USD balance under per-key spending limits and expiries, reserving funds at submission and settling when a job succeeds. Explicit failures release or refund their reservation while uncertain states need reconciliation—and a client timeout alone does not trigger a refund—so preventing duplicate submissions matters.

Take a hypothetical rate of $0.20 per second for a 10-second render ($2.00 per run). If POST /v1/tasks times out and your client sends a new Idempotency-Key instead of replaying the exact request with the same key and body, two separate renders can run; deliberate creative reruns after viewing results are separate and cost extra.

Keep API keys on the server (never in browser bundles or mobile clients, and do not enable IP restrictions on task API keys), let active renders finish and save outputs before revoking a key, and remember deleting a webhook endpoint stops future callbacks while cancellation only applies before submission.

  • Reuse the exact Idempotency-Key and identical body on timeouts or HTTP 5xx
  • Count deliberate creative reruns separately from transport retries in spend estimates
  • Save outputs from succeeded jobs before revoking the owning API key
Operational Recovery Actions by Condition
ConditionPrimary actionStop or guard rule
POST /v1/tasks timeout or HTTP 5xxReplay exact body with same Idempotency-KeyDo not alter body or mint a new key
Webhook missing after retriesQuery GET /v1/tasks/{id} and /eventsDo not assume generation failed
Task status is needs_reviewRetain task id for manual or job reviewStop automatic resubmission
Cancel requested after submissionHandle HTTP 409 or inspect statusCancel only works before submission

Frequently Asked Questions

Should I combine webhooks and polling on Giky API?

Yes. Webhooks deliver prompt event updates when reachable, while polling GET /v1/tasks/{id} every five seconds or longer catches delayed or missed deliveries after up to eight retries and supports bounded check windows for longer renders.

Why does raw-body verification matter for webhook signatures?

X-Webhook-Signature is a hex HMAC-SHA256 over X-Webhook-Timestamp, a literal dot, and the exact raw request body using your endpoint secret. Parsing and re-serializing JSON before hashing can change formatting and fail verification, so hash raw bytes and reject timestamps outside five minutes.

What should my code do if a task status is needs_review?

Stop automatic retries and keep the task id so a reconciliation job or operator can inspect the task and event log. Retrying needs_review automatically risks duplicate spend or conflicting state handling.

Does polling GET /v1/tasks/{id} create a new generation or affect billing?

No. Reading GET /v1/tasks/{id} with your Bearer API key checks current task state and does not start another render. Keep poll intervals at five seconds or longer and use bounded windows on long jobs.

How do I retry safely when POST /v1/tasks times out or returns HTTP 5xx?

Replay the exact same request with the same Idempotency-Key and identical JSON body within the 64 KiB limit. Save the key and payload before sending, never alter the body while reusing a key, and read the task once id is returned.

Can I cancel a video generation once it is already running upstream?

No. POST /v1/tasks/{id}/cancel with JSON {} only works before submission and returns HTTP 409 once past that stage. Cancellation yields status failed with error_code cancelled_before_submit rather than halting an active run.

YOUR NEXT STEP

What Should You Do Next?

Set up a staging test with a registered HTTPS webhook endpoint, raw-body HMAC-SHA256 verification, a five-minute timestamp check, and a polling fallback worker on a video task. Log X-Webhook-Id deduplication alongside GET /v1/tasks/{id} and GET /v1/tasks/{id}/events responses, and replay a simulated HTTP 5xx creation failure using the exact same Idempotency-Key and JSON body to verify no duplicate task is created.

Sources & scope

This is an editorial comparison of Giky API’s published integration contracts and documented workflows. It is not a measured ranking of model quality, speed or reliability. Illustrations explain the workflow; they do not show matched model outputs.