Unified async batch API for AI providers
Project description
Batchwork
Unified async batch API for OpenAI, Anthropic, Google Gemini, Groq, Mistral, Together AI, and xAI. Access provider-native batch pricing—often up to 50% lower than standard synchronous requests—through one typed interface while Batchwork handles provider-specific serialization, submission, polling, and result normalization. Pricing and eligibility remain provider- and model-specific. Built for Python by Ajanraj.
- One typed API for provider-native batch jobs
- Text, embedding, and image workloads
- Normalized jobs, results, usage, and errors
- Messages, tools, structured content, and remote media
- Polling, persistent stores, and signed webhooks
- 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.
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.
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 |
|---|---|---|---|
| OpenAI | Yes | Yes | Yes |
| Anthropic | Yes | No | No |
| Google Gemini | Yes | Yes | Yes |
| Groq | Yes | No | No |
| Mistral | Yes | Yes | No |
| Together AI | Yes | No | No |
| xAI | Yes | 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 images
- Provider overview
- Polling and webhooks
- Stores
- Security
- Examples
- Public API
- FAQ
License
Acknowledgements
Inspired by Hayden Bleasel's Batchwork.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file batchwork_ai-0.1.1.tar.gz.
File metadata
- Download URL: batchwork_ai-0.1.1.tar.gz
- Upload date:
- Size: 64.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
52c1c6876a5b157c7953de45c50f0dc9b14b1f1cbc3f505b20113d11f51df76a
|
|
| MD5 |
b6734af964d51bde3c059191058b1b16
|
|
| BLAKE2b-256 |
45742643432e2f8b107a3fe92889c7cdd57ab67144972981a5902469c3934676
|
Provenance
The following attestation bundles were made for batchwork_ai-0.1.1.tar.gz:
Publisher:
publish.yml on ajanraj/batchwork-ai
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
batchwork_ai-0.1.1.tar.gz -
Subject digest:
52c1c6876a5b157c7953de45c50f0dc9b14b1f1cbc3f505b20113d11f51df76a - Sigstore transparency entry: 2194329308
- Sigstore integration time:
-
Permalink:
ajanraj/batchwork-ai@7a7569920d2529a45d5474b33417d2c0d125d095 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/ajanraj
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@7a7569920d2529a45d5474b33417d2c0d125d095 -
Trigger Event:
push
-
Statement type:
File details
Details for the file batchwork_ai-0.1.1-py3-none-any.whl.
File metadata
- Download URL: batchwork_ai-0.1.1-py3-none-any.whl
- Upload date:
- Size: 83.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
911d8580f820de65cb9c2aa68647b08baa03a552a449539be81626d175834004
|
|
| MD5 |
a425e42a1f545d233530c5bcdbb0a452
|
|
| BLAKE2b-256 |
47302771f1f7811add90c5edff796a1c0e8c944121f25baa0693a47ea94c83d4
|
Provenance
The following attestation bundles were made for batchwork_ai-0.1.1-py3-none-any.whl:
Publisher:
publish.yml on ajanraj/batchwork-ai
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
batchwork_ai-0.1.1-py3-none-any.whl -
Subject digest:
911d8580f820de65cb9c2aa68647b08baa03a552a449539be81626d175834004 - Sigstore transparency entry: 2194329313
- Sigstore integration time:
-
Permalink:
ajanraj/batchwork-ai@7a7569920d2529a45d5474b33417d2c0d125d095 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/ajanraj
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@7a7569920d2529a45d5474b33417d2c0d125d095 -
Trigger Event:
push
-
Statement type: