CarbonCue SDK
Core Python SDK for carbon-aware computing based on Green Software Foundation (GSF) principles.
Features
- 🌍 Real-time carbon intensity data from Electricity Maps
- 📊 SCI (Software Carbon Intensity) score calculation per GSF specification
- ⚡ Async/await support for high-performance applications
- 🔌 Extensible API client architecture
- 💾 Built-in caching to reduce API calls
- 🎯 Type-safe with Pydantic models
Installation
pip install carboncue-sdk
Quick Start
import asyncio
from carboncue_sdk import CarbonClient
async def main():
async with CarbonClient() as client:
# Get current carbon intensity
intensity = await client.get_current_intensity(
region="us-west-2",
provider="aws"
)
print(f"Current intensity: {intensity.carbon_intensity} gCO2eq/kWh")
# Calculate SCI score
sci = client.calculate_sci(
operational_emissions=100.0, # gCO2eq from energy usage
embodied_emissions=50.0, # gCO2eq from hardware
functional_unit=1000, # Number of requests
functional_unit_type="requests",
region="us-west-2"
)
print(f"SCI Score: {sci.score} gCO2eq/request")
asyncio.run(main())
Configuration
Set environment variables with CARBONCUE_ prefix:
export CARBONCUE_ELECTRICITY_MAPS_API_KEY=your_api_key
export CARBONCUE_DEFAULT_REGION=us-west-2
export CARBONCUE_CACHE_TTL_SECONDS=300
Or use a .env file:
CARBONCUE_ELECTRICITY_MAPS_API_KEY=your_api_key
CARBONCUE_DEFAULT_REGION=us-west-2
SCI Calculation
Implements the GSF Software Carbon Intensity specification:
SCI = (O + M) / R
Where:
O = Operational emissions (energy consumption × carbon intensity)
M = Embodied emissions (hardware manufacturing & infrastructure)
R = Functional unit (requests, users, transactions, etc.)
API Reference
CarbonClient
Main client for carbon-awareness operations.
Methods:
get_current_intensity(region, provider)- Get real-time carbon intensitycalculate_sci(...)- Calculate SCI score per GSF specclose()- Cleanup resources
Models
CarbonIntensity- Carbon intensity data with timestampSCIScore- Complete SCI calculation resultRegion- Cloud region informationEmissionsBreakdown- Detailed emissions breakdown
Development
# Install in development mode
cd packages/sdk
pip install -e ".[dev]"
# Run tests
pytest
# Type checking
mypy src/
License
MIT License - see LICENSE file for details.
Metadata
Release files for carboncue-sdk 1.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 |
|---|---|---|---|---|
| carboncue_sdk-1.1.0.tar.gz | 6.9 kB | Without provenance | Details for carboncue_sdk-1.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| carboncue_sdk-1.1.0-py3-none-any.whl | Python 3 | none | any | Details for carboncue_sdk-1.1.0-py3-none-any.whl |
Total release size: 15.9 kB
Release files / carboncue_sdk-1.1.0.tar.gz
| Download URL | carboncue_sdk-1.1.0.tar.gz |
|---|---|
| Size | 6.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6318356a96885e53995ef61ea47df623bfc7259070e6d120ee93db3c9cb2921c
|
|
BLAKE2b-256 checksum How to use checksums |
bdfd57431ca97b674fea01afcd01ac7a4aa2c796e9de5a6738029fe39d260d8d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.14
|
Release files / carboncue_sdk-1.1.0-py3-none-any.whl
| Download URL | carboncue_sdk-1.1.0-py3-none-any.whl |
|---|---|
| Size | 9.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7a275a2b3daa7f1dec6060af4d5de0f05783448e18add081dd7fc49c752ca336
|
|
BLAKE2b-256 checksum How to use checksums |
47bed29d87d5b475b5f63e664fcefac5bf9453f829a612e0813f23b10de0e163
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.14
|
Security for carboncue-sdk 1.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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.