Library / Monitoring, Ops & Incidents
Monitoring, Ops & Incidents
Track AI Agent Token Usage and Costs in Sheets
When called or run, it reads execution data from the n8n API, extracts token usage for Claude, OpenAI, Gemini and OpenRouter, and logs estimated costs in Google Sheets.
What it does
## Limitations ### 1. This workflow doesn't account for Prompt caching If you're consecutively sending similar prompts to OpenAI it'll automatically use Cached Tokens to reduce the cost of your requests. So our cost estimates will have a higher value than the actual cost. Other providers like Anthropic and Google have similar mechanisms. ### 2. Not tested with audio or video files This workflow was tested with text and images, but no tests were made with audio files or videos. ### 3. The cost is an estimate In the spreadsheet you can see the total cost of the requests, but that is only an estimate. If you do batch requests, prompt caching or other techniques to reduce cost, the estimate might be higher than the actual cost.
The steps
- When clicking ‘Test workflow’
- AI Agent
- Call sub-workflow
- Think
- Extract token usage data
- Get execution data
- When Executed by Another Workflow
- Split Out
- Sum Token Totals - aggregate by model
- Record token usage
- Gemini
- OpenAI
- Anthropic
Similar automations
Monitoring, Ops & IncidentsTrack AI Token Usage for WhatsApp and Telegram Agents25 stepsReports, Analytics & DashboardsTrack OpenAI API Usage and Costs in Google Sheets26 stepsMonitoring, Ops & IncidentsTrack AI Token Usage and Cost in Google Sheets8 stepsMonitoring, Ops & IncidentsLog Agent Outputs, Errors and Costs in Airtable12 steps