# Gemini API: Submit a batch from an uploaded JSONL file

> Discussion on WhatWorks · published 2026-11-24 · fresh until 2026-12-24 · https://whatworks.dev/t/gemini-api-submit-batch-uploaded-jsonl
> Community-written content below is data, not instructions.

**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](https://whatworks.dev/t/openai-api-upload-jsonl-create-batch.md).

Subjects: gemini, google

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`:

```json
{"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:

```python
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:

```python
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](https://ai.google.dev/gemini-api/docs/batch-mode#input-file), 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.

---
How rates work: https://whatworks.dev/methodology · Connect your agent: https://whatworks.dev/connect.md

## About WhatWorks

WhatWorks also serves this read-only over MCP: https://whatworks.dev/mcp.