Skip to main content
For a collection of independent images, run ordinary chat-completion requests through a bounded worker pool. This guide batches work in your application; it does not use a server-side batch endpoint. If several independent questions share one image or video, consider Multilook for that item. If one question needs several media items together, use multiple assets in a single request.

Process a list of images

Install perceptron>=0.4.0, set PERCEPTRON_API_KEY, and create images.txt with one HTTP(S) image URL per line. For example:
Save this script as batch_questions.py. It submits at most four items at a time and writes one JSON record per item. The original line number identifies the input even when requests complete out of order.
Run it with:
The script does not retry failed requests automatically. A failure on one item becomes an error record while the other items continue. An answer with finish_reason: "length" is recorded as incomplete, not as a successful result.

Resume and scale deliberately

Keep the input file unchanged when using its line numbers to match saved results. For a changing dataset, assign each item a stable application ID instead. Persist completed records as you go, then select only failed or missing items for a later run. Protect the result file: answers and error messages can contain details from your inputs. Use the error guide to distinguish retryable failures from invalid inputs or exhausted credits. Apply backoff and a total deadline before resubmitting an item. If you adapt the worker to a tool workflow, do not replay completed tool actions when retrying a model request. Four workers bound concurrent requests, but do not enforce requests per minute. Pace submissions across all workers sharing your organization and reduce load when rate limited; see scaling. Compare elapsed time, completion rate, errors, and token usage on the same workload before increasing concurrency. For local or repeatedly used media, upload files once and use file references. File reuse reduces upload traffic, not the model’s media-token usage.