Track LLM Token Costs per Customer with Langchain Code Node

Track token usage and costs for every LLM call per customer using a custom Langchain Code node in self-hosted n8n. Logs data to Google Sheets for aggregation and billing insights.

This n8n workflow demonstrates tracking LLM token usage and costs for individual customers using the Langchain Code node, exclusively for self-hosted n8n instances. It simulates an AI service converting resume PDFs to JSON: a form trigger handles PDF uploads, followed by file extraction, field editing for metadata, and an Information Extractor node with a custom LLM subnode built via Langchain Code. Lifecycle hooks capture usage metadata, which is logged to Google Sheets. Key benefits include c
Platform
n8n
Category
Customer Support
Price
$19.99
Creator
Nadia Ivanov

How to import this workflow into n8n

  1. 1Purchase or download the workflow to get the n8n workflow JSON file.
  2. 2In your n8n instance, open Workflows and choose "Import from File" (or paste the JSON with Ctrl+V on the canvas).
  3. 3Open each node marked with a credential warning and connect your own accounts and API keys.
  4. 4Run the workflow once manually to verify the data flow, then toggle it to Active.

Related Customer Support workflows

More from Nadia Ivanov

Need this deployed? We'll set it up for you.

Our automation experts deploy this workflow in your stack, connect your accounts, and verify it works — or build a custom solution from scratch.