Track AI Agent token usage and estimate costs in Google Sheets
n8n template #5541Summary
Use templateThis n8n template demonstrates how to obtain token usage from AI Agents and places the data into a spreadsheet that calculates the estimated cost of the execution. Obtaining the token usage from AI Agents is tricky, because it doesn't provide all the data from tool calls. This workflow taps into the workflow execution metadata to extract token usage information. Works well with OpenAI, Google and Anthropic. Other LLM providers might need small tweaks. How it works The AI Agent executes and then calls a subworkflow to calculate the token usage. The data is stored in Google Sheets The spreadsheet has formulas to calculate the estimated cost of the execution. How to use The AI Agent is used as
Hand off to your agent
Prompt
Help me set up the n8n workflow "Track AI Agent token usage and estimate costs in Google Sheets" (https://n8n.io/workflows/5541). It uses: Google Sheets, AI Agent, Anthropic Chat Model, OpenAI Chat Model, Google Gemini Chat Model, Think Tool. Import the template JSON into my n8n instance, list every credential I need to create, and walk me through testing it.
Paste into Claude Code and it will do the rest.
Apps and nodes
Similar workflows
NameViews
- Explore n8n Nodes in a Visual Reference Library5,197
- Generate AI Viral Videos with Seedance and Upload to TikTok, YouTube & Instagram215K
- Generate & Auto-post AI Videos to Social Media with Veo3 and Blotato71K
- π€ AI content generation for Auto Service π Automate your social mediaπ²!27K
- Create & Upload AI-Generated ASMR YouTube Shorts with Seedance, Fal AI, and GPT-424K
- AI-Powered RAG Workflow For Stock Earnings Report Analysis15K
- Build an AI-Powered Tech Radar Advisor with SQL DB, RAG, and Routing Agents12K
- Lead Workflow: Yelp & Trustpilot Scraping + OpenAI Analysis via BrightData7,460