Templates / Track OpenAI token usage and AI agent metrics with Google Sheets dashboard

Track OpenAI token usage and AI agent metrics with Google Sheets dashboard

Needs changes

by Hunyao ✓ · 1,278 views · created 2025-08-11 · Engineering, Multimodal AI

Needs changes. This template uses 1 thing(s) that n8n 3.0 removes: LangChain Code (legacy). 1 breaking item(s) found. Static check, last run 2026-10-19.

What this workflow does

This AI workflow has 7 nodes and runs when a chat message arrives. Along the way it connects Google Sheets.

How it runs

Trigger: When a chat message arrives.

  1. Set • Workflow + Client Metadata (Edit Fields (Set)): sets 3 fields: workflow_id, execution_id, client_id
  2. AI Agent: runs an AI agent, with model: LangChain Chat Model + Token Callback
  3. Branch • Tool Used? (If): checks a condition and branches into true / false
  4. Log • Token Metrics to Sheets (Tool) (Google Sheets): append

Services it uses

Google Sheets

Before you upgrade to n8n 3.0

1 thing in this workflow is removed in n8n 3.0. Fix it before you upgrade:

  • LangChain Code (legacy) in LangChain Chat Model + Token Callback: no direct replacement.

Rather not rewrite it? Many of these flows can be rebuilt in Make (free plan).

Removed in 3.0Replace with
LangChain Code (legacy)
LangChain Chat Model + Token Callback
No direct replacement

Nodes used (7)

From the author

What it does Captures token usage and cost from your AI Agent/LLM. Logs model, tokens, cost, tool use, and conversation I/O to Google Sheets for simple observability and billing. Perfect for Developers adding usage monitoring to AI agents. Teams needing cost…

Excerpt from Hunyao's description on n8n.io.

View the original on n8n.io → Check your own copy

Get the weekly “what broke” email

New templates, newly broken ones, and n8n release changes. One short email a week.

Form not loading? Subscribe here.