A simple Python wrapper for OpenAI Batch workflows.
Project description
batchkit
batchkit is a thin Python wrapper around the OpenAI Batch API.
It turns the low-level Batch workflow into a simpler Python flow:
- map source items into batch requests
- submit through the official
openaiSDK - wait for completion with status updates
- fetch parsed results
- retry failed rows without rebuilding the whole job by hand
Install from PyPI:
pip install batchkit-ai
Import as:
import batchkit
It is designed to remove the repetitive parts of batch usage:
- building JSONL request files
- uploading files and creating batches
- polling batch status
- downloading output and error artifacts
- reconciling results back to the original inputs
- retrying failed rows
Example
from openai import OpenAI
from batchkit import BatchClient
sdk = OpenAI()
client = BatchClient(sdk)
job = client.map(
name="movie-classification",
items=movies,
model="gpt-4.1-mini",
build_request=lambda movie: {
"input": movie["overview"],
},
)
results = job.wait(progress=True)
for row in results.rows:
if row.ok:
print(row.custom_id, row.response)
else:
print(row.custom_id, row.error)
What It Handles
- request JSONL generation
- batch file upload and creation
- polling and terminal-state handling
- local manifests under
.batchkit/ - output and error artifact download
- result reconciliation by
custom_id - retry job creation for retryable rows
Scope
Current scope:
- OpenAI only
responsesendpoint first- sync and async clients
Contributor setup and release workflow live in CONTRIBUTING.md.
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 batchkit_ai-0.1.1.tar.gz.
File metadata
- Download URL: batchkit_ai-0.1.1.tar.gz
- Upload date:
- Size: 20.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f35b370f21473bac36e5b6f649e63ce3d7090a06887e0b9a43dad1f6443b3eca
|
|
| MD5 |
1bd4777c2aa1d16dff0eb664981d2894
|
|
| BLAKE2b-256 |
12e821f40c16cd147b7ac75e46302237d62b83d2e647b63ba4f9bb311d680406
|
Provenance
The following attestation bundles were made for batchkit_ai-0.1.1.tar.gz:
Publisher:
publish.yml on thesaadfarooq/batchkit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
batchkit_ai-0.1.1.tar.gz -
Subject digest:
f35b370f21473bac36e5b6f649e63ce3d7090a06887e0b9a43dad1f6443b3eca - Sigstore transparency entry: 1059750769
- Sigstore integration time:
-
Permalink:
thesaadfarooq/batchkit@252c8895bbc265cb1b9e7cfd7ea18a515b6d010f -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/thesaadfarooq
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@252c8895bbc265cb1b9e7cfd7ea18a515b6d010f -
Trigger Event:
push
-
Statement type:
File details
Details for the file batchkit_ai-0.1.1-py3-none-any.whl.
File metadata
- Download URL: batchkit_ai-0.1.1-py3-none-any.whl
- Upload date:
- Size: 20.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4a875462d5a863f09d538d9395951f34f28b19b17f6de7deae43edde8ab60a89
|
|
| MD5 |
8c385fe86554a15e7110a57eb69a7e39
|
|
| BLAKE2b-256 |
ab93171eb451241a367fe0e8ccd16253b8d33cd0904596499648c66b10c5c9d1
|
Provenance
The following attestation bundles were made for batchkit_ai-0.1.1-py3-none-any.whl:
Publisher:
publish.yml on thesaadfarooq/batchkit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
batchkit_ai-0.1.1-py3-none-any.whl -
Subject digest:
4a875462d5a863f09d538d9395951f34f28b19b17f6de7deae43edde8ab60a89 - Sigstore transparency entry: 1059750770
- Sigstore integration time:
-
Permalink:
thesaadfarooq/batchkit@252c8895bbc265cb1b9e7cfd7ea18a515b6d010f -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/thesaadfarooq
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@252c8895bbc265cb1b9e7cfd7ea18a515b6d010f -
Trigger Event:
push
-
Statement type: