⚒️ LLM usage tracker & cost monitor with node-level analytics (v2)

1,400 views · ⚒️ Engineering

Description

LLM Cost Monitor & Usage Tracker for n8n

> v2: Now it can read multiple types of LLM usages. Better dynamic approach for reading model usage.

🎯 What This Workflow Does

This workflow provides comprehensive monitoring and cost tracking for all LLM/AI agent usage across your n8n workflows. It extracts detailed token usage data from any workflow execution and calculates precise costs based on current model pricing.

The Problem It Solves

When running LLM nodes in n8n workflows, the token usage and intermediate data are not directly accessible within the same workflow. This monitoring workflow bridges that gap by:

⚙️ Setup Instructions

Prerequisites

  1. Experience Required: Basic familiarity with n8n LLM nodes and AI agents
  2. Agent Configuration: In your monitored workflows, go to agent settings and enable “Return Intermediate Steps”
  3. For getting execution data, you need to set upthe n8n API in your instance (also available onthe free version)

Installation Steps

  1. Import this monitoring workflow into your n8n instance
  2. Go to Settings >> select n8n API from left bar >> define an API. Now you can add this as the credential for your “Get an Execution” node
  3. Configure your model name mappings in the “Standardize Names” node
  4. Update model pricing in the “Model Prices” node (prices per 1M tokens)
  5. To monitor a workflow:
    • Add an “Execute Workflow” node at the end of your target workflow
    • Select this monitoring workflow
    • Important: Turn OFF “Wait For Sub-Workflow Completion”
    • Pass the execution ID as input

🔧 Customization

When You See Errors

If the workflow enters the error path, it means an undefined model was detected. Simply:

  1. Add the model name to the standardize_names_dic
  2. Add its pricing to the model_price_dic
  3. Re-run the workflow

Configurable Elements

📊 Output Data

Per LLM Call

Summary Statistics

✨ Key Benefits

📝 Example Use Cases

🚀 Quick Start

  1. Import workflow
  2. Update model prices (if needed)
  3. Add monitoring to any workflow with the Execute Workflow node
  4. View detailed cost breakdowns instantly

Note: Prices are configured per million tokens. Default includes GPT-4, GPT-3.5, Claude, and other popular models. Add custom models as needed.

🔗 Nodes Used

Stop and Error, n8n, Execute Workflow Trigger

📥 Import

Download workflow.json and import into n8n: Workflow menu → Import from File

📖 Importing guide · 🔑 Credential setup