Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

AI & ML · Const

tools

tools is the request parameter that gives an OpenAI model access to callable functions and built-in capabilities. The model can choose a tool, while your application performs the operation and returns its output for continued generation.

How it works

The tools parameter is an array of capabilities made available to the model for a request. A model can select a tool, after which the application executes the corresponding code and sends the result in a follow-up request so the model can produce a final response or make additional tool calls.

Syntax

tools: Tool[]

Parameters

NameTypeDescription
toolsarrayArray of tools that the model may call for the request; entries can describe custom functions or supported built-in tools.

Returns

The model response may contain a tool call, a final response, or additional tool calls.

Key points

  • A tool call is a model response indicating that the model wants the application to use one of the supplied capabilities.
  • Declare custom functions in the request's tools parameter.
  • The documented flow has five stages: provide tools, receive a call, execute it, return its output, and receive the model's continuation.
  • For large tool collections, tool search can defer tool definitions until relevant tools are found.

Example: Declare a function tool

import OpenAI from "openai";

const client = new OpenAI();
const tools = [{
  type: "function",
  name: "get_weather",
  description: "Get current temperature for a city.",
  parameters: {
    type: "object",
    properties: { location: { type: "string" } },
    required: ["location"],
    additionalProperties: false
  },
  strict: true
}];

const response = await client.responses.create({
  model: "gpt-5",
  tools,
  input: "What is the weather in Paris?"
});
console.log(response.output);

Supplies a function tool to the Responses API so the model can request application-side weather retrieval.

When to use it

Custom function calling

Expose application-owned operations such as weather lookup, database retrieval, or business actions to a model.

Built-in web search

Offer web search when a response needs current external information.

Deferred tool discovery

Manage a large catalog of callable capabilities by loading less-common tools only when needed.

Interview questions

QWhat is the role of the tools parameter?

The tools array declares capabilities the model may use, including custom functions and built-in tools. With function calling, the application still executes the requested function; the model does not directly run application code.

Follow-up: How does the application complete a function call? It reads the tool call's arguments, runs the function, then makes another model request containing the tool output.

QDescribe the tool-calling flow.

The interaction is multi-step: send tools with the request, receive a tool call, execute it in the application, send the result back, and receive a final response or another call.

Follow-up: Why might another call occur? The model can require multiple tools or successive tool invocations before it has enough information to answer.

QHow is a function tool defined?

A custom function tool uses a schema describing its name, purpose, and parameters. Strict structured parameters help constrain the arguments the model generates.

Follow-up: What should be validated before execution? Validate the tool name and arguments against application-side rules, because the model's request is not itself authorization.

  • function calling
  • tool calling
  • tool_search
  • Responses API
  • web_search
  • file search

Source: Function calling | OpenAI API. Checked 2026-10-15.