Web Search
Use the built-in web search tool to give the model access to current information from the web.
import os
import anthropic
client = anthropic.Anthropic(
api_key="<API_KEY>",
base_url='https://llm.onerouter.pro'
)
message = client.messages.create(
model='claude-sonnet-4-5@20250929',
max_tokens=2048,
tools=[
{
'type': 'web_search_20250305',
'name': 'web_search',
}
],
messages=[
{
'role': 'user',
'content': 'What are the latest developments in quantum computing?'
}
],
)
for block in message.content:
if block.type == 'text':
print(block.text)
elif block.type == 'web_search_tool_result':
print('Search results received')Last updated