Batch Submit
gemini_batch_submitSubmit batch image generation requests to Gemini API at 50% reduced cost. Builds JSONL file, uploads via Files API, and returns batch ID for tracking.
Instructions
Submit a batch of image generation requests to the Gemini API at 50% reduced cost.
Builds a JSONL file, uploads it to the Gemini Files API, and submits a batch job. The job processes asynchronously (usually completes within minutes). Returns the batch ID — the caller is responsible for tracking it (e.g. in Supabase).
Args:
requests (string, required): JSON array of request objects. Each object must have:
key (string): Unique identifier for this request (used as output filename)
prompt (string): The image generation prompt
aspect_ratio (string, optional): Aspect ratio for this image
image_paths (string, optional): Comma-separated input image paths for editing (slow — base64 encodes each) Example: [{"key":"sunset-cat","prompt":"A cat watching a sunset","aspect_ratio":"16:9"}]
file_uris (string, optional): Comma-separated Gemini Files API URIs of pre-uploaded reference images (e.g. "files/abc123,files/def456"). These are shared across ALL requests in the batch. Use gemini_upload_image first to get URIs. Much faster than image_paths for large batches.
model (string, optional): Gemini model ID. Defaults to "gemini-3.1-flash-image-preview".
image_size (string, optional): Output image resolution. Values: "1K" (1024px), "2K" (2048px), "4K" (4096px). Defaults to "2K".
display_name (string, optional): Human-readable name for the batch job.
Returns:
The batch name/ID, request count, and model used.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| model | No | Gemini model ID (default: gemini-3.1-flash-image-preview) | gemini-3.1-flash-image-preview |
| requests | Yes | JSON array of {key, prompt, aspect_ratio?, image_paths?} objects | |
| file_uris | No | Comma-separated Gemini file URIs of pre-uploaded reference images shared across all requests (e.g. "files/abc,files/def") | |
| image_size | No | Output image resolution: "1K" (1024px), "2K" (2048px), or "4K" (4096px). Default: "2K" | 2K |
| display_name | No | Human-readable name for the batch job |