Documentation Index
Fetch the complete documentation index at: https://docs.dartantic.ai/llms.txt
Use this file to discover all available pages before exploring further.
Anthropic’s web search tool allows Claude to search the web and incorporate
real-time information into responses.
Enable Web Search
final agent = Agent(
'anthropic',
chatModelOptions: const AnthropicChatOptions(
serverSideTools: {AnthropicServerSideTool.webSearch},
),
);
Usage
await for (final chunk in agent.sendStream(
'Search the web for the three most recent announcements '
'about the Dart programming language and summarize them.',
)) {
stdout.write(chunk.output);
}
The model automatically decides when to search based on the query. Search
results are incorporated directly into the response with citations.
Web search events stream through metadata['web_search']:
await for (final chunk in agent.sendStream(prompt)) {
stdout.write(chunk.output);
final events = chunk.metadata['web_search'] as List?;
if (events != null) {
for (final event in events) {
stdout.writeln('[search] ${event['type']}');
}
}
}
Example