n8n-nodes-tracked-openai
v0.2.0
Published
n8n community node: Vendor-agnostic AI Chat Model with automatic usage tracking via Tokora
Readme
Tracked OpenAI Chat Model for n8n
Know exactly what your AI workflows cost. Drop-in replacement for the built-in OpenAI Chat Model node that automatically tracks every token, every call, every workflow — so you always know where your money goes.
The problem
You're running AI workflows in n8n — agents, chains, automations — and your OpenAI bill keeps growing. But you have no idea which workflow, which model, or which customer is driving the cost. You're flying blind.
The solution
Swap the standard OpenAI Chat Model node for this one. Everything works exactly the same, but now every model call is tracked:
- Token usage — prompt, completion, and total tokens per call
- Model — which model was used (captured from the actual API response)
- Workflow context — which workflow, which execution, which node
- Cost attribution — optional document/customer ID to tie costs to specific entities
View it all in your Tokora dashboard — broken down by model, workflow, day, or customer.
Getting started
1. Create your Tokora account
Go to app.tokora.ai and sign up. Create a project and copy your Project API Key.
2. Install the node in n8n
Go to Settings → Community Nodes, enter n8n-nodes-tracked-openai, and click Install.
3. Set up credentials
You need two credentials in n8n:
OpenAI API (built-in — you may already have this):
- API Key: your OpenAI API key
Usage Tracking API (new credential from this package):
- Tracking Endpoint URL: the endpoint shown in your Tokora dashboard
- Project API Key: the key from step 1
4. Use it
The node appears under AI → Language Models → Chat Models.
With AI Agent:
- Remove your existing OpenAI Chat Model
- Add Tracked OpenAI Chat Model
- Select your credentials
- Done — nothing else changes
With LLM Chain:
- Connect Tracked OpenAI Chat Model as the language model
- Select your credentials
- Done
That's it. Your usage data starts appearing in the Tokora dashboard immediately.
What you can track
| Dimension | Example | |-----------|---------| | Model | gpt-4o vs gpt-4o-mini — see where the expensive calls are | | Workflow | "Customer Support Agent" used 2M tokens this month | | Node | Which step in the workflow is burning tokens? | | Document / Customer | Attribute costs to specific customers or projects | | Time | Daily, weekly, monthly breakdowns |
Node parameters
| Parameter | Description | |-----------|-------------| | Model | Any OpenAI-compatible model name (free text — new models work immediately) | | Document ID | Optional. Tie costs to a specific document, customer, or entity. Supports n8n expressions. | | Options | Temperature, Max Tokens, Top P, Frequency Penalty, Presence Penalty, Timeout, Max Retries |
How it works
This node is a thin wrapper around the standard OpenAI Chat Model. It creates the exact same LangChain ChatOpenAI model that the built-in node uses, with one addition: a lightweight callback that fires after each model call to log token usage and workflow context.
- Zero latency impact — logging is fire-and-forget with a 3-second timeout
- Zero workflow risk — if logging fails for any reason, your workflow continues unaffected
- Works everywhere — AI Agent, LLM Chain, or any other node that accepts a language model
- All models supported — model name is free text, so new OpenAI models work on day one
FAQ
Does this slow down my workflows? No. Usage logging happens asynchronously after each model call. If the logging request takes longer than 3 seconds or fails entirely, it's silently dropped and your workflow continues normally.
Does this work with the AI Agent node? Yes. It's a drop-in replacement. Swap it in where you'd normally use the OpenAI Chat Model and everything works the same.
Which models are supported? Any model available through the OpenAI API — GPT-4o, GPT-4o-mini, o1, o3-mini, and any future models. The model field is free text, so you're never waiting for an update.
Can I use this with a custom OpenAI-compatible API? Yes. Set the Base URL in your OpenAI API credential to point to any OpenAI-compatible endpoint (Azure, local models, etc.).
Where is my data stored? Your usage data is stored securely in your Tokora account. Each organization's data is fully isolated — team members only see data for their own organization.
Support
- Dashboard: app.tokora.ai
- Issues: GitHub
License
MIT
