For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
DocsAPI ReferenceSDKs
DocsAPI ReferenceSDKs
      • Overview
      • Chat Completions
      • Prompt Templates
      • Files & Batches
      • Embeddings
      • Image Generation
      • Responses (Reasoning)
      • Compare (Multi-model)
      • Models
      • Error Handling
LogoLogo
On this page
  • Batches
Python SDK

Batches

||View as Markdown|
Was this page helpful?
Edit this page
Previous

Prompt Templates

Next

Embeddings

Built with

Batches

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

1from meshapi import (
2 BatchRequestItem,
3 CreateBatchParams,
4)
5
6# 1. Create the batch
7batch = client.batches.create(
8 CreateBatchParams(
9 requests=[
10 BatchRequestItem(
11 custom_id="req-1",
12 body={
13 "model": "openai/gpt-4o-mini",
14 "messages": [{"role": "user", "content": "Say hi."}],
15 },
16 ),
17 BatchRequestItem(
18 custom_id="req-2",
19 body={
20 "model": "openai/gpt-4o-mini",
21 "messages": [{"role": "user", "content": "Say bye."}],
22 },
23 ),
24 ],
25 completion_window="24h",
26 )
27)
28
29# 2. Poll later
30status = client.batches.get(batch.id)
31if status.status == "completed" and status.output_file_id:
32 output_bytes = client.files.content(status.output_file_id)
33 # output_bytes is JSONL