OpenAI Function Calling (tool calling) is a mechanism provided by the OpenAI platform that enables large language models to connect to external data and systems. When generating a response, the model can determine whether it needs to call tools predefined by the developer, thereby obtaining information beyond its training data or performing specific operations.
Key capabilities:
- Function tools: Define functions using JSON Schema, including parameter types, enums, descriptions, nested objects, etc., based on which the model can generate call requests.
- Custom tools: Tools that support free-text input and output.
- Built-in tools: The platform also provides built-in tools such as web search, code execution, and MCP server access.
- Tool search: When there are many functions or the schema is large, tool_search can be combined to lazily load infrequently used tools; only supported by gpt-5.4 and later models.
- Namespaces: Related tools can be grouped by domain (such as crm, billing, shipping).
Usage: Tool calling is a multi-step conversation flow:
- Send a request to the model and provide the list of callable tools in the tools parameter.
- The model returns a tool call request containing the tool name and arguments.
- The application executes code using the input provided by the model.
- Pass the tool output (structured JSON, plain text, images, or file content) back to the model along with the original request and the tool call.
- The model generates the final response, or continues to make more tool calls.
This guide provides integration examples for the Responses API and Chat Completions. For Agents API sessions, you can use Functions to register functions and handle session operation requests. GPT-6 Astra and GPT-6.1 Sol require the Responses API for tool calling; the Chat Completions example uses GPT-5.6 Terra with reasoning disabled. For reasoning models (such as GPT-5 or o4-mini), the reasoning items returned in the model response need to be passed back along with the tool call output.
Applicable scenarios:
- Obtaining real-time data, such as querying weather or account details.
- Performing operations, such as initiating refunds or bookings.
- Connecting to external systems or APIs to extend model capabilities.
Limitations:
- Tool calling requires the application to implement the execution logic; the model only generates call requests.
- Some advanced features (such as tool_search) have modelversion requirements.
- Different models have different API requirements; refer to the migration guide.
- Specific information such as fees and pricing is not yet provided.