Appearance
Time-Shifted Execution
Defer non-urgent requests to execute during periods of lower grid carbon intensity.
How Time-Shifting Works
Time-shifted execution analyzes grid carbon intensity forecasts and schedules your requests for optimal sustainability:
- Submit Request: Queue your non-urgent workload
- Carbon Forecast: System predicts grid carbon intensity
- Optimal Scheduling: Request executes when carbon intensity is lowest
- Result Delivery: Receive response when complete
Basic Usage
python
from openai import OpenAI
client = OpenAI(
base_url="https://api.gateflow.ai/v1",
api_key="gw_prod_your_key_here"
)
# Defer execution to low-carbon period
response = client.chat.completions.create(
model="gpt-5.2",
messages=[{"role": "user", "content": "Generate comprehensive sustainability report"}],
routing_mode="time_shift_optimized",
max_delay_hours=12, # Maximum acceptable delay
priority="normal" # low, normal, high
)
print(f"Job ID: {response.deferred_job_id}")
print(f"Estimated completion: {response.estimated_completion}")
print(f"Expected carbon savings: {response.estimated_carbon_savings_gco2e} gCO₂e")Configuration Options
Delay Settings
python
# Short delay for slightly better carbon conditions
response = client.chat.completions.create(
model="auto",
messages=[{"role": "user", "content": "Quick analysis"}],
routing_mode="time_shift_optimized",
max_delay_hours=2, # Complete within 2 hours
min_carbon_savings_gco2e=10 # Minimum savings to justify delay
)
# Long delay for maximum carbon savings
response = client.chat.completions.create(
model="auto",
messages=[{"role": "user", "content": "Overnight data processing"}],
routing_mode="time_shift_optimized",
max_delay_hours=24, # Can wait up to 24 hours
target_carbon_intensity=200 # Wait for grid intensity <200 gCO₂/kWh
)Priority Levels
| Priority | Typical Delay | Use Case |
|---|---|---|
low | 6-24 hours | Background processing, batch jobs |
normal | 2-12 hours | Reports, non-urgent analysis |
high | 0-4 hours | Time-sensitive but flexible tasks |
Monitoring Deferred Jobs
python
# Check job status
job_status = client.deferred_jobs.get(response.deferred_job_id)
print(f"Status: {job_status.status}")
print(f"Scheduled for: {job_status.scheduled_for}")
print(f"Carbon intensity at submission: {job_status.grid_intensity_at_submission}")
print(f"Carbon intensity at execution: {job_status.grid_intensity_at_execution}")
print(f"Actual carbon savings: {job_status.carbon_saved_vs_immediate}")
# Wait for completion and get result
if job_status.status == "completed":
result = client.deferred_jobs.result(response.deferred_job_id)
print(f"Result: {result.content}")Batch Processing with Time-Shifting
python
# Process multiple requests in optimized batch
batch_response = client.batch.create(
requests=[
{
"model": "auto",
"messages": [{"role": "user", "content": "Analyze dataset A"}]
},
{
"model": "auto",
"messages": [{"role": "user", "content": "Analyze dataset B"}]
},
{
"model": "auto",
"messages": [{"role": "user", "content": "Analyze dataset C"}]
}
],
routing_mode="time_shift_optimized",
max_delay_hours=8,
batch_optimization="carbon_efficient" # Optimize batch execution order
)
print(f"Batch ID: {batch_response.batch_id}")
print(f"Estimated total carbon savings: {batch_response.estimated_total_savings_gco2e}")Carbon Savings Potential
Typical Savings by Delay
| Delay Period | Typical Carbon Savings | Best For |
|---|---|---|
| 2-4 hours | 20-40% | Short-term optimization |
| 4-8 hours | 40-60% | Daily workload shifting |
| 8-12 hours | 60-75% | Overnight processing |
| 12-24 hours | 75-85% | Weekend/off-peak execution |
Regional Variations
Carbon savings vary by region based on grid mix:
- Nordics/Hydro-rich: 30-50% savings
- France/Nuclear: 40-60% savings
- US Mixed Grid: 50-70% savings
- Coal-heavy Regions: 70-85% savings
Best Practices
Ideal Use Cases
✅ Perfect for:
- Nightly data processing
- Report generation
- Batch analytics
- Content creation pipelines
- Non-urgent customer communications
- Background data enrichment
❌ Avoid for:
- Real-time customer interactions
- Time-critical alerts
- Financial transactions
- Emergency response systems
- User-facing real-time features
Implementation Strategy
- Start Small: Test with non-critical workloads
- Monitor Impact: Track carbon savings and completion times
- Adjust Thresholds: Find optimal delay/savings balance
- Expand Gradually: Apply to more workloads as confidence grows
- Combine Approaches: Use with Sustain Mode for maximum impact
Advanced Configuration
Carbon Intensity Targets
python
# Set specific carbon intensity thresholds
response = client.chat.completions.create(
model="auto",
messages=[{"role": "user", "content": "Process when grid is cleanest"}],
routing_mode="time_shift_optimized",
max_delay_hours=12,
target_carbon_intensity=150, # Wait for <150 gCO₂/kWh
min_savings_percentage=50 # Require at least 50% savings vs immediate execution
)Regional Preferences
python
# Prioritize specific low-carbon regions
response = client.chat.completions.create(
model="auto",
messages=[{"role": "user", "content": "Execute in greenest region"}],
routing_mode="time_shift_optimized",
max_delay_hours=6,
preferred_regions=["nordics", "canada", "france"],
avoid_regions=["coal-heavy"]
)Troubleshooting
"Job not executing within expected time"
Causes:
- Carbon intensity not dropping as predicted
- Grid conditions more volatile than usual
- Regional constraints limiting options
Solutions:
- Increase
max_delay_hours - Lower
target_carbon_intensity - Reduce
min_savings_percentage - Check regional grid conditions
"Carbon savings lower than estimated"
Causes:
- Grid conditions changed after estimation
- Regional carbon intensity higher than expected
- Job executed before optimal conditions
Solutions:
- Increase maximum delay for better optimization
- Use more flexible carbon intensity targets
- Monitor grid conditions in your dashboard
Time-Shifting vs Other Optimization Methods
| Method | Carbon Savings | Latency Impact | Best For |
|---|---|---|---|
| Sustain Mode | 30-50% | Minimal | Real-time requests |
| Time-Shifting | 50-85% | Significant | Non-urgent workloads |
| Caching | 80-90% | None | Repeated requests |
| Combined | 70-95% | Varies | Comprehensive optimization |
Next Steps
- Explore Sustain Mode - Real-time carbon optimization
- View Deferred Jobs - Monitor time-shifted requests
- Configure Regional Policies - Optimize for specific regions
- Set Up Alerts - Get notified of optimal execution windows