Skip to main content

Module openai

Module openai 

Source
Expand description

OpenAI Chat Completions response shapes.

The spec (https://developers.openai.com/api/docs/guides/function-calling) puts tool calls in message.tool_calls[] with function.arguments as a JSON string and a mandatory id. The broken variants below reproduce deviations observed on OpenAI-compatible stacks in the wild.

Functions§

text_response
Assistant text response (finish_reason: "stop").
tool_call
Spec-conformant tool call: string arguments, id present.
tool_call_malformed_args
Broken variant: arguments is not valid JSON. Clients must surface a recoverable error rather than dying (a model that emits one malformed payload can be asked to retry).
tool_call_object_args_no_id
Broken-but-observed variant: arguments is a JSON object and the id field is absent. Emitted through OpenAI-compatible endpoints by Ollama’s native /api/chat shape (which has no id at all — see ollama docs/api.md), by Gemini’s functionCall.args, and by some vLLM tool-call parsers.
tool_calls_response
Assistant tool-calls response (finish_reason: "tool_calls", content: null).