AI Model Wiki

    Skip to main content
    22 min
    Lesson 3 of 4

    FinOps for AI

    From the course AI Cost Optimization

    Implement FinOps practices for sustainable AI cost management at the organizational level.

    Cost Attribution

    Tagging Strategy

    # Track costs by team, product, and use case
    class CostTracker:
        def track_usage(self, model, input_tokens, output_tokens, metadata):
            cost = self.calculate_cost(model, input_tokens, output_tokens)
            
            self.db.insert({
                "timestamp": datetime.utcnow(),
                "model": model,
                "input_tokens": input_tokens,
                "output_tokens": output_tokens,
                "cost_usd": cost,
                "team": metadata.get("team"),
                "product": metadata.get("product"),
                "use_case": metadata.get("use_case"),
                "environment": metadata.get("environment")  # dev/staging/prod
            })
        
        def get_monthly_report(self):
            return self.db.query("""
                SELECT team, product, use_case, 
                       SUM(cost_usd) as total_cost,
                       SUM(input_tokens) as total_input_tokens
                FROM ai_usage
                WHERE timestamp > NOW() - INTERVAL '30 days'
                GROUP BY team, product, use_case
                ORDER BY total_cost DESC
            """)
    

    Budget Controls

    Hard Limits and Alerts

    class BudgetGuard:
        def __init__(self, monthly_budget_usd):
            self.monthly_budget = monthly_budget_usd
        
        def check_budget(self, team):
            current_spend = self.get_current_month_spend(team)
            budget = self.get_team_budget(team)
            
            utilization = current_spend / budget
            
            if utilization > 0.8:
                self.send_alert(team, f"80% of monthly budget consumed")
            
            if utilization >= 1.0:
                self.disable_non_critical_features(team)
                self.send_alert(team, "Budget limit reached - non-critical AI disabled")
            
            return utilization < 1.0
    

    Optimization Roadmap

    Quick Wins (Week 1-2)

    • Enable response caching for repeat queries (30-60% cost reduction)
    • Switch dev/test traffic to cheaper models (80% savings for non-production)
    • Set daily spending limits per team

    Medium-Term (Month 1-3)

    • Implement batch processing for async workloads (50% savings)
    • Optimize prompts for token efficiency (30-70% reduction)
    • Audit and eliminate unused AI features

    Long-Term (Month 3-12)

    • Evaluate open-source models for high-volume use cases
    • Implement model routing (smart selection per task type)
    • Build fine-tuned models for repetitive tasks

    Key Takeaways

    • •Cost attribution by team, product, and use case enables data-driven optimization
    • •Hard budget limits with automated enforcement prevent runaway AI spending
    • •Quick wins with caching and model selection typically achieve 40-60% immediate savings
    • •FinOps maturity model progresses from visibility to optimization to governance
    0 of 4 lessons marked complete

    Progress is kept in this browser only.