function_call output with the tool name and arguments for you to execute.
Basic Tool Calling
Tool Call Response
When the model decides to call a tool, the response includes afunction_call output:
Tool Choice Options
Control how the model uses tools with thetool_choice parameter:
| Value | Behavior |
|---|---|
"auto" | The model decides whether to call a tool |
"required" | The model must call at least one tool |
"none" | The model cannot call any tools |
Request Parameters
Array of tool definitions. Each tool object contains:
type: Always"function"name: The function name the model will usedescription: Describes when and how to use this toolparameters: JSON Schema object defining the function’s parameters
Controls tool usage. Set to
"auto" (default), "required", or "none". To force a specific tool, pass {"type": "function", "name": "tool_name"}.When
true, the model may call multiple tools simultaneously. Default: trueUse Case: Coding Agent
A coding agent gives the model a set of file system and terminal tools and runs an agentic loop — calling the API, executing whatever tools the model requests, and feeding the results back — until the model returns a plain text response with no further tool calls. Define seven SWE tools:Python
Python
The agent loop continues until the model returns a response with no
function_call outputs. Always set a max_iterations guard to prevent runaway loops."Read main.py and tell me what the entry point function does.""Write a file /tmp/utils.py with a helper function for parsing JSON, then read it back to confirm.""Search app.py for all lines containing 'TODO' and list their line numbers.""Edit config.py: replace DEBUG = False with DEBUG = True, then verify the change.""Run python3 tests/test_api.py and report any failures.""List the project root and find all TypeScript files under src/."