Batchwork
Unified async batch API for OpenAI, Azure OpenAI, Anthropic, Google Gemini, Groq, Mistral, Together AI, and xAI. Providers price eligible batch requests up to 50% below standard synchronous calls, and Batchwork gives you that pricing through one typed Python interface and one CLI. It handles provider-specific serialization, submission, polling, and result parsing so you do not have to. Pricing and eligibility remain provider- and model-specific.
- One typed API for provider-native batch jobs
- Text, embedding, image, image-edit, moderation, transcription, translation, and video workloads
- Normalized jobs, results, usage, and errors
- Messages, tools, structured content, and remote media
- Polling, persistent stores, and signed webhooks
- A
batchworkCLI and Agent Skill for terminals, scripts, and coding agents - No provider SDK or JavaScript runtime dependencies
📖 Full documentation: batchwork.ajanraj.com
Installation
Batchwork requires Python 3.11 or newer.
With uv:
uv add batchwork-ai
With pip:
pip install batchwork-ai
Then configure a provider credential:
export OPENAI_API_KEY="..."
See Configuration for every provider credential, endpoint override, model format, and batch limit.
Command-line tool
The same package ships a batchwork command, so you can submit and manage batches without writing Python. Install it with uv tool:
uv tool install batchwork-ai
batchwork --version
Human quick start:
batchwork submit text prompts.txt --model openai/gpt-5
batchwork list
batchwork status BW_RECORD_ID
batchwork results BW_RECORD_ID
Agent and automation quick start:
batchwork --jsonl --quiet run text requests.jsonl --model openai/gpt-5
Machine output uses schema version 1. Global controls such as --jsonl, --profile, and --quiet precede the command. Preserve the first emitted job identity, capture stdout/stderr/exit status separately, and never retry an acceptance-ambiguous submission automatically. Image files are written only when --output-dir is explicit.
If you use a coding agent, the batchwork-ai Agent Skill teaches it the same contract, including when to ask before spending money and how to resume interrupted jobs:
npx skills add ajanraj/batchwork-ai@batchwork-ai
See the CLI guide, configuration and registry reference, machine schema, and exit catalog.
Quickstart
import asyncio
from batchwork import BatchRequest, Batchwork
async def main() -> None:
async with Batchwork() as client:
job = await client.batch(
model="openai/gpt-5.6-sol",
requests=[BatchRequest(custom_id="hello", prompt="Say hello")],
)
await job.wait(timeout=3600)
for result in await job.collect():
print(result.custom_id, result.text)
asyncio.run(main())
Submitting returns a BatchJob immediately. Provider processing is asynchronous and may take minutes or, depending on the provider and workload, up to 24 hours.
Beyond text, the same client covers seven more modalities — for example hosted-audio transcription:
from batchwork import BatchTranscriptionRequest
job = await client.batch_transcriptions(
model="groq/whisper-large-v3",
requests=[
BatchTranscriptionRequest(
custom_id="call-1",
audio_url="https://example.com/call-1.mp3",
)
],
)
Models use provider/model form. Results are correlated with requests through custom_id; provider output order is not guaranteed.
Providers
Output workloads supported by Batchwork:
| Provider | Text | Embeddings | Image generation | Image edits | Moderation | Transcription | Translation | Video |
|---|---|---|---|---|---|---|---|---|
| OpenAI | Yes | Yes | Yes | Yes | Yes | No | No | No |
| Azure OpenAI | Yes | No | No | No | No | No | No | No |
| Anthropic | Yes | No | No | No | No | No | No | No |
| Google Gemini | Yes | Yes | Yes | No | No | No | No | No |
| Groq | Yes | No | No | No | No | Yes | Yes | No |
| Mistral | Yes | Yes | No | No | Yes | Yes | No | No |
| Together AI | Yes | No | No | No | No | Yes | Yes | No |
| xAI | Yes | No | Yes | Yes | No | No | No | Yes |
Image, PDF, text-file, and audio inputs for text requests vary separately from output modalities. Provider APIs may also impose model-specific limits. See the provider overview for input support, submission transport, credentials, and restrictions.
Optional Redis store
Install the Upstash Redis integration for persistent polling state:
uv add "batchwork-ai[redis]"
# or
pip install "batchwork-ai[redis]"
The base package does not import or require upstash-redis.
Documentation
- Installation
- Configuration
- Jobs
- Results
- Text, embeddings, and other modalities
- Provider overview
- Polling and webhooks
- Stores
- Security
- Examples
- Public API
- FAQ
Built with Codex and GPT-5.6
Batchwork was built entirely in the OpenAI Codex CLI with GPT-5.6 during OpenAI Build Week (July 2026) — the Python library, the batchwork CLI with its machine output contract and local job registry, the Agent Skill, the test suite, and the documentation site. Codex planned the design through a decision interview, implemented the seven provider adapters across three modalities, hardened security through repeated review loops, verified everything against live provider APIs, and drove the PyPI and documentation releases. The full collaboration story, plus a self-contained demo project for judges, lives in hackathon/.
License
Acknowledgements
Inspired by Hayden Bleasel's Batchwork.
Metadata
Release files for batchwork-ai 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| batchwork_ai-0.3.0.tar.gz | 146.3 kB | With provenance | Details for batchwork_ai-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| batchwork_ai-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for batchwork_ai-0.3.0-py3-none-any.whl |
Total release size: 321.0 kB
Release files / batchwork_ai-0.3.0.tar.gz
| Download URL | batchwork_ai-0.3.0.tar.gz |
|---|---|
| Size | 146.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
16bf0896dd7600756e5b1fb65fbf1cfb656ce9c3f885d372d7268d859aaffedd
|
|
BLAKE2b-256 checksum How to use checksums |
e97d6a3aad9c7a7925c25279eae054694862a6a98149870665b01d5e51cd3888
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 20, 2026.
Transparency logRelease files / batchwork_ai-0.3.0-py3-none-any.whl
| Download URL | batchwork_ai-0.3.0-py3-none-any.whl |
|---|---|
| Size | 174.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1cf0882296f20a26d4037a2531d879fef79b3597709b874cef30be27126ea37b
|
|
BLAKE2b-256 checksum How to use checksums |
cbbb69e07ac86d2ea8628a685909e43cd327ad47bb05017a50810eca5f3761a5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 20, 2026.
Transparency logSecurity for batchwork-ai 0.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for batchwork_ai-0.3.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 20, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.