Web Search
Example request
import os
import anthropic
client = anthropic.Anthropic(
api_key="<API_KEY>",
base_url='https://llm.siraya.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')
import Anthropic from '@anthropic-ai/sdk';
const anthropic = new Anthropic({
"<API_KEY>",
baseURL: 'https://llm.siraya.pro',
});
const message = await anthropic.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 (const block of message.content) {
if (block.type === 'text') {
console.log(block.text);
} else if (block.type === 'web_search_tool_result') {
console.log('Search results received');
}
}
Web search response format
When the model makes web search, the response includes tool use blocks:
{
"id": "gen-1771662932-6kgZ7Ntv0LlaGlYSVVUT",
"content": [
{
"id": "toolu_vrtx_01G9KmA4dCvqKcNZfWn9ebVq",
"input": {
"query": "latest developments quantum computing 2024"
},
"name": "web_search",
"type": "tool_use"
}
],
"model": "claude-sonnet-4-5@20250929",
"role": "assistant",
"stop_reason": "tool_use",
"stop_sequence": null,
"type": "message",
"usage": {
"cache_creation_input_tokens": 0,
"cache_read_input_tokens": 0,
"input_tokens": 536,
"output_tokens": 59,
"server_tool_use": null,
"service_tier": null
}
}