Support custom HTTP headers in the AI Agent (Chat Models) node

The idea is:

Add a Custom headers parameter to the AI Agent → Chat Models sub-node so users can pass arbitrary HTTP headers (name / value, supports expressions) to the underlying request.


My use case:

I run several n8n workflows against OpenRouter.

OpenRouter lets you group usage in their dashboard and billing by sending two optional headers:

Header Purpose
HTTP-Referer Identifies the calling app / workflow for cost tracking
X-Title Human-readable label shown in the dashboard

Without header support every call made by the Agent node gets lumped together, so it’s impossible to see which workflow burned through the token budget. Having per-workflow headers would fix that.

(OpenRouter header docs: see “HTTP-Referer” and “X-Title” here) → https://openrouter.ai/docs/api-reference/overview#headers


I think it would be beneficial to add this because:

  • Granular cost & usage accounting for anyone using the Agent node with OpenRouter (or any future provider that supports custom headers).
  • Mirrors the flexibility already available in the HTTP Request node—so the behaviour is consistent across n8n.

Any resources to support this?


Are you willing to work on this?

I’m not familiar with the n8n codebase, but if someone points me at the relevant files I can try a PR.

1 Like

Good one! This will be helpful

2 Likes

is there a resolution or new functionality to this issue ?

i’d love to have this new feature i’ve got exactly the same issue right now and this would help me a lot ! :grinning_face_with_smiling_eyes:

+1, this is still a real blocker in production use cases.

We are using n8n AI Agent nodes with OpenRouter in a multi-tenant environment.
LLM providers already expose detailed activity exports (CSV) with request-level metadata,
but without the ability to attach custom headers or request identifiers from the AI Agent node,
it is impossible to reliably correlate LLM usage with:

  • workflow executions
  • end users
  • tenants / accounts

Injecting correlation IDs into the prompt works only as a workaround and is not suitable for:

  • cost attribution
  • auditing
  • billing
  • enterprise observability

Allowing optional custom headers (expression-based, advanced section) would fully solve this
in a provider-agnostic way and unlock much better AI observability in n8n.

I would also love to see this. At the moment I’m having to use different API keys to do cost attribution which is messy - this would be much neater.

Also came here trying to find how to add “application-axis” for cost tracking when working through OpenRouter.

It would be useful when troubleshooting/optimizing/refactoring separate AI nodes when there’re multiple AI nodes in the same workflow (or in a group of n8n workflows, which constitute some bigger logic/process workflow). For example, if I optimize one AI node and what to see the impact on this node’s cost. To do this currently, it would require to assign different API keys per each AI node, which is tiresome when there’re multiple AI nodes and probably an overkill. It becomes even less convenient when we have multiple logical/process workflows - OpenRouter usage dashboard will list them all, which won’t allow to see cumulative impact of a single workflow. The latter can be solved by having OpenRouter’s Workspaces per process workflow, but in many cases it’s also an overkill and can reduce observability.

However, I’m not sure that adding ability to specify custom headers is the way to solve the problem of passing application name to OpenRouter. When there’re multiple AI nodes in a workflow (or in a group of interconnected workflows), specifying headers in all AI nodes would quickly turn to a mess. Maybe, the more appropriate solution is to add a dedicated optional “application name” property either to the “OpenRouter Model” node, or to the “OpenRouter” credential type.

Seconded - and @dmitrillobanov’s point about multiple AI nodes is valid. A practical middle ground: support custom headers at the credential level rather than per-node. If you can set X-Title: my-workflow on the OpenAI credential config itself, it propagates to every node using that credential without per-node config. For multi-node cost tracking, you’d just create separate credentials per workflow and let OpenRouter aggregate by credential/header.

I also would LOVE to see this added. Love you n8n! Thank you!