Pipelines3 min read

Batch Rendering 1,000 Assets on the fal.ai Queue

A production pipeline pattern for running 1,000 GPT Image 2 jobs, handling failures, and keeping wall time under an hour.


If you are spinning up a campaign that needs 1,000 renders, you do not want to synchronously await each one. Here is the batch pattern we use for GPT Image 2 on fal.ai that keeps wall time under an hour and maintains a clean audit trail.

Concurrency

fal.ai lets you fire roughly 10 concurrent requests per account on gpt-image-2 endpoints. Above that you start seeing 429 responses. The sweet spot is 8 to 10 in flight at any time. Below 6, throughput is limited by wall time per render.

The worker pool pattern

Use a simple fixed pool of workers pulling from a shared queue. Each worker calls fal.subscribe, awaits the result, logs the request ID, writes the output URL to your store, and pulls the next job. Here is the shape in TypeScript.

example.tsTS
1import { fal } from "@fal-ai/client";
2
3const CONCURRENCY = 10;
4const jobs = [...]; // 1000 prompts
5
6const workers = Array.from({ length: CONCURRENCY }, async () => {
7 while (jobs.length > 0) {
8 const job = jobs.shift();
9 if (!job) return;
10 try {
11 const result = await fal.subscribe("fal-ai/gpt-image-2", {
12 input: { prompt: job.prompt, image_size: "1024x1024", quality: "medium", num_images: 1, output_format: "png" },
13 logs: false,
14 });
15 await persist(job.id, result.data.images[0].url);
16 } catch (err) {
17 console.error(`[fail] ${job.id}`, err);
18 }
19 }
20});
21await Promise.all(workers);

Cost discipline

Render everything at quality=low on the first pass, review the thumbnails, then rerun only the winners at quality=high. That pattern costs roughly a fifth of rendering everything at high from the start.

Failure handling

Store every request ID, even on failure. fal.ai keeps a trace for about 72 hours that you can replay. When a render looks off in review, you have the exact input the model saw.

A flowchart showing the batch rendering pipeline
A flowchart showing the batch rendering pipeline

Also reading