⚒️ Track LLM token costs per customer using the Langchain code node

1,577 views · ⚒️ Engineering

Description

Screenshot of template

Note: This template only works for self-hosted n8n.

This n8n template demonstrates how to use the Langchain code node to track token usage and cost for every LLM call.

This is useful if your templates handle multiple clients or customers and you need a cheap and easy way to capture how much of your AI credits they are using.

How it works

Check out the example Client Usage Log - https://docs.google.com/spreadsheets/d/1AR5mrxz2S6PjAKVM0edNG-YVEc6zKL7aUxHxVcffnlw/edit?usp=sharing

How to use

Requirements

Customising this template

🔗 Nodes Used

Google Sheets, Gmail, Schedule Trigger, Filter, LangChain Code, n8n Form Trigger

📥 Import

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

📖 Importing guide · 🔑 Credential setup