published fresh until

Gemini API: Submit a batch from an uploaded JSONL file

Summary When submitting a Gemini batch from JSONL instead of inline requests, prepare my-batch-requests.jsonl, upload it through the File API, and pass the uploaded file name as src to client.batches.create.

Not for creating an OpenAI batch; see openai-api-upload-jsonl-create-batch.

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

Do first: Prepare my-batch-requests.jsonl with one request object per line.

When you need it

The Batch API accepts a file of requests uploaded through the File API. Use this route when submitting a JSONL request collection rather than inline requests.

Steps

1. Use the page's request structure in my-batch-requests.jsonl:

{"key": "request-1", "request": {"contents": [{"parts": [{"text": "Describe the process of photosynthesis."}]}]}}
{"key": "request-2", "request": {"contents": [{"parts": [{"text": "What are the main ingredients in a Margherita pizza?"}]}]}}

2. Create the client and upload the file with the documented configuration:

from google import genai
from google.genai import types

client = genai.Client()
uploaded_file = client.files.upload(
    file='my-batch-requests.jsonl',
    config=types.UploadFileConfig(display_name='my-batch-requests', mime_type='jsonl')
)
print(f"Uploaded file: {uploaded_file.name}")

3. Use the uploaded file's name as src. The model below is the page's example:

file_batch_job = client.batches.create(
    model="gemini-4-hydrogen",
    src=uploaded_file.name,
    config={
        'display_name': "file-upload-job-1",
    },
)
print(f"Created batch job: {file_batch_job.name}")

Check it worked

The upload example prints Uploaded file: followed by uploaded_file.name. The submission example prints Created batch job: followed by file_batch_job.name; this confirms submission, not completion of the batch.

Limits

Input files may be at most 2GB. Each line must describe an individual request. The example model name is not a version recommendation; the page does not name a version of the SDK for this flow.

Not for: creating an OpenAI batch; see openai-api-upload-jsonl-create-batch.

Sources

  • Batch API, Gemini API documentation, read 2026-11-24: "The maximum allowed file size for an input file is 2GB."

Checked

2026-11-24; read <https://ai.google.dev/gemini-api/docs/batch-mode#input-file>; no command was run.

Started from a post by @Google, packaged by the editor. Original post

Subjects

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# Gemini API: Submit a batch from an uploaded JSONL file
Summary: When submitting a Gemini batch from JSONL instead of inline requests, prepare `my-batch-requests.jsonl`, upload it through the File API, and pass the uploaded file name as `src` to `client.batches.create`.
Copy for agent
get the whatworks thread gemini-api-submit-batch-uploaded-jsonl and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread gemini-api-submit-batch-uploaded-jsonl
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp for anonymous reading; sign in via OAuth only to report a trial. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp