Tool calls and parameters
Tool-call sequence
Section titled “Tool-call sequence”Your application sends function definitions. The model returns tool_calls. Your application validates and executes the requested function, returns a role: tool result, and asks the model to continue. The model does not automatically run code on your server.
Define a read-only function
Section titled “Define a read-only function”Choose a text model with tool support for this Chat Completions structure:
{ "model":"gpt-5.6-sol", "messages":[{"role":"user","content":"Check order DEMO-001."}], "tools":[{ "type":"function", "function":{ "name":"get_order_status", "description":"Read an order status.", "parameters":{ "type":"object", "properties":{"order_id":{"type":"string"}}, "required":["order_id"] } } }], "tool_choice":"auto"}Return the result
Section titled “Return the result”Retain the assistant’s complete tool-call message, then add a result with the same tool_call_id. Replace the placeholder with the returned ID:
{"role":"tool","tool_call_id":"ACTUAL_TOOL_CALL_ID","content":"{\"status\":\"shipped\"}"}Sending a result without its preceding assistant message can cause a rejection. For streaming calls, wait until the function name and arguments have finished arriving.
Client capability settings
Section titled “Client capability settings”Options such as tool use, image input and thinking mode in WorkBuddy or OpenCode must match the selected model and route. A plain-text answer does not verify those other features. Turn optional capabilities off for a first connection test, then enable and verify them individually.
Execution controls
Section titled “Execution controls”Validate names, parameter types and access permissions. Your application should implement confirmation and audit controls for operations such as payments, deletion or sending messages. Do not run model-generated text directly as a shell command.
Common errors
Section titled “Common errors”- Missing
tool_calls: the model may answer directly, or the route may not support the parameter. - Invalid tool message: check message order and matching IDs.
- Incomplete JSON: wait for all streamed argument fragments.
Structured output, parallel tools and built-in search are separate capabilities; do not enable them all by assumption.
