Skip to main content
Model ID
Calling method: sync

Gemini Batch Inference API Usage Guide

Overview

Gemini Batch Inference allows you to process large volumes of requests asynchronously at approximately 50% lower cost than online inference. Ideal for batch processing tasks like document analysis, image labeling, or bulk content generation.

Authentication

All API requests require authentication using an API key. Include your API key in the Authorization header:

Submit Batch Job

Base URL

Endpoint

Request Format

Request Parameters

Supported Models

JSONL Input Format

Each line must be a valid JSON object with a request field containing contents: Text-only requests:
Multimodal requests (with images):

Response (Immediate)

After submitting, you receive a request_id to track the job:

Check Job Status

Endpoint

Example

Response (In Progress)

Response (Completed)

Download and Parse Output

The output is a JSONL file where each line corresponds to one input request:
Note: An empty status field indicates success. Failed requests will have an error message in status.

List Your Batch Jobs

Endpoint

Example

Request Status Values

Batch Job States (Vertex AI)

Pricing

Limits

Tips for Best Results

  1. Batch Size: Ideal for 100+ requests. For fewer requests, consider online inference.
  2. File References: Use gs:// URIs for images/documents stored in Google Cloud Storage.
  3. Processing Time: Jobs typically complete within minutes to hours depending on volume.
  4. Cost Optimization: Use batch for non-time-sensitive workloads to save ~50%.
  5. Error Handling: Check batch_job_completion_stats for failed request counts.
  6. Partial Results: Even if some requests fail, successful ones are still billed and available.