How to get token usage from OpenAI Assistant node in n8n (self-hosted)?

I’m using self-hosted n8n and the OpenAI node with Resource = Assistant (using an existing Assistant ID).
The workflow is working correctly and the assistant returns strict JSON output.

However, I need to track token usage (prompt / completion / total tokens) for each execution, mainly for monitoring and billing purposes.

Current situation

  • The OpenAI Assistant node output only returns the assistant response and thread_id

  • Token usage is not available in the node output

  • I have multiple OpenAI nodes in the same workflow

  • Replacing OpenAI nodes with HTTP Request nodes (Assistants API) works, but makes the workflow much more complex and harder to maintain

What I’m looking for

  • Is there a supported way to access token usage from the OpenAI node (especially Assistant resource)?

  • Is token usage stored internally in execution data and can it be accessed reliably?

  • Any recommended best practice from n8n for tracking OpenAI token usage without replacing the OpenAI node?

Environment

  • n8n: self-hosted

  • OpenAI node: Assistant resource

  • Output format: strict JSON

Any guidance or recommended approach from the n8n team would be really helpful.

Thanks!

yeah the OpenAI Assistant node doesn’t expose token usage in its output unfortunately - it’s a known gap.

your best bet is actually that workflow template someone made: https://n8n.io/workflows/2695-obtain-token-usage-from-ai-agents (one of your search results mentions it). it shows how to extract token usage from AI agent nodes and log it to a spreadsheet with cost estimates.

if you need it specifically for the Assistant resource and that template doesn’t cover it, you might have to go the HTTP Request route or check if the execution data has it buried somewhere (you could inspect the full execution JSON via the n8n API). not ideal i know but token tracking isn’t built into most AI nodes yet.

lmk if the template works for your setup