# Track token usage from n8n AI agents and log to Google Sheets
This automation template helps developers and teams using LangChain-based AI agents in n8n to accurately track token consumption and analyze LLM costs. Data is collected after the main workflow execution and stored in Google Sheets for reporting and budgeting.
## Who it´s for
- Developers building AI agents in n8n who need to monitor token usage
- Automators using multiple LLM providers and wanting to control costs
- Teams implementing budget oversight for AI integrations in n8n
## What the automation does
- Triggers a sub-workflow after the main process completes
- Extracts input/output token data from LangChain agent execution metadata in n8n
- Uses JMESPath to parse and structure token usage information
- Aggregates data by model (OpenAI, Gemini, Anthropic) and execution ID
- Logs structured records into Google Sheets for analysis and cost tracking
## What´s included
- Ready-to-use n8n workflow with LangChain agent and token tracking support
- Trigger and handler logic based on manual or workflow execution events
- Integrations with Google Sheets API, OpenAI, Gemini, Anthropic
- Basic text instructions for deployment and adaptation
## Requirements for setup
- n8n instance with access to execution metadata
- Google account with Google Sheets API enabled
- API keys from LLM providers (OpenAI, Gemini, Anthropic)
- JMESPath support configured in n8n nodes
## Benefits and outcomes
- Accurate cost monitoring of LLM usage across models
- Compare efficiency of different LLMs by token volume per task
- Centralized logging of AI usage in a single spreadsheet
- Support for multi-provider environments (GPT, Claude, Gemini)
- Prevent unexpected API overages with transparent usage tracking
## Important: template only
Important: you are purchasing a ready-made automation workflow template only. Rollout into your infrastructure, connecting specific accounts and services, 1:1 setup help, custom adjustments for non-standard stacks and any consulting support are provided as a separate paid service at an individual rate. To discuss custom work or 1:1 help, contact via chat
No feedback yet