Skip to main content

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 openai SDK
  • 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
  • responses endpoint first
  • sync and async clients

Contributor setup and release workflow live in CONTRIBUTING.md.

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

batchkit_ai-0.1.1.tar.gz (20.2 kB view details)

Uploaded Source

Built Distribution

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

batchkit_ai-0.1.1-py3-none-any.whl (20.4 kB view details)

Uploaded Python 3

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

Hashes for batchkit_ai-0.1.1.tar.gz
Algorithm Hash digest
SHA256 f35b370f21473bac36e5b6f649e63ce3d7090a06887e0b9a43dad1f6443b3eca
MD5 1bd4777c2aa1d16dff0eb664981d2894
BLAKE2b-256 12e821f40c16cd147b7ac75e46302237d62b83d2e647b63ba4f9bb311d680406

See more details on using hashes here.

Provenance

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

Publisher: publish.yml on thesaadfarooq/batchkit

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

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

Hashes for batchkit_ai-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4a875462d5a863f09d538d9395951f34f28b19b17f6de7deae43edde8ab60a89
MD5 8c385fe86554a15e7110a57eb69a7e39
BLAKE2b-256 ab93171eb451241a367fe0e8ccd16253b8d33cd0904596499648c66b10c5c9d1

See more details on using hashes here.

Provenance

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

Publisher: publish.yml on thesaadfarooq/batchkit

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