A queue is a waiting line for jobs. Images take seconds to generate and videos take minutes, which is longer than most web requests are allowed to stay open. So a system doing this work accepts the job, answers straight away, and delivers the result later.
The pattern is ordinary engineering, and it is still the thing studio-built tools most often get wrong. We will follow a wedding invitation studio that makes a short video invite for each couple with veo-3.1-lite-generate-001, one of Google's Veo models, on Google's Agent Platform.
Store the ticket before anything else
A request arrives, a job is created and acknowledged, a worker picks it up, and the result is stored and announced. With Veo on the Agent Platform, you send the job with predictLongRunning, and it answers at once with an operation name instead of a video. That name is your ticket, so store it before you do anything else.
Then write the job into your own list as waiting, with the prompt, the settings and the time it was sent. If the studio's laptop goes to sleep, the job carries on at Google, and your list is how you find it again.
Ask for the result at a sensible pace
There are two ways to find out a job is done. Polling means asking again and again whether it has finished. A webhook means the provider tells you when it is done, which is neater but needs an address where your system is listening.
For the invites, ask about the operation every 10 seconds until it says done. At the time of writing, Google's Gemini API page gave 11 seconds as the fastest time and 6 minutes at peak, and a 4-second Lite clip took about 36 seconds in tests for this course. Asking every second wastes calls, and asking every few minutes keeps the couple waiting for nothing.
Give every job a maximum age
Something will hang. A system with no maximum age for its jobs collects zombies, jobs that never finish and never leave the list, until somebody notices the queue is a thousand long. Mark any invite job older than ten minutes as failed and stop asking about it.
Timeouts need the same care. A timeout is how long something may take before it is abandoned, and there are usually three of them, the platform's limit, the request's limit and the library's retry budget. If an inner one can run longer than the outer one, you get a failure your code never sees. Write the three numbers down side by side and make each inner one comfortably smaller.
Check for errors and save the file at once
When the operation says done, look for an error before you look for a video. If the error says "internal server issue", send the job again once. In tests for this course that error came back twice, and a plain retry worked both times.
Download the video into your own storage straight away, then mark the job done. Without a storage bucket named in the request, the Agent Platform returns the video only as bytes in its answer, so write those bytes to a file before your code does anything else.
Show the couple what is happening
A queued job with no visible state looks exactly like a broken one, and people start it again, which doubles your bill and your load. Show the person who asked which state the job is in: waiting, making, done or failed.
For the wedding studio, the couple's page might say "Making your invite. This can take a few minutes." When it changes to done, the video is already safe in the studio's storage and ready to play.
The next lesson covers caching, and how to avoid paying twice.