Skip to content
NEWMarketplace and the trig8n Agent: sell what you build, and get plans and changes that are tested before you see them. See what is new

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

  1. When clicking ‘Test workflow’
  2. AI Agent
  3. Call sub-workflow
  4. Think
  5. Extract token usage data
  6. Get execution data
  7. When Executed by Another Workflow
  8. Split Out
  9. Sum Token Totals - aggregate by model
  10. Record token usage
  11. Gemini
  12. OpenAI
  13. Anthropic

Similar automations