tools=[{"type":"web_search"}] is one line. The same capability built yourself — picking a search provider, contracting for API access, parsing results, ranking, citation extraction — is a multi-week project that ships your bug surface forever. Hosted tools are OpenAI's bug surface.
The tradeoff is control: hosted web_search uses OpenAI's choice of provider; you can't swap it for your own. For most product use cases that's fine. When it isn't, define a custom function tool and run the search yourself.
Code
Enabling web_search and code_interpreter·python
# Web search
response = client.responses.create(
model="gpt-5.4",
input="What is the current price of NVIDIA stock?",
tools=[{"type": "web_search"}],
)
# File search (requires vector store)
response = client.responses.create(
model="gpt-5.4",
input="Summarize the Q3 earnings report.",
tools=[{"type": "file_search", "vector_store_ids": ["vs_abc123"]}],
)
# Code interpreter
response = client.responses.create(
model="gpt-5.4",
input="Calculate the 10,000th Fibonacci number.",
tools=[{"type": "code_interpreter"}],
)
# Image generation
response = client.responses.create(
model="gpt-4.1-mini",
input="Generate an image of a sunset over the ocean.",
tools=[{"type": "image_generation"}],
)
# Computer use
response = client.responses.create(
model="computer-use-preview",
input="Take a screenshot and tell me what's on the screen.",
tools=[{"type": "computer", "display_width": 1024, "display_height": 768}],
)
Build a Q&A loop that has access to web_search AND a file_search vector store of 5 PDFs. Track which tool the model invoked for each question. Tune the system instructions until the routing matches your intuition.
Progress
Progress is local-only — sign in to sync across devices.