Skip to main content
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.

Available Built-in Tools

ToolType valueDescription
Web Searchweb_search_previewSearch the internet for current information
File Searchfile_searchSearch through uploaded files using semantic search
Code Interpretercode_interpreterExecute Python code in a sandbox

Enable web search to let the model look up current information that isn’t in its training data.
import os
from openai import OpenAI

client = OpenAI(
    base_url="https://api.routeway.ai/v1",
    api_key=os.getenv("ROUTEWAY_API_KEY")
)

response = client.responses.create(
    model="gpt-4o",
    tools=[{"type": "web_search_preview"}],
    input="What were the top tech news stories today?"
)

print(response.output_text)
When the model uses web search, the output array includes a web_search_call item showing what was searched:
{
  "output": [
    {
      "type": "web_search_call",
      "id": "ws_abc123",
      "status": "completed"
    },
    {
      "type": "message",
      "role": "assistant",
      "content": [
        {
          "type": "output_text",
          "text": "Here are today's top tech stories..."
        }
      ]
    }
  ]
}
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.

Code Interpreter

Let the model write and execute Python code to solve math problems, analyze data, or generate charts.
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)
The output array will include a code_interpreter_call item with the code that was executed:
{
  "output": [
    {
      "type": "code_interpreter_call",
      "id": "ci_abc123",
      "code": "fibs = [0, 1]\nfor i in range(18):\n    fibs.append(fibs[-1] + fibs[-2])\nprint(fibs)",
      "results": [
        {
          "type": "text",
          "text": "[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181]"
        }
      ]
    },
    {
      "type": "message",
      "role": "assistant",
      "content": [...]
    }
  ]
}

Combining Multiple Tools

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:
  1. Use web search to find current population data
  2. Use code interpreter to generate the chart
  3. Return the final answer with both tool calls visible in the output array

Mixing Built-in and Custom Tools

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.

Tool Choice

Control how the model selects tools with tool_choice:
ValueBehavior
"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 web
response = 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?"
)

Best Practices

Be specific about when to search

If your prompt clearly needs current data, enable web search. For questions answerable from training data, skip it to save latency.

Use code interpreter for computation

Models are better at writing code than doing arithmetic. For math-heavy tasks, enable code interpreter for accurate results.

Check output items

Inspect the output array to see which tools were used and verify the model’s reasoning chain.

Combine thoughtfully

Enabling too many tools can confuse the model. Enable only the tools relevant to the task at hand.