Enable Web Search
Usage
Streaming Metadata
Web search events stream throughmetadata['web_search']:
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Search the web using Anthropic’s server-side search tool.
final agent = Agent(
'anthropic',
chatModelOptions: const AnthropicChatOptions(
serverSideTools: {AnthropicServerSideTool.webSearch},
),
);
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);
}
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']}');
}
}
}
