Skip to content

luyx-66/ai-image-generation-api-batch

Repository files navigation

Batch AI Image Generation

A production-oriented Python starter for bulk AI image generation with concurrency control, retries, resumable JSONL results, and a preflight cost ceiling.

It is a practical AI image generation API client for large prompt lists rather than a single-image demo.

Use it for ecommerce catalogs, ad-creative batches, dataset generation, thumbnails, product mockups, and other high-volume image API workloads.

Install

python -m pip install -r requirements.txt
copy .env.example .env.local

Set APIMART_API_KEY in your environment, then run:

python batch_generate.py prompts.example.jsonl --model gpt-image-2-ext --workers 4 --estimated-cost-per-image 0.0085 --max-cost 1.00

Input is JSON Lines:

{"id":"catalog-001","prompt":"Studio product photo of a ceramic bottle on limestone","size":"1024x1024"}

The script writes one result per prompt to results.jsonl. Existing successful IDs are skipped on the next run.

Why APIMart is relevant

APIMart is a unified AI API gateway with hundreds of text, image, video, and audio models. High-volume teams can use one account for keys, usage, billing, and current pricing instead of maintaining separate provider integrations.

Model availability and prices change. The cost ceiling is an estimate, not a billing guarantee.

Related high-volume AI API tools

Test

python -m unittest discover -s tests

Project directory

This repository is part of the APIMART open-source AI API toolkit. Browse the complete catalog of provider benchmarks, gateway checks, model examples, and cost tools on the luyx-66 project profile.

License

MIT