Sub topic 16
Provider Differences and Availability
This chapter assumes you can call a responses or messages API with an API key, read JSON request and response bodies, and have used function calling before. It compares how OpenAI and Anthropic expose the three built-in tools covered earlier. Check each provider's current documentation before relying on any detail here, because tool versions, model support, and pricing change often.
Same idea, different shapes
Both providers run web search and code execution on their own servers and return the results in one response. The request and response formats differ, so code written for one provider does not work on the other without changes.
| Capability | OpenAI (Responses API) | Anthropic (Messages API) |
|---|---|---|
| Web search | `{"type": "web_search"}` | Versioned type such as `web_search_20250305`, plus `name` |
| Search limit | Controlled through other settings | `max_uses` on the tool |
| Code execution | `code_interpreter` with a `container` | A separate code execution server tool |
| File search | `file_search` with `vector_store_ids` | No equivalent hosted vector store tool in the same form |
| Answer text | `response.output_text` | Loop over `message.content` blocks |
Treat the last two rows with care. Anthropic's file handling and code execution tools have been released as separate or beta features, and they may need extra headers or different versions. Confirm the current state in the documentation.
Versioned tool names
Anthropic puts a date in the tool type, as in web_search_20250305. A newer version can change behavior, so pin the version you tested. OpenAI uses shorter type names, but the behavior behind them can still change as models are updated. In both cases, log the tool type and model name with each request so you can trace a change in results.
import anthropic
client = anthropic.Anthropic()
message = client.messages.create(
model="claude-sonnet-4-20250514",
max_tokens=1024,
tools=[
{
"type": "web_search_20250305",
"name": "web_search",
"max_uses": 3,
}
],
messages=[{"role": "user", "content": "Summarize recent news on solid-state batteries."}],
)
for block in message.content:
print(block.type)Printing the block types shows the search calls and result blocks next to the text. OpenAI returns a similar list in response.output, with items such as web_search_call and message.
Availability checks
Before you build on a built-in tool, check these points:
- Which models support the tool. Not every model accepts every tool.
- Which regions and account tiers can use it. Some tools are limited by region or need an organization setting turned on.
- How it is priced. Search calls, container time, and vector store storage are often billed apart from tokens.
- Where your data goes. Files in a vector store and code in a sandbox live on the provider's systems.
A portable design
Keep your own interface, for example answer_with_search(question), and put each provider's request and parsing code behind it. When a tool is missing on one provider, you can fall back to a function tool that your own code runs, such as a call to a search API of your choice.
Exercise
Your team wants to switch from OpenAI to Anthropic for web search. Name two things in your code that must change, and one question to answer before you switch.
Show answer
Change the tool declaration (OpenAI's web_search type versus Anthropic's versioned type with name and optional max_uses) and the response parsing (output_text and output items versus iterating over message.content blocks). Before switching, check that the chosen model supports the tool in your region and account, and how the search is priced.