A simple Python wrapper for OpenAI Batch workflows.
Project description
batchkit
batchkit is a thin Python wrapper around the OpenAI Batch API.
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
Goals
- keep the official
openaiSDK under the hood - make the happy path one normal Python flow
- persist inspectable local manifests under
.batchkit/ - support both sync and async usage
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)
Development
This project is built test-first.
uv venv --python 3.11
uv pip install -e ".[dev]"
.venv/bin/python -m pytest
Release
Publishing is handled by GitHub Actions.
- create a version tag like
v0.1.0 - push the tag
- approve the
pypienvironment job - the
Publishworkflow uploadsbatchkit-aito PyPI
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.0.tar.gz.
File metadata
- Download URL: batchkit_ai-0.1.0.tar.gz
- Upload date:
- Size: 17.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e160853fc7e6b9006b7e34d1ab571580c7cc22689642850a7242ba92dee08f0e
|
|
| MD5 |
e2847611074ed46f3eeee16a6cbd9214
|
|
| BLAKE2b-256 |
30e87ff7256c83413086e7fd08474dd0866325b32d929fef92d030d6b87d436b
|
Provenance
The following attestation bundles were made for batchkit_ai-0.1.0.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.0.tar.gz -
Subject digest:
e160853fc7e6b9006b7e34d1ab571580c7cc22689642850a7242ba92dee08f0e - Sigstore transparency entry: 1059695168
- Sigstore integration time:
-
Permalink:
thesaadfarooq/batchkit@2ae7c5b40cf6f6e3598750ba2c3607be6a45bb65 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/thesaadfarooq
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@2ae7c5b40cf6f6e3598750ba2c3607be6a45bb65 -
Trigger Event:
push
-
Statement type:
File details
Details for the file batchkit_ai-0.1.0-py3-none-any.whl.
File metadata
- Download URL: batchkit_ai-0.1.0-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 |
aef8bc9ea1a1483e22c0f88d17b925cd38795ce668e8651f764e4b1b6e176d00
|
|
| MD5 |
fa6e8faa97bc8d6dc66135a81288f381
|
|
| BLAKE2b-256 |
0effb482fac412503c5f249acbde289c3be6d85b53e2b318aa4884e5baa8daea
|
Provenance
The following attestation bundles were made for batchkit_ai-0.1.0-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.0-py3-none-any.whl -
Subject digest:
aef8bc9ea1a1483e22c0f88d17b925cd38795ce668e8651f764e4b1b6e176d00 - Sigstore transparency entry: 1059695171
- Sigstore integration time:
-
Permalink:
thesaadfarooq/batchkit@2ae7c5b40cf6f6e3598750ba2c3607be6a45bb65 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/thesaadfarooq
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@2ae7c5b40cf6f6e3598750ba2c3607be6a45bb65 -
Trigger Event:
push
-
Statement type: