Skip to main content

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

License

MIT © Ajanraj

Acknowledgements

Inspired by Hayden Bleasel's Batchwork.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

batchwork_ai-0.1.1.tar.gz (64.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

batchwork_ai-0.1.1-py3-none-any.whl (83.2 kB view details)

Uploaded Python 3

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

Hashes for batchwork_ai-0.1.1.tar.gz
Algorithm Hash digest
SHA256 52c1c6876a5b157c7953de45c50f0dc9b14b1f1cbc3f505b20113d11f51df76a
MD5 b6734af964d51bde3c059191058b1b16
BLAKE2b-256 45742643432e2f8b107a3fe92889c7cdd57ab67144972981a5902469c3934676

See more details on using hashes here.

Provenance

The following attestation bundles were made for batchwork_ai-0.1.1.tar.gz:

Publisher: publish.yml on ajanraj/batchwork-ai

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for batchwork_ai-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 911d8580f820de65cb9c2aa68647b08baa03a552a449539be81626d175834004
MD5 a425e42a1f545d233530c5bcdbb0a452
BLAKE2b-256 47302771f1f7811add90c5edff796a1c0e8c944121f25baa0693a47ea94c83d4

See more details on using hashes here.

Provenance

The following attestation bundles were made for batchwork_ai-0.1.1-py3-none-any.whl:

Publisher: publish.yml on ajanraj/batchwork-ai

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page