Use web search, file search, and code interpreter without defining custom schemas.
The Responses API includes built-in tools that the model can invoke automatically — no function schemas required. These tools extend the model’s capabilities beyond its training data.
Built-in tools are handled server-side. Unlike custom function calling (where your code executes the function), built-in tools execute automatically and return results to the model within the same request.
Web search is useful for questions about current events, recent releases, live data, or anything that may have changed since the model’s training cutoff.
Let the model write and execute Python code to solve math problems, analyze data, or generate charts.
Python
Node.js
response = client.responses.create( model="gpt-4o", tools=[{"type": "code_interpreter"}], input="Calculate the first 20 Fibonacci numbers and show them in a formatted table.")print(response.output_text)
const response = await client.responses.create({ model: "gpt-4o", tools: [{ type: "code_interpreter" }], input: "Calculate the first 20 Fibonacci numbers and show them in a formatted table.",});console.log(response.output_text);
The output array will include a code_interpreter_call item with the code that was executed:
You can enable multiple built-in tools in the same request. The model decides which to use based on the input.
response = client.responses.create( model="gpt-4o", tools=[ {"type": "web_search_preview"}, {"type": "code_interpreter"} ], input="Look up the current population of the 10 largest countries, then create a bar chart comparing them.")print(response.output_text)
The model may:
Use web search to find current population data
Use code interpreter to generate the chart
Return the final answer with both tool calls visible in the output array
You can combine built-in tools with your own custom function definitions:
response = client.responses.create( model="gpt-4o", tools=[ {"type": "web_search_preview"}, { "type": "function", "function": { "name": "save_to_database", "description": "Save structured data to the database.", "parameters": { "type": "object", "properties": { "data": {"type": "object"}, "collection": {"type": "string"} }, "required": ["data", "collection"] } } } ], input="Find the current Bitcoin price and save it to the prices collection.")
Built-in tools execute automatically on the server. Custom function calls still require your code to execute the function and submit results back. See Tool Calling for the full custom function workflow.
Control how the model selects tools with tool_choice:
Value
Behavior
"auto"
Model decides whether to use tools (default)
"required"
Model must use at least one tool
"none"
Model cannot use any tools
{"type": "web_search_preview"}
Force a specific tool
# Force the model to search the webresponse = client.responses.create( model="gpt-4o", tools=[{"type": "web_search_preview"}], tool_choice={"type": "web_search_preview"}, input="What is the current weather in Tokyo?")