slickVik
02/16/2025, 9:27 PMslickVik
02/16/2025, 9:27 PMslickVik
02/16/2025, 9:27 PMVapi
02/17/2025, 3:52 PMslickVik
02/17/2025, 3:58 PMslickVik
02/17/2025, 3:58 PMslickVik
02/17/2025, 4:36 PMslickVik
02/17/2025, 4:37 PMslickVik
02/17/2025, 4:38 PMslickVik
02/17/2025, 8:05 PMVapi Ticket Bot
02/17/2025, 10:03 PMslickVik
02/17/2025, 11:30 PMslickVik
02/17/2025, 11:51 PMslickVik
02/18/2025, 5:16 PMslickVik
02/18/2025, 5:17 PMslickVik
02/18/2025, 5:17 PMShubham Bajaj
02/19/2025, 10:26 AMShubham Bajaj
02/19/2025, 10:33 AMlogs
🔵 21:34:50:468 Couldn't Complete Completion Request (#1, provider: custom-llm, model: gpt-4o, region: undefined, credential: true) Error: {
"message": "chunk.choices is not iterable",
The error "**chunk.choices is not iterable**" occurs because the custom LLM response doesn't match the expected OpenAI-compatible format. We expect the response to follow the OpenAI streaming format, which should include a choices array property that is iterable. When this property is missing or not an array, the error occurs.
[expected]
{
choices: [
{
delta: {
content?: string,
tool_calls?: Array<...>,
},
finish_reason?: string
}
]
}
Shubham Bajaj
02/19/2025, 10:33 AMShubham Bajaj
02/19/2025, 10:33 AMslickVik
02/19/2025, 2:10 PM{
"id": "chatcmpl-B2PihK9m7Yag0aBdJdhWyG36Rpa93",
"object": "chat.completion",
"created": 1739915223,
"model": "gpt-4o-2024-08-06",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": null,
"tool_calls": [
{
"id": "call_dTmZivlvze6Z7SGqcAxUEftq",
"type": "function",
"function": {
"name": "transferCall",
"arguments": "{\"destination\":\"+14045633811\"}"
}
}
],
"refusal": null
},
"logprobs": null,
"finish_reason": "tool_calls"
}
],
"usage": {
"prompt_tokens": 1805,
"completion_tokens": 18,
"total_tokens": 1823,
"prompt_tokens_details": {
"cached_tokens": 1792,
"audio_tokens": 0
},
"completion_tokens_details": {
"reasoning_tokens": 0,
"audio_tokens": 0,
"accepted_prediction_tokens": 0,
"rejected_prediction_tokens": 0
}
},
"service_tier": "default",
"system_fingerprint": "fp_523b9b6e5f"
}
slickVik
02/19/2025, 2:11 PMslickVik
02/19/2025, 2:11 PMslickVik
02/19/2025, 2:12 PMVapi
02/21/2025, 4:54 AM// First chunk - Start the stream and set tool call ID
{
choices: [{
delta: {
tool_calls: [{
index: 0,
id: "call_dTmZivlvze6Z7SGqcAxUEftq",
type: "function",
function: {
name: "transferCall"
}
}]
}
}]
}
// Second chunk - Send the arguments
{
choices: [{
delta: {
tool_calls: [{
index: 0,
function: {
arguments: "{\"destination\":\"+14045633811\"}"
}
}]
}
}]
}
// Final chunk - End the stream
{
choices: [{
delta: {},
finish_reason: "tool_calls"
}]
}
This is the correct format because:The streaming handler processes chunks incrementally.
**TLDR: I**nstead of sending the complete response, you need to stream it in chunks.
The error "tool type not set" occurs because the handler expects the type to be set in the first chunk before processing arguments.slickVik
03/02/2025, 8:16 PMVapi
03/04/2025, 4:55 PM