Skip to main content

llm-batch-accelerator

CI Python 3.11+ License: MIT Ruff

Half the price. None of the 24-hour tail.

llm-batch-accelerator (lba) is an open-source accelerator and reliability engine for LLM Batch APIs (OpenAI first, with Anthropic and Gemini adapters planned). It preserves the 50% batch discount while eliminating multi-hour straggler lock-in, broken partial-archive recovery, and duplicate billing across restarts.


Why It Exists

Native LLM Batch APIs cut token spend by 50%, but running large workloads in production exposes three recurring bottlenecks:

  1. Straggler Tail Lock-In: Large batches frequently complete 95%–99% of requests quickly, then stall on the remaining tail until hitting the 24-hour expiration window.
  2. Double-Billing on Retries & Restarts: Re-submitting an input file after an interruption, timeout, or pipeline upgrade replays requests that already completed or are still in flight.
  3. Dirty Partial Archives: Cancelled and expired batch outputs can arrive with unordered records, hidden 503 error lines, truncated payloads, or stale progress counters.

Core Capabilities

  • Adaptive 3-Tier Tail-Cutting & Bounded Hybrid Sync: Detect stalled batches across calibrated Ultra / Standard / High-Age tiers (off / shadow / active), cancel early to release completed results, and finish bounded tails through real-time APIs under an explicit SyncBudget guardrail (with automatic fallback to Batch on 429).
  • Zero Double-Billing & In-Flight Adoption: Deterministic SHA-256 hashing over the canonical wire payload and provider contract enables cross-run caching, adoption of still-running batches, and intent-journaled submissions (max_retries=0 on creation).
  • Crash-Safe Dirty Archive Reconciliation: Safely unpack and reconcile completed, cancelled, expired, and failed batch artifacts by custom_id before rescheduling only the verified unfinished delta.

See Your Tail in 30 Seconds (lba audit)

Zero code changes, strictly read-only (GET /v1/batches only):

OPENAI_API_KEY="sk-..." uvx llm-batch-accelerator audit --days 30 --limit 1000 --inspect-archives 5

Example output (illustrative synthetic dataset):

╭──────────────────────────────────────────────────────────────────────────────────────╮
│ OPENAI Batch Audit · Last 30 days (observed span: 72.4h) · 500 batches · 720,000 req │
╰──────────────────────────────────────────────────────────────────────────────────────╯

   Status Mix                      cancelled: 28, completed: 312, expired: 85, in_progress: 75
   Turnaround                      P50: 11.2h   P90: 24.0h   P99: 24.0h   (slow >6h completed: 142)
   Expired Tail                    85 expired (17.0%) · median completion: 99.5% · >=95% at expiry: 76 · locked wait: ~1088.0h
   In-Flight Radar                 75 active (24 >=95% complete, 19 match tail-cut tiers now) · cancelled >=95%: 26
   Small-Batch Sync                48 batches (<=25 reqs, 512 reqs) waited avg 9.4h — ideal for instant Sync
   Projection (balanced · sync 1%) Avoidable expired: 79/85 · Est. speedup: 1.32× – 1.74× · Hours saved: 948.0h – 1738.0h · Sync tail: 740 reqs (+0.10%, within cap)

                              Worst / Slowest Batches
  Batch ID              Status    Duration           Completed   Remaining   Endpoint
 ──────────────────────────────────────────────────────────────────────────────────────
  batch_demo_001        expired      24.0h   4982/5000 (99.6%)          18   /v1/responses
  batch_demo_002        expired      24.0h   4371/4375 (99.9%)           4   /v1/responses
  batch_demo_003        expired      24.0h   3585/3597 (99.7%)          12   /v1/responses

Installation

# Run directly without installing
uvx llm-batch-accelerator --help

# Or install into a project / environment
uv add llm-batch-accelerator
# or: pip install llm-batch-accelerator

Quickstart CLI

# 1. Read-only audit + exportable Markdown / single-file HTML report
lba audit --days 30 --inspect-archives 5 --format html --out audit-report.html

# 2. Run a standard OpenAI Batch JSONL workload (tail-cut active, 1% sync cap, inflight reuse)
lba run requests.jsonl -o results.jsonl --errors errors.jsonl --run-id batch-dec04

# 3. Run simplified body-only JSONL by passing --endpoint explicitly
lba run prompts.jsonl -o results.jsonl --endpoint /v1/chat/completions --model gpt-4o-mini

# 4. Inspect, resume, cancel+drain, or re-export locally
lba status
lba resume batch-dec04 -o results.jsonl
lba cancel batch-dec04 --drain
lba export batch-dec04 -o results.jsonl --output-format enriched

Python Async SDK

Managed Mode

import asyncio
from llm_batch_accelerator import BatchAccelerator, BatchRequest, SyncBudget, TailCutPolicy

async def main() -> None:
    requests = [
        BatchRequest(
            custom_id="doc-1",
            endpoint="/v1/chat/completions",
            body={"model": "gpt-4o-mini", "messages": [{"role": "user", "content": "Summarize."}]},
        )
    ]
    async with BatchAccelerator(
        provider="openai",
        store="sqlite:///.lba/state.db",
        tail_cut=TailCutPolicy.balanced(),
        sync_budget=SyncBudget.parse("1%"),
        reuse="inflight",
    ) as acc:
        report = await acc.run(requests, run_id="demo-run")
        print(report.summary)

asyncio.run(main())

Step / Pulse Mode (Airflow, Temporal, K8s CronJobs)

async with BatchAccelerator(store="sqlite:///.lba/state.db") as acc:
    run = await acc.enqueue(requests, run_id="daily-2026-12-04")
    tick = await acc.tick(run.run_id)
    page = acc.collect(run.run_id, after_cursor=None, limit=1000)

Documentation

License

MIT License — see LICENSE.

Metadata

Release files for llm-batch-accelerator 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for llm-batch-accelerator 0.1.0
File Size Uploaded Provenance Actions
llm_batch_accelerator-0.1.0.tar.gz 97.7 kB With provenance Details for llm_batch_accelerator-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for llm-batch-accelerator 0.1.0
File Interpreter ABI Platform Actions
llm_batch_accelerator-0.1.0-py3-none-any.whl Python 3 none any Details for llm_batch_accelerator-0.1.0-py3-none-any.whl

Total release size: 171.3 kB

Release files / llm_batch_accelerator-0.1.0.tar.gz

Download URL llm_batch_accelerator-0.1.0.tar.gz
Size 97.7 kB
Tags Source
SHA-256 checksum
How to use checksums
455cbded3e7bdb8ce1653114c5a20dc30aaa41fcc7b7d3d034920562338074fa
BLAKE2b-256 checksum
How to use checksums
6b6a2c770e2d52aa7601c3071dea425aecdbe8b0382e1f2b6bed3131cd4ab2c1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 4, 2026.

Transparency log

Release files / llm_batch_accelerator-0.1.0-py3-none-any.whl

Download URL llm_batch_accelerator-0.1.0-py3-none-any.whl
Size 73.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
71ead65c984e4745152d60a79ff708e39c5daa7b52246c85ff97bc67722a86c3
BLAKE2b-256 checksum
How to use checksums
4d37e9b12513371ee307003ac196f3692a671faba00165d01ce21f5b1dc0ea19
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 4, 2026.

Transparency log

Security for llm-batch-accelerator 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for llm_batch_accelerator-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 4, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page