Use tools like remote MCP servers or web search to extend the model's capabilities.
When generating model responses or building agents, you can extend capabilities using built‑in tools, function calling, Programmatic Tool Calling, tool search, and remote MCP servers. These enable the model to search the web, retrieve from your files, load deferred tool definitions at runtime, call your own functions, compose tool calls in JavaScript, or access third‑party services. Only gpt-5.4 and later models support tool_search.
Web search
Include web search results for the model response
JavaScript
1
2
3
4
5
6
7
8
9
10import OpenAI from"openai";constclient=newOpenAI();constresponse=await client.responses.create({ model: "gpt-5.6", tools: [{ type: "web_search" }], input: "What was a positive news story from today?",});console.log(response.output_text);
1
2
3
4
5
6
7
8
9
10
11from openai import OpenAIclient = OpenAI()response = client.responses.create( model="gpt-5.6", tools=[{"type": "web_search"}], input="What was a positive news story from today?",)print(response.output_text)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15using OpenAI.Responses;#pragma warning disable OPENAI001string key = Environment.GetEnvironmentVariable("OPENAI_API_KEY")!;ResponsesClient client = new(key);CreateResponseOptions options = new() { Model = "gpt-5.6" };options.Tools.Add(ResponseTool.CreateWebSearchTool());options.InputItems.Add( ResponseItem.CreateUserMessageItem("What was a positive news story from today?"));ResponseResult response = await client.CreateResponseAsync(options);Console.WriteLine(response.GetOutputText());
1
2
3
4
5
6
7
8
9
10
11require "openai"openai = OpenAI::Client.newresponse = openai.responses.create( model: "gpt-5.6", tools: [{type: "web_search"}], input: "What was a positive news story from today?")puts(response.output_text)
1
2
3
4
5
6
7
8curl "https://api.openai.com/v1/responses" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $OPENAI_API_KEY" \ -d '{ "model": "gpt-5.6", "tools": [{"type": "web_search"}], "input": "what was a positive news story from today?"}'
1
2
3
4
5
6
7
8openai responses create \ --model gpt-5.6 \ --raw-output \ --transform 'output.#(type=="message").content.0.text' <<'YAML'tools: - type: web_searchinput: What was a positive news story from today?YAML
File search
Search your files in a response
JavaScript
1
2
3
4
5
6
7
8
9
10
11
12
13
14import OpenAI from"openai";constopenai=newOpenAI();constresponse=await openai.responses.create({ model: "gpt-5.6", input: "What is deep research by OpenAI?", tools: [ { type: "file_search", vector_store_ids: ["<vector_store_id>"], }, ],});console.log(response);
1
2
3
4
5
6
7
8
9
10from openai import OpenAIclient = OpenAI()response = client.responses.create( model="gpt-5.6", input="What is deep research by OpenAI?", tools=[{"type": "file_search", "vector_store_ids": ["<vector_store_id>"]}],)print(response)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17using OpenAI.Responses;#pragma warning disable OPENAI001string key = Environment.GetEnvironmentVariable("OPENAI_API_KEY")!;ResponsesClient client = new(key);CreateResponseOptions options = new() { Model = "gpt-5.6" };options.Tools.Add( ResponseTool.CreateFileSearchTool(["<vector_store_id>"]));options.InputItems.Add( ResponseItem.CreateUserMessageItem("What is deep research by OpenAI?"));ResponseResult response = await client.CreateResponseAsync(options);Console.WriteLine(response.GetOutputText());
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16require "openai"openai = OpenAI::Client.newresponse = openai.responses.create( model: "gpt-5.6", input: "What is deep research by OpenAI?", tools: [ { type: "file_search", vector_store_ids: ["<vector_store_id>"] } ])puts(response)
When making a request to generate a model response, you usually enable tool access by specifying configurations in the tools parameter. Each tool has its own unique configuration requirements—see the Available tools section for detailed instructions.
Based on the provided prompt, the model automatically decides whether to use a configured tool. For instance, if your prompt requests information beyond the model’s training cutoff date and web search is enabled, the model will typically invoke the web search tool to retrieve relevant, up-to-date information.
Some advanced workflows can also load more tool definitions during the interaction. For example, tool search can defer function definitions until the model decides they’re needed.
You can explicitly control or guide this behavior by setting the tool_choice parameter in the API request.
Usage in the Agents SDK
In the Agents SDK, the tool semantics stay the same, but the wiring moves into the agent definition and workflow design rather than a single Responses API request.
Attach hosted tools, function tools, or hosted MCP tools directly on the agent when one specialist should call them itself.
Expose a specialist as a tool when a manager should stay in control of the user-facing reply.
Keep shell, apply patch, and computer-use harnesses in your runtime even when the SDK models the tool decision.
Wrap local logic as a function tool
TypeScript
1
2
3
4
5
6
7
8
9
10
11import { tool } from"@openai/agents";import { z } from"zod";constgetWeatherTool=tool({ name: "get_weather", description: "Get the weather for a given city.", parameters: z.object({ city: z.string() }),asyncexecute({ city }) {return`The weather in ${city} is sunny.`; },});
1
2
3
4
5
6
7from agents import function_tool@function_tooldef get_weather(city: str) -> str: """Get the weather for a given city.""" return f"The weather in {city} is sunny."
Expose a specialist as a tool
TypeScript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16import { Agent } from"@openai/agents";constsummarizer=newAgent({ name: "Summarizer", instructions: "Generate a concise summary of the supplied text.",});constmainAgent=newAgent({ name: "Research assistant", tools: [ summarizer.asTool({ toolName: "summarize_text", toolDescription: "Generate a concise summary of the supplied text.", }), ],});
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16from agents import Agentsummarizer = Agent( name="Summarizer", instructions="Generate a concise summary of the supplied text.",)main_agent = Agent( name="Research assistant", tools=[ summarizer.as_tool( tool_name="summarize_text", tool_description="Generate a concise summary of the supplied text.", ) ],)