LLMMetrics extends LLMTokens with additional context about an LLM call.

Properties

PropertyTypeDescription
completion_tokensnumberTokens produced by the model
prompt_tokensnumberTokens from the prompt
total_tokensnumberTotal tokens used
providerLLMProviderLLM provider name
modelstringModel identifier
function_namestring[]Functions executed, if any
durationnumberInference time in milliseconds
finish_reasonstringLLM finish reason
source_node_typestringSource node type in the graph

Example

Python
from xpander_sdk import LLMMetrics, LLMProvider

metrics = LLMMetrics(provider=LLMProvider.OPEN_AI, model="gpt-4.1")
print(metrics.total_tokens)

For all metric fields, consult the xpander-sdk docs.