Use this advanced n8n workflow to capture execution metrics, token usage, and performance data from your AI applications and send them automatically to LangFuse for deep observability. A powerful addition to your n8n templates collection.
Download this n8n workflow template and start using it instantly.
AI/ML Engineers: Who need reliable tracing of their LLM operations. n8n Automation Specialists: Looking for robust observability solutions for complex n8n workflow automations. Developers: Integrating LangFuse with their self-hosted or cloud n8n setups. Performance Analysts: Requiring detailed token usage and latency data per AI model run.
Maintaining visibility into AI application performance is crucial. This specialized n8n workflow solves the challenge of scattered execution data by consolidating detailed performance metrics—including prompt/completion tokens, latency, and model usage—and pushing them to LangFuse, a dedicated LLM observability platform. This sophisticated n8n template ensures that every single AI execution within your primary n8n workflow is tracked and analyzed. Utilizing the native n8n node for API interaction, combined with powerful JavaScript scripting, this automation provides essential insights that are difficult to gather otherwise, turning opaque AI steps into actionable data points. It is a vital component for anyone running production-grade AI applications using n8n.
This n8n workflow is designed to be triggered asynchronously by another parent n8n workflow after an AI task completes.
When Executed by Another Workflow n8n trigger, receiving the executionid of the completed AI run.Remove Duplicates n8n node ensures idempotent processing. A subsequent Wait n8n node introduces a crucial 80-second delay, allowing the source execution data (especially token totals and run metrics) to finalize within the n8n system before retrieval.n8n node connects via the n8n API to fetch the complete execution data associated with the received executionid.Code: structure execution data n8n node executes complex logic. It processes the raw execution results, identifies all individual LLM calls (e.g., 'OpenAI Chat Model' runs), calculates latency and token usage per run, and links them back to source 'Get a prompt' nodes, outputting a structured array of perModelRuns.Split Out and Loop Over Items n8n nodes break down the consolidated list of AI runs into individual items, allowing separate LangFuse tracking for each LLM execution step within the overall n8n workflow.Code: prepare JSON for LF n8n node constructs the necessary LangFuse ingestion payload for each run, creating trace-create (for workflow context) and generation-create (for the specific LLM output) events.HTTP Request n8n node securely submits the prepared batch data to the LangFuse Ingestion API endpoint, completing the observability cycle for this n8n execution.To implement this powerful n8n workflow template, follow these steps:
n8n node. This requires creating an 'n8n API' credential in your instance, enabling the workflow to read execution data.HTTP Request n8n node with LangFuse API credentials. Edit the HTTP Request node and navigate to the Authentication section. Select Generic Credential Type and choose HTTP Basic Auth.* Create a new credential where the Username is your LangFuse Public Key and the Password is your LangFuse Secret Key.$execution.id of the parent run as the execution_id parameter. When Executed by Another Workflow (n8n trigger): Starts the workflow when called by another n8n process, receiving the execution_id of the run to be monitored.
n8n (n8n node): Fetches comprehensive data about the target execution using the internal n8n API. Key configuration: Resource: execution, Operation: get, dynamically uses the received executionId.
Wait to get an execution data (n8n node): Implements an 80-second pause. This wait is critical to ensure that all internal metrics, especially token usage and final step outputs, are available in the execution history before retrieval.
Code: structure execution data (n8n node): The analytical heart of this n8n template. This custom code node parses the nested execution data, identifies and extracts LLM inputs (promptText), outputs (completionText), token counts, and latency (latencyMs) for every individual model run. It aggregates this data into a usable perModelRuns array.
Split Out / Loop Over Items (n8n nodes): Used together to iterate through the array of structured AI runs (perModelRuns) generated by the previous Code node, ensuring each run is handled as a separate LangFuse generation event.
Code: prepare JSON for LF (n8n node): Transforms the structured run data into the specific JSON payload required by the LangFuse Ingestion API, generating trace-create and generation-create event objects.
Use this essential n8n workflow to accurately track AI Agent token usage (prompt and completion tokens) across various models and log cost estimates in Google Sheets. This n8n templates solution is crucial for cost management.

Use this advanced n8n workflow to track expenses instantly via Telegram (voice or text). It leverages AI agents and Google Sheets for smart financial management and analysis.

Use this n8n workflow to scrape sales data, analyze rep performance using an AI agent (OpenAI, Bright Data), and automatically save detailed metrics to Google Sheets. Find more powerful n8n templates here.

Use this powerful n8n workflow to automatically track competitor pricing on Amazon. This n8n template leverages Apify scraping services to fetch prices and update Google Sheets daily, providing competitive intelligence.

Automate Amazon price tracking using this comprehensive n8n workflow. Scrape product prices, store history in Google Sheets, and send instant Telegram alerts when prices drop using the ScrapeGraphAI n8n node.

Use this robust n8n workflow to track Amazon product prices automatically via the ScrapeOps API. Receive instant email alerts when prices fluctuate, logging all history to Google Sheets. Find more n8n templates for price monitoring.









































