Skip to main content

offpeak

Deadline-priced inference. Same model, same tokens, a later deadline — for half price.

CI PyPI License

OpenAI, Anthropic, and Google all sell batch inference at 50% off list price. Almost nobody uses it, because no API lets work say it can wait: every token runs "now" by default, and the batch workflow — build a file, upload, poll, download, match results back up — is enough friction that urgency gets bought by accident.

offpeak gives your code one new argument.

import offpeak

jobs = [offpeak.job("claude-haiku-4-5", f"Summarize:\n\n{doc}") for doc in docs]

results = offpeak.run(jobs, deadline="06:00")   # done by 6am, at batch prices

print(offpeak.receipt(results))
OFFPEAK SETTLEMENT ────────────────────────────
jobs      1,000 (1,000 ok, 2 sync fallback)
sla       1,000/1,000 met
venues    anthropic:batch 1,000
tokens    12,410,332 in · 3,104,551 out
list      $27.93
paid      $14.02
captured  $13.91 (49.8%)
prices    snapshot 2026-08-21 — override via offpeak.prices
───────────────────────────────────────────────

Documentation · Quickstart · Spec · Roadmap

What it does

  • Know the price before you spend it. quote(jobs, deadline=...) prices a run against the published sheets with no API calls and no key — list versus batch, per venue, plus what the wait is worth.
  • One argument, not a workflow. run(jobs, deadline=...) handles batching, submission, polling, collection, and result matching across providers.
  • Deadlines are guarded, not hoped for. If a batch hasn't landed by the time the remaining window shrinks to a risk buffer, offpeak cancels and re-runs the stragglers synchronously at list price. You state the deadline; it gets met.
  • Every run settles a receipt. List cost, paid cost, captured spread — arithmetic against public price sheets, not estimates.
  • Your keys, your perimeter. offpeak talks directly to the providers with your own API keys. There is no proxy and no third party in the data path.
  • Zero-dependency core. Provider SDKs load only via extras.

Install

pip install "offpeak[all]"        # OpenAI + Anthropic venues
pip install "offpeak[anthropic]"  # or one provider
pip install "offpeak[openai]"

Venues use the standard environment variables (OPENAI_API_KEY, ANTHROPIC_API_KEY), or pass a configured client: OpenAIBatch(client=my_client).

Five more venues are in the tree and opt-in — each wants its own key and its own extra, and is passed to run() explicitly rather than routed to by default:

Venue Models Extra Key Lane
groq:batch openai/gpt-oss-*, groq/* groq GROQ_API_KEY batch, 24h–7d window
mistral:batch mistral-*, codestral, … mistral MISTRAL_API_KEY batch, window in hours
gemini:batch gemini-* gemini GEMINI_API_KEY batch, 24h
qwen:batch qwen* (Model Studio spelling) qwen DASHSCOPE_API_KEY batch, 24h–336h window, per-region
deepseek:clock deepseek-* deepseek DEEPSEEK_API_KEY clock — no batch API; half price off-peak, held until the boundary
from offpeak.venues import DeepSeekClock, QwenBatch

results = offpeak.run(jobs, deadline="06:00", venues=[DeepSeekClock(), QwenBatch(region="intl")])

DeepSeek is the first venue that is not a batch tier: peak is 01:00–04:00 and 06:00–10:00 UTC on weekdays, everything else is off-peak at half the peak rate, and the driver holds a job until the clock is cheap rather than uploading it anywhere. Neither DeepSeek nor Qwen has a live receipt yet.

The free quote

What is the wait worth? Ask before you spend anything — quote() makes no API calls and needs no key.

python -m offpeak quote --model gpt-5.6-luna --input-tokens 800 --output-tokens 200 --jobs 5000
OFFPEAK QUOTE ─────────────────────────────────
jobs      5000 across 1 venue(s)
deadline  2026-08-21 21:11 PDT (24.0h out)
tokens    4,000,000 in · 1,000,000 out

  openai:batch      5000 job(s)  list $2.00  batch $1.00  save $1.00 (50.0%)

list      $2.00   (run now, synchronously)
batch     $1.00   (run by the deadline)
save      $1.00 (50.0%)
risk      deadline is inside the 24h batch window — the SLA rests on the sync fallback, which pays list
basis     input explicit; output explicit
prices    snapshot 2026-08-21 — estimate only, not a bill
───────────────────────────────────────────────

From Python, offpeak.quote(jobs, deadline="06:00") takes the same jobs you would pass to run(). Token counts come from the job where it knows them (metadata={"input_tokens": ..., "output_tokens": ...}, or max_tokens as an output ceiling) and are a labeled chars/4 estimate where it does not — every figure reports its provenance in basis, and a quote with no output signal is marked a floor, not an estimate.

If you do know roughly what the model will write, say so and get a priced number instead — quote(jobs, deadline=..., assumed_output_ratio=0.25), or metadata={"expected_output_tokens": 300} on a single job. Those quotes are marked EST, distinct from a floor. Both are opt-in: absent one, offpeak assumes nothing on your behalf.

Deadlines

Deadlines are how software says "this can wait" — the full semantics live in SPEC.md.

Form Meaning
"06:00" the next 6am, local time (the canonical session form)
"4h", "90m", "2d" relative to now
"2026-08-21T06:00:00-07:00" ISO 8601, absolute
datetime / timedelta / seconds native Python forms

How a run works

  1. Jobs are grouped by venue (claude-* → Anthropic Message Batches, gpt-*/o* → OpenAI Batch) and submitted at the batch tier — 50% off list.
  2. offpeak polls the venues, backing off while the window is long.
  3. When remaining time reaches the risk buffer (default: 15% of the window, clamped to 1–10 minutes), unfinished jobs are cancelled and re-run synchronously so the deadline holds. Set fallback="none" to report them instead.
  4. Results come back in input order, each with a per-job Receipt; offpeak.receipt(results) settles the run.
results = offpeak.run(
    jobs,
    deadline="06:00",
    fallback="sync",       # meet the deadline at list price if the batch is at risk
    risk_buffer=600,       # seconds held in reserve (optional)
)

Receipts and prices

Receipts are computed against a bundled snapshot of public list prices (batch = 50% off list, as published). Providers change prices — verify and override at runtime:

import offpeak

offpeak.prices.register_price("my-fine-tune", input_per_m=4.0, output_per_m=16.0)

Unknown models settle with cost = None rather than a guess. The sheet also carries what the venues charge for urgency — get_fast_price(), urgency_spread() — and flags list prices that are promotional, with the date and the price they decay to: promo_decay("gpt-5.6-sol") is (1.25, 1.5) after 2026-11-21.

What this is (and the roadmap)

offpeak is the open client and spec for a simple claim: intelligence has a time value. A large share of AI work — embeddings, evals, backfills, report generation, daily agent runs — has no human waiting on it, and the venues already sell that patience at 50% off. This library is the missing workflow.

The token side is wider than the headline discount. Patience sells at 50% off — a 2.0x spread — and haste is priced too: hold the model and venue constant and gpt-5.6-sol costs $8.00 / $40.00 per 1M on OpenAI's fast tier against $2.00 / $10.00 on its batch tier, a 4x intra-venue urgency spread for the hour alone (source; sol's standard rate is promotional at least through 2026-11-21, and both tiers are defined off it, so the ratio outlives the prices). It is data, not prose: offpeak.prices.urgency_spread("gpt-5.6-sol") returns 4.0.

The Spread Board marks the same claim against open grid data daily — GB power and carbon plus CAISO SP15 and ERCOT Houston peak/off-peak spreads, alongside the published token spreads. ERCOT Houston marked 3.94x on the session of 2026-08-20; a venue charges 4x for the same impatience.

The roadmap follows the same interface upward: more venues (Google batch, spot capacity, off-peak windows on your own GPUs), queue-latency forecasting instead of a fixed risk buffer, portfolio placement across venues, energy- and carbon-aware scheduling with per-job receipts. The venue interface (offpeak.Venue) is deliberately the extension point — a venue is anywhere deferred work can run.

A hosted desk that does the forecasting, cross-venue portfolio scheduling, and SLA insurance at fleet scale — payloads never leaving your perimeter — is being built by the same team. The SDK and the deadline spec stay open, Apache-2.0.

Contributing

Issues and PRs welcome — see CONTRIBUTING.md. Spec changes start as issues against SPEC.md.

License

Apache-2.0 © Offpeak

Metadata

Release files for offpeak 0.2.7

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

Source distribution (sdist)

Source distribution for offpeak 0.2.7
File Size Uploaded
offpeak-0.2.7.tar.gz 250.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for offpeak 0.2.7
File Interpreter ABI Platform
offpeak-0.2.7-py3-none-any.whl Python 3 none any Details

Total release size: 316.2 kB

Release files / offpeak-0.2.7.tar.gz

Download URL offpeak-0.2.7.tar.gz
Size 250.8 kB
Tags Source
SHA-256 checksum
How to use checksums
7e05b05bf353fdfa5d3c6df145fc5fe611248d5ed4231278c574cb4e0cb643ae
BLAKE2b-256 checksum
How to use checksums
27ffe5188bdcbc67d825090049a7c616656e150e01606681d0a89ff8deaecccb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Aug 30, 2026.

Transparency log

Release files / offpeak-0.2.7-py3-none-any.whl

Download URL offpeak-0.2.7-py3-none-any.whl
Size 65.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c82537c8e736f67b5722a27a4a558b661b4bade76688c55be05df90e09ff1eee
BLAKE2b-256 checksum
How to use checksums
fc258fe01bc9f1cfa4f5c123f468861ce4062bc95948900ccc48905dad7fb7fd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Aug 30, 2026.

Transparency log

Release history Release notifications | RSS feed

0.3.0

2 release files

0.2.8

2 release files

This release

0.2.7 This release

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

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