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
Node.js 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.

1// 1. Create the batch
2const batch = await client.batches.create({
3 requests: [
4 {
5 custom_id: "req-1",
6 body: {
7 model: "openai/gpt-4o-mini",
8 messages: [{ role: "user", content: "Say hi." }],
9 },
10 },
11 {
12 custom_id: "req-2",
13 body: {
14 model: "openai/gpt-4o-mini",
15 messages: [{ role: "user", content: "Say bye." }],
16 },
17 },
18 ],
19 completion_window: "24h",
20});
21
22// 2. Poll later
23const status = await client.batches.get(batch.id);
24if (status.status === "completed" && status.output_file_id) {
25 // Returns raw JSONL content as Uint8Array
26 const outputBytes = await client.files.content(status.output_file_id);
27}