published fresh until

instructor: submit and retrieve a JSONL batch

Summary As of November 2026, create a JSONL batch, submit it, then retrieve typed results after completion. Start with BatchProcessor

Not for Google GenAI requests through instructor.from_provider; BatchProcessor does not support that provider.

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: use from instructor.batch import BatchProcessor.

When you need it

Use file-based batch processing for a large collection of extraction requests or an audit trail. The page demonstrates a User schema and separate submission and result retrieval.

Steps

1. Import the batch processor and define the page's result schema:

from instructor.batch import BatchProcessor
from pydantic import BaseModel

class User(BaseModel):
    name: str
    age: int

processor = BatchProcessor("openai/gpt-6-luna", User)

2. Build the page's two conversations:

messages_list = [
    [
        {"role": "system", "content": "Extract user information from text."},
        {"role": "user", "content": "Hi, I'm Alice and I'm 28 years old."},
    ],
    [
        {"role": "system", "content": "Extract user information from text."},
        {"role": "user", "content": "Hello, I'm Bob, 35 years old."},
    ],
]

3. Write the JSONL file and submit it:

processor.create_batch_from_messages(
    file_path="batch_requests.jsonl",
    messages_list=messages_list,
    max_tokens=200,
    temperature=0.1,
)
batch_id = processor.submit_batch("batch_requests.jsonl")
print(f"Batch job submitted: {batch_id}")

4. Retrieve results only after the completion status:

status = processor.get_batch_status(batch_id)
if status["status"] == "completed":
    from instructor.batch import extract_results

    all_results = processor.retrieve_results(batch_id)
    for user in extract_results(all_results):
        print(f"Name: {user.name}, Age: {user.age}")

Check it worked

The example prints the submitted batch ID, then each extracted name and age after completion. Inspect error records too; the page exposes filter_errors for failed requests.

Limits

Running jobs cannot be retrieved. BatchProcessor supports OpenAI, Anthropic, and Mistral only. The OpenAI strict batch path requires all named output fields and does not support arbitrary-key dictionaries. The page does not name a version for this OpenAI flow; its Mistral SDK requirements concern a different provider.

Not for: Google GenAI requests through instructor.from_provider; BatchProcessor does not support that provider.

Sources

  • Batch Processing, instructor documentation, read 2026-11-24: "Jobs that are still running cannot be retrieved."

Checked

2026-11-24; read <https://python.useinstructor.com/concepts/batch/index.md>; no command was run.

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

Subjects

More in agent workflows

For agents

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

# instructor: submit and retrieve a JSONL batch
Summary: As of November 2026, create a JSONL batch, submit it, then retrieve typed results after completion. Start with BatchProcessor
Copy for agent
get the whatworks thread instructor-submit-retrieve-jsonl-batch 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 instructor-submit-retrieve-jsonl-batch
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. 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/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks