green-batch-ai
Run your bulk AI jobs cleaner and cheaper. Find the time (and place) when the grid is cleanest for jobs you run yourself, turn a list of prompts into OpenAI, Anthropic or Gemini batch files at half the price, and work out how many requests to keep in flight under your rate limits.
pip install green-batch-ai
green-batch-ai plan --signal uk --hours 4 --watts 2000 --deadline 2026-12-05T12:00Z --tz Europe/London
Carbon-aware plan (uk): 4 h job, 8 kWh
Forecast in your window: 96 to 246 gCO2/kWh (average 162)
Best start: Sat 05 Dec 02:00 Europe/London, finishing Sat 05 Dec 06:00 Europe/London
Emissions: 789 g at 99 g/kWh, against 1.87 kg if started now (234 g/kWh)
Saving: 1.08 kg (58%)
(From the real Great Britain forecast of 4 December 2026, saved in examples/: a windy night more than halves the carbon of the same job.)
What it does
1. When and where to run (plan, run)
For jobs on your own hardware or cloud machines (embedding a catalogue, scoring a dataset, fine-tuning, nightly evaluations), it reads a carbon-intensity forecast and finds:
- the best start time for a job that runs in one go, or
- the cleanest slots for a job that can pause and resume (
--interruptible), - or the best place among several zones (
--zones DE,FR,SE).
It compares that with starting now and shows the saving. run waits until the best start and then runs your command:
green-batch-ai run --signal uk --postcode RG1 --hours 3 --watts 1500 --deadline 2026-12-06T08:00Z -- python embed_catalog.py
Forecast sources:
--signal |
Coverage | Key |
|---|---|---|
uk |
Great Britain, national, by region (--region-id) or outward postcode (--postcode), half-hourly, 48 h |
none (NESO Carbon Intensity API, CC BY 4.0) |
electricitymaps |
Worldwide zones (--zone), or a cloud data centre (--provider aws --cloud-region eu-west-1), hourly |
ELECTRICITYMAPS_TOKEN |
file:forecast.csv |
Anything: your utility's forecast, a WattTime export (time,value CSV or JSON) |
none |
static:450 |
Grids with no forecast | none |
It tells you when waiting is pointless. Where carbon intensity hardly changes over a day (much of South Asia today, where most power is fossil all day), shifting saves little, and the plan says so. Research on real grids finds the same: the gains from shifting are real but limited and depend heavily on the region (Sukprasert et al., EuroSys 2024). In those places, a smaller model or a cleaner region matters more.
2. Batch files at half price (batch-files)
If results can wait up to a day, every major provider charges half for batch jobs, with their own, higher limits:
| Provider | Price | Limits per batch | Turnaround |
|---|---|---|---|
| OpenAI Batch API | 50% off | 50,000 requests, 200 MB file | within 24 h |
| Anthropic Message Batches | 50% off | 100,000 requests or 256 MB | most within 1 h, at most 24 h; results kept 29 days |
| Gemini Batch Mode | 50% off | input file up to 2 GB | target 24 h |
green-batch-ai batch-files prompts.csv --provider anthropic --model your-model-id --out batches/ --prices prices.json --output-tokens 150
It reads a CSV or JSONL of prompts (id, prompt or messages, optional system, max_tokens, model), writes files in each provider's format (OpenAI JSONL for chat completions or the Responses API, the Anthropic request body, Gemini JSONL with key and request), splits them under the limits, and estimates normal and batch cost from an llm-cost-shield price table.
The provider decides when a batch runs inside its window, so carbon-aware timing is for jobs you run yourself; batching is the saving for API jobs.
3. Concurrency under rate limits (concurrency)
For jobs that must use the normal API:
green-batch-ai concurrency --requests 100000 --rpm 600 --tpm 2000000 --input-tokens 500 --output-tokens 200 --latency 2
100,000 requests: run 18 at a time for about 9.00 requests/s, limited by requests per minute (with 10% headroom).
Expected duration: 185 minutes (3.1 h).
Use the provider's batch API instead if results can wait: half the price, separate limits.
By Little's law, requests in flight equal throughput times latency. More concurrency than that only produces 429 errors and retries, which waste time, money and energy.
From Python
from green_batch_ai import uk, plan, format_plan
p = plan(uk(postcode="M1"), hours=3, kwh=4.5)
print(format_plan(p, tz="Europe/London"))
Prior work
CATS, the Climate-Aware Task Scheduler (Bartholomew et al., JOSS 2025) schedules jobs for the UK grid and HPC schedulers. green-batch-ai adds other forecast sources, pausable jobs, comparing places, and the parts specific to AI workloads: provider batch files, batch pricing and rate-limit planning.
Limits
- Forecasts are forecasts; real intensity can differ by a few percent or more.
- Average intensity is used (what the sources publish). Marginal intensity, the plants that respond to extra demand, can differ.
- For the energy of a job, measure a short run with greeninfer or a power meter, or use the machine's typical draw.
SDG alignment
This tool supports SDG target 7.3 (energy efficiency): batching and right-sized concurrency remove wasted retries and idle time. It also supports target 13.3 (improve awareness and capacity on climate change mitigation), by making the carbon cost of when and where a job runs visible and actionable, and target 7.2 (increase the share of renewable energy), since running flexible work when wind and solar are plentiful uses more of them.
Sources
- NESO Carbon Intensity API. https://carbonintensity.org.uk and https://carbon-intensity.github.io/api-definitions/
- Electricity Maps API reference. https://portal.electricitymaps.com/developer-hub/api/reference
- OpenAI Batch API guide. https://developers.openai.com/api/docs/guides/batch
- Anthropic Message Batches. https://platform.claude.com/docs/en/build-with-claude/batch-processing
- Gemini API Batch Mode. https://ai.google.dev/gemini-api/docs/batch-mode
- Wiesner P. et al. (2021). Let's Wait Awhile: How Temporal Workload Shifting Can Reduce Carbon Emissions in the Cloud. Middleware '21. arXiv:2110.13234
- Sukprasert T. et al. (2024). On the Limitations of Carbon-Aware Temporal and Spatial Workload Shifting in the Cloud. EuroSys '24. arXiv:2306.06502
- Bartholomew S. L. et al. (2025). CATS: The Climate Aware Task Scheduler. Journal of Open Source Software 10(111), 8251.
About
Built by Ahmad Zia, an AI and e-commerce consultant and green-AI researcher who teaches parallel and distributed computing. MIT licensed. Forecast data keeps its own licence (NESO data CC BY 4.0).
Guide, help and author
- Full guide with examples and FAQs: www.ahmadzia.com/tools/green-batch-ai
- Background reading: How to reduce LLM costs: 10 methods ranked by what they save
- All 30 free tools and agent skills: ahmadzia.com/tools · ahmadzia.com/skills
- Want it set up, fixed or tuned for your store? Book a free call
Built by Ahmad Zia (Muhammad Ahmad Zia), an AI consultant for ecommerce since 2020 and green AI researcher at the University of Lahore. Research · Google Scholar · ORCID · LinkedIn · GitHub
More AI cost control tools
- llm-cost-shield: Stop surprise LLM bills with per-user budgets, caching and cheap-model routing
- right-size-model: Find the cheapest LLM that is good enough for each task, with a statistical test
- parallel-inference-tuner: Find the fastest, most energy-efficient threads, workers and batching for model serving
All 30 tools and agent skills: github.com/MuhammadAhmadZia · ahmadzia.com/tools
Metadata
Release files for green-batch-ai 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| green_batch_ai-0.1.0.tar.gz | 23.7 kB | With provenance | Details for green_batch_ai-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| green_batch_ai-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for green_batch_ai-0.1.0-py3-none-any.whl |
Total release size: 43.8 kB
Release files / green_batch_ai-0.1.0.tar.gz
| Download URL | green_batch_ai-0.1.0.tar.gz |
|---|---|
| Size | 23.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9a876d15302284614267c5546670f070b8af92f12379ac353fc38c03db42be57
|
|
BLAKE2b-256 checksum How to use checksums |
c723b89cdeeb36f70560be701d8234c89c22254f90737c5fc4f4e8e69a9c4c83
|
| 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 5, 2026.
Transparency logRelease files / green_batch_ai-0.1.0-py3-none-any.whl
| Download URL | green_batch_ai-0.1.0-py3-none-any.whl |
|---|---|
| Size | 20.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bbbd8edad9693405cfffde2cc6a85a57822c9d3d1931132216a2cac7a2b4d969
|
|
BLAKE2b-256 checksum How to use checksums |
b533047a447fe1ef0f8b5b287d0f8dc55d8fa0f32bd0851c081ac85454ecee31
|
| 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 5, 2026.
Transparency logSecurity for green-batch-ai 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.
Attestation for green_batch_ai-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 5, 2026.
Transparency logA 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.