Hi Team, is it possible to get the Total Tokens based on a Trace ID using REST API or any of the SDKs? Any help is appreciated. Thanks.
It seems likely that retrieving the total token count based on a Trace ID might not be directly supported via a REST API or SDK in Phoenix. However, you can query token counts using the GraphQL API. The Project class in the Phoenix API provides fields like token_count_total, token_count_prompt, and token_count_completion which can be queried for a specific time range or filter condition, but it doesn't explicitly mention querying by Trace ID (source).Would you like more detail on how to use the GraphQL API to potentially achieve this? Sources:
- Project.py
馃挕聽Hint: Mention RunLLM in the thread for followups.
Hi Dustin N., thanks for checking in. Yeah, I was able to query on the GraphQL playground with the following query to get the required details based on the TraceID. I was also able to confirm the same using the API key:
query MyQuery {
projects {
edges {
node {
trace(traceId: "4117e78a41be37dadfafbb6359036123") {
traceId
projectId
spans {
edges {
node {
tokenCountTotal
latencyMs
endTime
startTime
statusCode
statusMessage
tokenCountPrompt
tokenCountCompletion
}
}
}
}
}
}
}
}Thanks a lot for the help. Really appreciate it.
great! I'm glad
