Track LLM token costs per customer using the Langchain code node
Needs changesWhat this workflow does
This AI workflow has 12 nodes and runs when someone submits an n8n form (“CV Parsing Service”) (plus 1 other trigger). Along the way it connects Google Sheets and Gmail.
How it runs
Trigger: When someone submits an n8n form (“CV Parsing Service”) (plus 1 other trigger).
- Parse PDF Upload (Extract from File): extracts data from a file (pdf)
- Get Client Logs (Google Sheets): uses Google Sheets
- Logging Attributes (Edit Fields (Set)): sets 3 fields: workflow_id, execution_id, client_id
- Filter: keeps only the items that match a condition
- Extract Resume Data (Information Extractor): extracts structured fields from text with AI, with model: Custom LLM Subnode
- Calculate Totals (Summarize): summarizes / groups the items
- Display JSON Document (n8n Form): shows the next form page
- Send Invoice (Gmail): uses Gmail
Services it uses
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 Custom LLM Subnode: no direct replacement.
Rather not rewrite it? Many of these flows can be rebuilt in Make (free plan).
| Removed in 3.0 | Replace with |
|---|---|
| LangChain Code (legacy) Custom LLM Subnode | No direct replacement |
Nodes used (12)
- Google Sheets Tool
n8n-nodes-base.googleSheetsTool - Edit Fields (Set)
n8n-nodes-base.set - n8n Form Trigger
n8n-nodes-base.formTrigger - LangChain Code
@n8n/n8n-nodes-langchain.code - n8n Form
n8n-nodes-base.form - Filter
n8n-nodes-base.filter - Google Sheets
n8n-nodes-base.googleSheets - Summarize
n8n-nodes-base.summarize - Schedule Trigger
n8n-nodes-base.scheduleTrigger - Gmail
n8n-nodes-base.gmail - Extract from File
n8n-nodes-base.extractFromFile - Information Extractor
@n8n/n8n-nodes-langchain.informationExtractor
From the author
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…