Overview
Batchwork is a unified batch API for AI providers — one call to run thousands of LLM requests at ~50% cost across OpenAI, Anthropic, Gemini, Groq, Mistral, Together AI, and xAI.
What is Batchwork?
A single TypeScript API for batch LLM inference that works the same way across providers. You author requests in the exact shape you already use with the Vercel AI SDK's generateText, pass the same models, and get back one normalized result type — correlated by customId.
import { batch } from "batchwork";
import { openai } from "@ai-sdk/openai";
const job = await batch({
model: openai.chat("gpt-5.5"),
requests: [
{ customId: "a", prompt: "Summarize this…" },
{ customId: "b", messages: [{ role: "user", content: "Translate this…" }] },
],
});
const results = await job.wait().then(() => job.collect());Why Batchwork?
Every major LLM provider offers a Batch API at roughly half the price — but each has a different, fiddly shape. OpenAI wants requests serialized to a JSONL file and uploaded via the Files API; Anthropic wants an inline JSON array; both return results out of order keyed by a custom_id, and you poll for completion. The AI SDK unifies synchronous generation but has no batch support, so today you drop out of it and hand-write provider plumbing.
Batchwork closes that gap:
- One API — the same
batch()call across every provider. The code that batches to OpenAI is the code that batches to Anthropic. - AI SDK native — pass
openai(...)/anthropic(...)models (or a"provider/model"string), and author each request likegenerateText. - JSONL handled — building, uploading, polling, and parsing are done for you. You never touch the wire format.
- Normalized results — one
BatchResultshape withstatus,text,usage, and the raw provider response, correlated bycustomId. - Lazy provider loading — the
@ai-sdk/*packages are optional peer dependencies, loaded only for the providers you use. - A server layer — an optional managed poller that fires one signed webhook when each batch finishes, so you never write polling loops in production.
Next steps
- Installation — install the SDK and the provider peer dependencies.
- Usage — submit a batch and read results end to end.
- Models — the model forms Batchwork accepts.
- Server — managed polling and unified webhooks.