Function calling is the part of the OpenAI contract most likely to break when the model behind the endpoint is not OpenAI's, and the breakage is rarely a clean error. Arguments arrive as fragments, content is null on the turn that emits a call, finish_reason becomes tool_calls instead of stop , and JSON Schema mode may not exist at all. This article walks a complete, runnable tool loop, then the streaming variant that accumulates fragments by index. It covers the three failures that account for nearly every broken integration, plus what changes when the endpoint in front of the model is a gateway that bills tool schemas as input tokens on every turn.
The shape of a tool turn
The model never runs your function. It returns a message whose content is null and whose tool_calls array holds one or more calls, each with an id and a JSON-encoded arguments string, and it sets finish_reason to tool_calls .β¦