Keyflow

Search Keyflow

Find a shortcut, workflow, MCP server or skill

Track AI Agent token usage and estimate costs in Google Sheets

n8n template #5541
This 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
  1. Explore n8n Nodes in a Visual Reference Library5,197
  2. Generate AI Viral Videos with Seedance and Upload to TikTok, YouTube & Instagram215K
  3. Generate & Auto-post AI Videos to Social Media with Veo3 and Blotato71K
  4. πŸ€– AI content generation for Auto Service 🚘 Automate your social mediaπŸ“²!27K
  5. Create & Upload AI-Generated ASMR YouTube Shorts with Seedance, Fal AI, and GPT-424K
  6. AI-Powered RAG Workflow For Stock Earnings Report Analysis15K
  7. Build an AI-Powered Tech Radar Advisor with SQL DB, RAG, and Routing Agents12K
  8. Lead Workflow: Yelp & Trustpilot Scraping + OpenAI Analysis via BrightData7,460
Buy me a coffee