Skip to main content

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

Workflow preview

Workflow preview
100%
Track OpenAI token usage and AI agent metrics with Google Sheets dashboard preview
Open on n8n.io

Important notice

This workflow is provided as-is. Please review and test before using in production.

1. Workflow Overview

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 Develo...

Best for

  • Engineering automation workflows
  • Multimodal AI automation workflows
  • intermediate n8n builders looking for reusable templates

Tools used

@n8n/n8n-nodes-langchain.chattrigger, @n8n/n8n-nodes-langchain.agent, n8n-nodes-base.googlesheetstool, n8n-nodes-base.stickynote, n8n-nodes-base.set, @n8n/n8n-nodes-langchain.code, n8n-nodes-base.if, n8n-nodes-base.googlesheets

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by Hunyao.

Original n8n.io source

1.1 Workflow description

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

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 transparency in prototypes.

How it works

  1. Chat Trigger collects user input for the AI Agent.
  2. A Set node injects metadata like workflow, execution, and client IDs.
  3. LangChain Code node returns a configured Chat model with a callback that reads usage metadata.
  4. The callback computes input, output, and total costs based on per‑million token prices you define.
  5. It appends token metrics to a Google Sheet via the Google Sheets Tool.
  6. The Agent records intermediate tool calls.
  7. An If node checks whether a tool was used.
  8. When tools are used, the workflow logs input, output, tool name, and metadata to an Observability sheet.

How to use SELF-HOSTED N8N ONLY - the Langchain Code node is only available in the self-hosted version of n8n. It is not available in n8n cloud.

Requirements Self-hosted version of n8n

If you have any questions in running the workflow, see the attached video: https://youtu.be/JSulRS128MA

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - When chat message received

Type / Role
@n8n/n8n-nodes-langchain.chatTrigger - chatTrigger
Config choices
Version 1.1

Block 2 - AI Agent

Type / Role
@n8n/n8n-nodes-langchain.agent - agent
Config choices
Version 2.1

Block 3 - Token Usage Log

Type / Role
n8n-nodes-base.googleSheetsTool - googleSheetsTool
Config choices
Version 4.5

Block 4 - Sticky Note8

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 5 - Sticky Note

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 6 - Set • Workflow + Client Metadata

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 7 - LangChain Chat Model + Token Callback

Type / Role
@n8n/n8n-nodes-langchain.code - code
Config choices
Version 1

Block 8 - Branch • Tool Used?

Type / Role
n8n-nodes-base.if - if
Config choices
Version 2.2

Block 9 - Log • Token Metrics to Sheets (Tool)

Type / Role
n8n-nodes-base.googleSheets - googleSheets
Config choices
Version 4.6

3. Summary Table

Workflow Track OpenAI token usage and AI agent metrics with Google Sheets dashboard
Complexity intermediate
Nodes 9
Categories Engineering, Multimodal AI
Author Hunyao
Published 11 Aug 2025

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/7231/7231.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does Track OpenAI token usage and AI agent metrics with Google Sheets dashboard do?

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 Develo...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your Engineering, Multimodal AI use case.