C.W.K.
Stream
Lesson 04 of 07 · published

Built-in Tools

~22 min · hosted-tools, web-search, code-interpreter, file-search

Level 0Tokenizer
0 XP0/54 lessons0/10 achievements
0/120 XP to next level120 XP to go0% complete

The Responses API includes several built-in tools that require no custom function definitions — just specify the tool type.

Built-in tool types include: web_search, file_search, code_interpreter, computer, image_generation, local_shell, and MCP (Model Context Protocol) servers.

Hosted tools collapse weeks of work

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}],
)

External links

Exercise

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.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.