
Monitoring Performance and Costs
The bill comes due. Learn to calculate token costs, identify expensive users, and optimize your spending.
Monitoring Performance and Costs
AI is expensive if unmanaged.
The Formula
Cost = (Input Tokens * Price) + (Output Tokens * Price).
- Images: Fixed price per image.
- Video: Price per second.
Estimation
Before launch, calculate the Unit Economics.
- Avg Input: 500 tokens.
- Avg Output: 200 tokens.
- Task: "Summarize Email".
- Model: Gemini Flash ($0.35 / 1M input).
- Cost per Task: $0.000175. (Very cheap).
Optimization
- Use Flash: 10x-20x cheaper than Pro.
- Shorten Prompts: Remove polite filler ("Please be so kind as to...").
- Limit Output: Use
max_output_tokensparam to prevent the model from writing a novel when you wanted a sentence.
Summary
If you track tokens, you control costs.
Module 11 Complete! You are ready for Production. In the final step, we build the Capstone Project.