generate never blocks waiting for the result.
The pattern
Why async?
Before this pattern,
generate blocked the HTTP connection waiting for the job to finish. For long videos (Veo 3.1 with 8s duration → ~2 minutes), connections would drop at Cloudflare’s 100s edge timeout or the MCP client’s own timeout, and the response would be lost even though the job completed.generate + check_generation, no individual HTTP request lasts more than a few hundred milliseconds — timeouts become irrelevant.
What the server returns
Everygenerate response includes hints to drive the polling loop:
eta_seconds— rough estimate; useful to set user expectations.poll_after_seconds— how long your AI should wait before the nextcheck_generation. Clamped to 3–10 seconds.
check_generation returns the same poll_after_seconds while done: false, and drops it when done: true.
How AI clients implement polling
Claude Code, Cursor, and similar clients already know this pattern. When they seepoll_after_seconds in a tool response, they sleep and re-call. No client-side code required.
If you’re writing a custom MCP client, the pseudocode is:
Status values
| Status | Meaning | Terminal? |
|---|---|---|
pending | Queued, not started yet | no |
processing | Running | no |
success | Completed, output is the URL | yes |
error | Failed, error has the message | yes |
done: false. Stop when done: true.
Credits
Credits are charged upfront ingenerate, before the job is queued. If the job later fails, credits are automatically refunded — no action needed.
This means:
generatecan returninsufficient_creditsimmediately if you’re out.- If
check_generationeventually returnsstatus: "error", your credits are already back.
Webhooks vs polling
If you’re building a backend that uses the REST API, webhooks are better than polling. But MCP clients are interactive: your AI is waiting in the conversation, polling is fine, and there’s no webhook endpoint for a laptop. For production backends: use the REST API with webhooks. For chat / editor workflows: use MCP with polling.Next steps
Tool reference
Exact shapes for every tool response.
Examples
Example prompts and conversations.