Retrieving Token Usage from Summarization Chain

Describe the problem/error/question

I’m unable to retrieve Input, Completion Token usage from the llm model used in the Summarization Chain node

What is the error message (if any)?

When trying to reference the model’s output direct (which includes the token usage) I receive this error or empty references
image

Please share your workflow

Share the output returned by the last node

Ideally I should be able to log how much tokens I’ve used :face_with_raised_eyebrow:

Information on your n8n setup

  • n8n version: 1.27.2
  • Database (default: SQLite): n8n Cloud
  • n8n EXECUTIONS_PROCESS setting (default: own, main): default
  • Running n8n via (Docker, npm, n8n cloud, desktop app): cloud
  • Operating system: Windows (my own) - Cloud I guess

Hi @manueltnc :wave: I got some confirmation from @oleg here - unfortunately it’s not possible to reference the execution data of sub-nodes at this point. There isn’t a simple way to do this currently :see_no_evil:

It’s possible to use n8n node to retrieve full execution data which also contains the sub-nodes data like tokenUsage, but that cannot be done in the same execution(as you need the executionId to retrieve already finished execution).

I’m going to move this over to the feature request forum for you, and hopefully that workaround will help you in the meantime!

Quick edit - this wouldn’t be necessarily a “pretty” way to do it, but this should do what you need for past executions: