> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://developers.meshapi.ai/llms.txt.
> For full documentation content, see https://developers.meshapi.ai/llms-full.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://developers.meshapi.ai/_mcp/server.

# Batches

> Run async bulk inference jobs with the Python SDK.

# Batches

Submit a list of requests inline, kick off a batch, poll until done. Batch jobs run at discounted pricing.

```python
from meshapi import (
    BatchRequestItem,
    CreateBatchParams,
)

# 1. Create the batch
batch = client.batches.create(
    CreateBatchParams(
        requests=[
            BatchRequestItem(
                custom_id="req-1",
                body={
                    "model": "openai/gpt-4o-mini",
                    "messages": [{"role": "user", "content": "Say hi."}],
                },
            ),
            BatchRequestItem(
                custom_id="req-2",
                body={
                    "model": "openai/gpt-4o-mini",
                    "messages": [{"role": "user", "content": "Say bye."}],
                },
            ),
        ],
        completion_window="24h",
    )
)

# 2. Poll later
status = client.batches.get(batch.id)
if status.status == "completed" and status.output_file_id:
    output_bytes = client.files.content(status.output_file_id)
    # output_bytes is JSONL
```