Skip to main content
Skip to content
Menu

AI Data Centers Beginner 5 parts Updated

Build a cost-tracking script for AI infrastructure

You'll have a working script that pulls your actual cloud spending on compute and flags when costs spike beyond projections.

What you'll make

AI Cost Monitor Script

  1. fetch_bills() — pulls current spending from cloud APIs: what to include
  2. detect_spikes() — flags unusual cost increases: what to include
  3. project_usage() — models next 90 days based on trends: what to include
  4. alert_thresholds() — sends notifications when limits are hit: what to include
  5. main() — orchestrates daily monitoring: what to include

Paste your working Python script with example output from your actual cloud bills

The 5 parts

Each part ends with a check you can see.

  1. Separate Real from Circular Costs

    Analyze your current AI spending to identify usage-driven costs vs relationship-subsidized pricing

    Done when

    A categorized breakdown of your last 90 days of AI infrastructure spending with circular vs direct costs identified

  2. Build the Data Pipeline

    Write fetch_bills() to pull current spending from your cloud provider's API

    Done when

    A working fetch_bills() function that pulls your last 30 days of AI-related charges with line-item detail

  3. Build Spike Detection

    Write detect_spikes() to flag unusual cost increases that might indicate runaway workloads

    Done when

    A working detect_spikes() function that catches cost increases above your defined threshold with test cases from your historical data

  4. Model Usage Trends

    Write project_usage() to forecast costs based on your actual usage patterns

    Done when

    A working project_usage() function that forecasts next 90 days of costs with confidence intervals based on your historical data

  5. Deploy the Complete Monitor

    Integrate all functions into a working monitoring script and run it on your infrastructure

    Done when

    A complete working script that runs daily monitoring, sends alerts for spikes, and provides cost projections with at least one week of real monitoring data

    Capstone: you put together your AI Cost Monitor Script.

Where this helps

An elective: a single lesson that sits outside rtwo's job certificates and doesn't count toward one.

About this lesson

What you'll be able to do

  • Run a working cost-tracking script on your actual cloud bills
  • Set automated alerts for cost spikes above your defined thresholds
  • Distinguish between real AI infrastructure costs vs circular revenue flows in your organization
  • Have a 90-day cost projection model based on your actual usage patterns

Who it's for

  • Engineering managers tracking AI infrastructure spend
  • Finance teams monitoring cloud costs for AI workloads
  • Technical leads building cost-aware AI systems
  • Anyone running AI workloads who's seen surprise bills

What it won't cover

  • Building production billing systems from scratch
  • Tax optimization or accounting policy
  • Vendor negotiation strategies
  • Multi-cloud cost allocation across teams

Skills you'll practise

  • Cloud billing API integration
  • Cost anomaly detection
  • Usage pattern analysis
  • Threshold-based alerting