How to access tokenUsage from a sub-node Model within an AI Agent?

Hi everyone,

I’m using the AI Agent node with the DeepSeek Chat Model (as a sub-node).

My issue is that I need to get the tokenUsage data for cost tracking. When I click on the Model sub-node and check its own output, the information is there (prompt, completion, and total tokens). However, the AI Agent node does not include this information in its output, even though I have the “Return Intermediate Steps” option enabled.

How can I access these specific values from the model to use them in the next nodes of my workflow?

Thanks!

  • n8n version: 2.16.1
  • Database (default: SQLite):
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Docker
  • Operating system: Ubuntu

Hi @emiliano2025, the token usage from the chat model is not directly accessible in the AI agent, the workaround is this:

good day @emiliano2025
I would avoid using the AI Agent final output as the control point for billing or audit data. Even if the model sub-node shows token usage internally, the Agent output is mainly the orchestration result, not a guaranteed cost-reporting contract. For cost tracking, I’d design the workflow with a separate measurable model step or branch where the usage metadata can be validated before continuing, then pass the result forward to the rest of the flow. That gives you a more reliable control point without depending on the Agent response format.