Skip to main content Switch to mobile version green-batch-ai 0.1.0 Run bulk AI jobs cleaner and cheaper: find the lowest-carbon time (and place) to run them from grid forecasts, write OpenAI, Anthropic and Gemini batch files at half price, and plan concurrency under rate limits.
pip install green-batch-ai Copy PIP instructions
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.)
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:
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:
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 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.
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.
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.
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.
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
Released: Dec 5, 2026
Author: Muhammad Ahmad Zia
Both files in this release have provenance metadata.
View provenance details
MIT View SPDX License List
anthropic-batch batch carbon-aware carbon-intensity electricity-maps gemini-batch green-ai llm openai-batch rate-limits scheduling sustainability
Development Status 3 - Alpha
Intended Audience Developers
Programming Language Python :: 3
Topic Scientific/Engineering :: Artificial Intelligence
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)
Built distribution (wheel)
Total release size: 43.8 kB
Release files / green_batch_ai-0.1.0.tar.gz
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.
Release files / green_batch_ai-0.1.0-py3-none-any.whl
Security for green-batch-ai 0.1.0
Both files in this release have been uploaded with provenance metadata.
With provenance green_batch_ai-0.1.0.tar.gz Dec 5, 2026
With provenance green_batch_ai-0.1.0-py3-none-any.whl Dec 5, 2026
Attestation for green_batch_ai-0.1.0.tar.gz
Attestation for green_batch_ai-0.1.0-py3-none-any.whl
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
Dec 5, 2026 2 release files Full provenance
"PyPI", "Python Package Index", and the blocks logos are registered trademarks of the Python Software Foundation.
© 2026 Python Software Foundation
Deployed from 4d99e05











