For the complete documentation index, see llms.txt. This page is also available as Markdown.

Image Generation

Run diffusion models for batch image generation and editing with Parasail.

Parasail supports batch image generation and editing for diffusion models such as OmniGen and Qwen-Image-Edit. Prompts are submitted as JSONL files—one prompt per line—through either the OpenAI-compatible Batch API or the Parasail Batch helper library, which wraps the OpenAI client.

Input and output images are encoded as raw Base64 (not Data URLs like data:image/png;base64,..., just the raw Base64 image data). Batch results are returned as JSONL with Base64-encoded output images. Batch submission files have a 1000 MB limit; see Batch file format for the full limits.

Minimal example

The quickest way to generate an image is the batch helper library, which builds the JSONL request file and submits it for you:

from openai_batch import Batch

with Batch() as batch:
    batch.add_to_batch(
        model="Shitao/OmniGen-v1",
        prompt="A serene mountain lake at sunrise, photorealistic",
        size="1024x1024",
        response_format="b64_json",
    )
    result, output_path, error_path = batch.submit_wait_download()

For editing, pass one or more Base64-encoded input images and reference them in the prompt:

import base64

with open("person.jpg", "rb") as f:
    img = base64.b64encode(f.read()).decode("utf-8")

batch.add_to_batch(
    model="Shitao/OmniGen-v1",
    prompt="A man in a black shirt is reading a book. The man is the right man in <img><|image_1|></img>.",
    size="1024x1024",
    image=[img],
    response_format="b64_json",
)

Supported parameters

Parameter
Description

model

For example Shitao/OmniGen-v1 or Qwen/Qwen-Image-Edit

prompt

The prompt to guide generation. Reference input images inline as <img><|image_1|></img>

size

Formatted as WxH in pixels, for example 1024x1024

image

A list of Base64-encoded JPGs or PNGs (used for editing)

response_format

Currently only b64_json is supported

Advanced: process a directory of images

The script below uses the batch helper library to process every image in an input directory and save the generated results to an output directory. The batch library has many additional features for building processing pipelines—see the Batch quickstart, which also shows how to monitor batch jobs in Parasail's UI.

To run it:

Next steps

Last updated