Use this modular n8n workflow template to accurately track and calculate the cost of AI model token consumption (like JinaAI or OpenAI). Logs execution details directly into Google Sheets for financial monitoring.
Download this n8n workflow template and start using it instantly.
Automation Developers seeking reliable cost monitoring for large language model (LLM) usage.
Teams needing to implement granular financial tracking for generative AI services.
Users who leverage n8n for complex AI pipelines and require a dedicated cost tracking module.
Anyone looking for reusable n8n templates for accounting and operations.
Managing the costs associated with frequent AI model interactions is crucial. This specialized n8n workflow template is designed to operate as a modular sub-workflow, automatically retrieving execution data from a parent n8n workflow, extracting token usage, fetching current pricing, calculating the total expense, and persistently logging the data. This solution solves the problem of opaque AI usage costs by providing a transparent audit trail in Google Sheets. Every run of your primary AI n8n workflow can call this specific n8n workflow, ensuring accurate and continuous financial oversight. The core logic relies on using the n8n node dedicated to fetching execution data, providing a robust mechanism for data exchange between workflows.
This n8n workflow starts in one of two ways: either manually via the 'When clicking ‘Test workflow’' n8n trigger for setup, or automatically via the 'When Executed by Another Workflow' n8n trigger, indicating its use as a sub-workflow component.
When Executed by Another Workflow (n8n trigger): The primary n8n trigger for modular use. It activates the n8n workflow when called by another execution, passing relevant usage data.
n8n Get Execution Data (n8n node): A specialized n8n node essential for sub-workflows. It retrieves the data payload and context from the parent n8n workflow execution.
Get AI Usage Data (Code n8n node): Contains custom JavaScript logic to dynamically parse the execution data, isolating metrics like prompttokens and completiontokens required for cost tracking.
Get AI Pricing (HTTP Request n8n node): Responsible for fetching real-time model pricing data necessary for the cost calculation step in this n8n template.
Get Models Price and Add Summary (Code n8n node): Executes the final financial logic, calculating the total dollar cost of the run based on the usage data and external pricing, preparing the output for the Google Sheets n8n node.
Google Sheets (n8n node): The final action. This n8n node appends the calculated usage summary (including model name, tokens, and cost) to a specified Google Sheet row, providing an auditable log of every run of the primary n8n workflow.
Deploy a powerful AI Agent chatbot using this advanced n8n workflow. Integrates LangChain memory, Google Docs for long-term data storage, and Telegram communication for personalized, contextual interactions.

Automate community leaderboard reporting using an n8n workflow. This solution aggregates creator stats, generates insightful reports via OpenAI/Gemini AI agents, and delivers results via Gmail and Google Drive.

Use this powerful n8n workflow to automate logistics management. It leverages an AI n8n node to extract structured data from Gmail shipment requests, calculates geocoding and routes using Open Route API, tracks everything in Google Sheets, and sends professional automated replies. Discover more complex n8n templates for logistics.

Monitor and analyze your entire automation environment using this advanced n8n workflow. Get detailed statistics on every n8n node, workflow tags, active status, and total n8n trigger counts for better DevOps monitoring.

Automate sending personalized welcome direct messages to new Bluesky followers using this powerful n8n workflow. Leverage custom HTTP Requests and the Cron n8n trigger.

Use this powerful n8n workflow to automate audio transcription using OpenAI's Whisper model, generate structured JSON and Markdown summaries, and save all reports directly to Google Drive. This n8n template includes notifications via Gmail and Telegram.








































