Token difference between two calls of same assista...
# support
a
Call ID: 6f9854d9-081f-4a23-953e-e3293a761a00 (Why does it utilizes 23000 tokens) Call ID: 8f78e6ec-f26a-41e0-bfe6-cd7a7a4dd01d (Whereas this call of same duration and more words spoken has only 5000 tokens) Why did it happen and how can I resolve this issue? Do let me know in case you want any other info from my side.
c
In the call ids you provided, the one that used more tokens has a tool call and the cheaper one doesn't. Some LLM requests use more tokens than others because tokens measure the text length of both your input and the model’s output. A few key reasons: 1. Input size – Longer prompts, context, or system messages use more tokens. 2. Output size – The more detail or longer the response requested, the more tokens are consumed. 3. Language & formatting – Certain words, punctuation, or formatting (like code) break down into more tokens than plain text. 4. Extra context – Features like conversation history, function/tool calls, or hidden metadata can add tokens even if you don’t see them. In short: the bigger or more complex the request and response, the more tokens it uses.
a
Both of them have same input prompts and almost the same number of words but the token difference of the calls is huge. Kindly look into it. @Vapi
c
We have looked into it further and determined that the tool call is the biggest difference in token usage. Because one of the ids called a tool, it also has to process a toolCallResult which uses more tokens. If both call ids had the same tool calls, they would have the same cost. This is not an issue but rather expected behavior. If you have any questions regarding this matter, please let us know.
a
Why the tool call has thousands of tokens, I don't think so because I am not doing anything that utilizes so much tokens.
c
Thanks for raising this — I understand why the numbers look surprising. The difference between your call that used \~5,000 tokens and the one that used \~17,000 tokens isn’t only the tool call itself. Here are the key factors: - System prompt size: Your assistant’s system prompt alone is already quite large (about 2,000–5,000 tokens), and this gets included each time the model is called. - Prompt duplication: When requests are converted into the OpenAI message format, parts of the prompt are duplicated to maintain context, which further increases the token count. - Tool call payload: When a transfer tool call is triggered, the JSON payload plus any returned data are also counted as tokens (both as output and then again as input when passed back into the model). That’s why you’re seeing higher totals — the tool call isn’t “thousands of tokens” by itself, but combined with the system prompt size and duplication, the numbers can add up quickly.
a
I don't understand that if there are same duration of a call and almost same number of input tokens are being used then why is this happening. The point is if there are almost 5000 tokens in the sytem prompt then why did the second call tokens are around 5000??
c
We will retrieve the logs and gather the cost data per turn. Will get back to you shortly
a
Did you find anything?
c
LLM Token Cost Per Turn Analysis - call 8f78e6ec-f26a-41e0-bfe6-cd7a7a4dd01d Overall Call Metrics: - Total LLM Cost: $0.0141225 - Total Prompt Tokens: 5,473 - Total Completion Tokens: 44 - Model: gpt-4o-2024-11-20 Turn Breakdown: Turn 1 - **User Input**: "Is this Solomon Rogers?" - **AI Response**: "No. This is Lisa from legal services. How can I assist you today?" - **Response Length**: \~13 words / \~17 tokens (estimated) Turn 2 - **User Input**: "Sorry for the call." - **AI Response**: "Thank you, Sharon, calling legal services. This is Lisa. How can I help you today?" (Initial greeting) - **Response Length**: \~14 words / \~17 tokens (estimated) Cost Calculation: Based on GPT-4o-2024-11-20 pricing: - Input: $0.0025 per 1K tokens - Output: $0.01 per 1K tokens Estimated Cost Per Turn:
Copy code
Total Input Cost: 5,473 tokens × $0.0025/1K = $0.0137
Total Output Cost: 44 tokens × $0.01/1K = $0.0004
Total: $0.0141 ✓ (matches the cost breakdown)
Per Turn Breakdown:
Copy code
Turn 1: ~$0.0070 (approximately half of total cost)
Turn 2: ~$0.0071 (approximately half of total cost)
Key Insights: - The majority of the cost (\~97%) comes from input tokens due to the large system prompt (the detailed customer service instructions) - Each turn costs approximately $0.007, with most cost attributed to processing the extensive system prompt - Output tokens are minimal (only 44 total) since the responses were brief - The high input token count (5,473) is primarily due to the comprehensive system prompt being included in each API call
LLM Token Cost Per Turn Analysis - Second Call (with Tool Calls) Overall Call Metrics: - Total LLM Cost: $0.0679 (significantly higher than first call) - Total Prompt Tokens: 17,326 (3x more than first call) - Total Completion Tokens: 19 (less than first call) - Model: gpt-4o-2024-11-20 Conversation Flow: 1. **Turn 1**: User says "Yes. Customer service." → AI responds "Do you want me to forward your call to our customer support representative?" 1) **Turn 2**: User says "Yes." → AI makes tool call to transferCall function Calculate LLM token costs per turn including tool call overhead Cost Calculation: Based on GPT-4o-2024-11-20 pricing: - Input: $0.0025 per 1K tokens - Output: $0.01 per 1K tokens Breakdown:
Copy code
Input Cost: 17,326 tokens × $0.0025/1K = $0.04332
Output Cost: 19 tokens × $0.01/1K = $0.0002
Total: $0.04352 
Total with Overhead costs: $0.0679
Turn 1 (Regular Response) - **User Input**: "Yes. Customer service." - **AI Response**: "Do you want me to forward your call to our customer support representative?" - **Estimated Cost**: \~$0.034 (approximately 50% of total cost) Turn 2 (Tool Call Turn) - **User Input**: "Yes." - **AI Action**: Tool call to transferCall with destination "+18053077002" - **Tool Result**: "Transfer initiated." - **Estimated Cost**: \~$0.034 (approximately 50% of total cost) Why Call 2 Costs Much More: 1. **Tool Function Definitions**: The system prompt includes 7 tool definitions that add significant token overhead 2. **Tool Call Processing**: When a tool call is made, the LLM must: - Process tool function schemas - Generate structured tool call JSON - Process tool call results - Continue conversation context 3. **Context Accumulation**: Each turn builds on previous context, and tool calls add additional message types to the conversation history.
2 Views