← Blog
n8n automation cost-tracking June 11, 2026 5 min read

How to Track OpenAI Costs in n8n Workflows (No Code Changes)

Network of connected automation nodes representing n8n workflow cost tracking

TL;DR: n8n's OpenAI and HTTP Request nodes let you override the base URL. Point them at https://tokonomics.ca/proxy/openai with your Tokonomics API key, and every AI call gets metered — cost per workflow, per model, per day. No code, no custom nodes, 2-minute setup.


The Problem: n8n Doesn't Track AI Costs

n8n is powerful for automation, but it has a blind spot: zero visibility into what your AI nodes cost.

You can see that a workflow ran 4,200 times this month. You cannot see that those runs consumed $380 in GPT-4o tokens. You definitely can't see that 60% of that spend came from one workflow with a bloated system prompt.

According to the 2024 State of AI in Automation report, AI nodes are the fastest-growing category in n8n. More AI nodes means more token spend — and most n8n users have no idea what they're paying per workflow.


How It Works: One URL Change

Tokonomics is a proxy that sits between n8n and your LLM provider. Instead of n8n calling OpenAI directly, it calls Tokonomics, which forwards the request to OpenAI, records the token usage and cost, and streams the response back.

The entire integration is one configuration change. No custom nodes. No code. No npm packages.

Before:  n8n → api.openai.com → response
After:   n8n → tokonomics.ca/proxy/openai → api.openai.com → response

The response is identical. Your workflows don't change. But now every call is metered.


Step-by-Step: OpenAI Node in n8n

Option 1: HTTP Request Node (Recommended)

The HTTP Request node gives you full control over the base URL:

  1. Add an HTTP Request node to your workflow
  2. Set Method to POST
  3. Set URL to https://tokonomics.ca/proxy/openai/chat/completions
  4. Under Authentication, select Generic Credential TypeHeader Auth
  5. Set header name: Authorization, value: Bearer mk_your_tokonomics_key
  6. Under Body, select JSON and paste your request:
{
  "model": "gpt-4o-mini",
  "messages": [
    {
      "role": "system",
      "content": "You are a helpful assistant."
    },
    {
      "role": "user",
      "content": "{{ $json.input_text }}"
    }
  ]
}
  1. (Optional) Add a header X-Feature-Name with the workflow name (e.g., lead-scoring) for per-workflow cost tracking

That's it. Every call through this node is now metered in your Tokonomics dashboard.

Option 2: OpenAI Node with Custom Base URL

If you're using n8n's built-in OpenAI node:

  1. Go to Settings → Credentials in n8n
  2. Create a new OpenAI API credential
  3. Set the API Key to your Tokonomics key: mk_your_tokonomics_key
  4. Set the Base URL to: https://tokonomics.ca/proxy/openai
  5. Use this credential in your OpenAI nodes

Every node using this credential now routes through the proxy.


Step-by-Step: Anthropic / Claude in n8n

For Claude models, use the HTTP Request node:

  1. URL: https://tokonomics.ca/proxy/anthropic/messages
  2. Headers:
    • Authorization: Bearer mk_your_tokonomics_key
    • Content-Type: application/json
  3. Body:
{
  "model": "claude-sonnet-4-6",
  "max_tokens": 1024,
  "messages": [
    {
      "role": "user",
      "content": "{{ $json.input_text }}"
    }
  ]
}

The same pattern works for DeepSeek (/proxy/deepseek/chat/completions), Gemini, Mistral, and any other supported provider.


Tagging Workflows for Cost Attribution

The real power comes from tagging. Add a custom header to each HTTP Request node:

X-Feature-Name: lead-scoring

Or for more detail:

X-Metering-Tags: {"workflow":"lead-scoring","client":"acme-corp","env":"production"}

These headers are stripped before reaching OpenAI — your provider never sees them. But in your Tokonomics dashboard, you can now filter costs by workflow, by client, or by environment.

For agencies running n8n workflows for multiple clients, this is how you get per-client cost isolation without separate API keys.


What You See in the Dashboard

Once connected, your Tokonomics dashboard shows:

Tokonomics dashboard showing budget gauge, daily spend chart, model breakdown, and recent API calls


Real Example: Catching a $200/Month Waste

A solo developer running 12 n8n workflows connected Tokonomics and discovered:

Total savings: $177/month — found in 10 minutes of looking at the dashboard.


n8n Cloud vs Self-Hosted: Both Work

Tokonomics works with both n8n Cloud and self-hosted n8n. The proxy is a URL — it doesn't matter where n8n runs. As long as n8n can make HTTPS requests, it can route through the proxy.

For self-hosted n8n behind a firewall, the only requirement is outbound HTTPS access to tokonomics.ca.


Frequently Asked Questions

Does the proxy add latency to my workflows?

The proxy adds approximately 30ms of overhead per call (see our benchmark). For LLM calls that typically take 500ms-3,000ms, this is unnoticeable and well within normal network variance.

Can I use this with n8n's AI Agent node?

Yes. The AI Agent node uses the same OpenAI credentials. If you set the credential's base URL to Tokonomics, all calls from the AI Agent node are metered automatically.

What if I use multiple AI providers in one workflow?

Each provider gets its own proxy URL (/proxy/openai, /proxy/anthropic, /proxy/deepseek). You can mix providers in a single workflow — each call is metered separately, and the dashboard shows a unified cost view across all providers.

Is there a free tier?

Yes. The Free plan includes 100 API calls/month — enough to test the integration and see the dashboard. The Pro plan at $49/month gives unlimited calls.


Get Started in 2 Minutes

  1. Create a free Tokonomics account
  2. Copy your API key from the dashboard
  3. Update your n8n HTTP Request node URL to https://tokonomics.ca/proxy/openai/chat/completions
  4. Replace the Authorization header with your Tokonomics key
  5. Run the workflow once — check the dashboard

Your AI costs are now visible. Set a budget alert and never get surprised by an invoice again.


All sources retrieved June 2026. Pricing: GPT-4o at $2.50/1M input tokens (OpenAI Pricing), GPT-4o-mini at $0.15/1M input tokens.

About the author
Founder & CTO at Tokonomics. Built the proxy after a $47,000 LLM invoice blindsided his team. Tracks LLM pricing weekly across 9 providers.
Connect on LinkedIn →
← Back to Blog