OpenAI Batch Helper
Running the OpenAI Batch API can cut per-request costs by roughly 50%. But the process through the default OpenAI Python SDK is very cumbersome. It requires users to manage JSONL uploads, poll for status updates, download results in JSONL format again, and parse them. This quickly turns messy. The package openai_batch_helper helper keeps the batch flow tidy, typed, and production-friendly.
Install
pip install openai-batch-helper
Quickstart (add_task)
from openai_batch_helper import BatchHelper, status_progress_logger
helper = BatchHelper(endpoint="/v1/chat/completions", completion_window="24h")
job = helper.init_job()
job.add_task(
"t1",
body={
"model": "gpt-4o-mini",
"messages": [
{"role": "system", "content": "Be concise."},
{"role": "user", "content": "Explain idempotency in one sentence."},
],
},
)
job.add_task(
"t2",
body={
"model": "gpt-4o-mini",
"messages": [
{"role": "system", "content": "Be concise."},
{"role": "user", "content": "List 3 benefits of unit tests."},
],
},
)
(job
.submit_file()
.submit_batch_job(metadata={"project": "demo"})
.wait_for_completion(poll_seconds=5.0, on_update=status_progress_logger()))
print(job.download_result())
print(job.map_by_custom_id())
Learn more
Check the docs for CLI usage, additional helpers, and troubleshooting: https://openai-batch-helper.readthedocs.io .
Release files for openai-batch-helper 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| openai_batch_helper-0.1.1.tar.gz | 13.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| openai_batch_helper-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 25.6 kB
Release files / openai_batch_helper-0.1.1.tar.gz
| Download URL | openai_batch_helper-0.1.1.tar.gz |
|---|---|
| Size | 13.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6b98d974fdf713753c680c576b240fde2062e893b28cb01cdc75e65b543a125d
|
|
BLAKE2b-256 checksum How to use checksums |
11aa6f26958449dafba6e1333820ddaf4f67f688bce89856d788d42efacfee41
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / openai_batch_helper-0.1.1-py3-none-any.whl
| Download URL | openai_batch_helper-0.1.1-py3-none-any.whl |
|---|---|
| Size | 12.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
80ff8aaaa75128186f67d27817364da279112a60f13769db3b62268f6475d8fe
|
|
BLAKE2b-256 checksum How to use checksums |
1d3c804187f216a8d450a15e9385a48cd0d7043786accb7cf8d820731d2ec902
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|