Azure OpenAI Usage Metrics Tracing

Hi. I am using Basic LLM Chain node with Azure OpenAI model.

I want to keep track of the usage metrics (input token, output token). I have an excel node and wanted to save usage metrics in it but I cannot find the token sections on the Basci LLM Chain node. However, I can see the token usage in the model node. Please help me. Thank you!

Hey, what’s up?

So, the thing is that the Basic LLM Chain node kind of wraps the call to the model. That’s why you can’t directly see usage data like input and output tokens there. But there are ways around it.

See if this helps:

  • Use the Azure OpenAI model node directly that one gives you the token usage info in the output

  • If you want to keep using the Basic LLM Chain, you could move the model outside the chain (as a separate node), send the final prompt from the agent to it directly, and grab the token usage from there

  • Another option: inspect the full output from the Basic LLM Chain using a Set or IF node. Depending on the n8n version and the model, the token info might still be there under something like usage

You can send those token values into a spreadsheet using the Spreadsheet File node to keep track of each execution.