Enable Web Fetch
Usage
Fetched Documents
Fetched content is attached asDataPart instances on the message history:
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Fetch and process web pages using Anthropic’s server-side tool.
final agent = Agent(
'anthropic',
chatModelOptions: const AnthropicChatOptions(
serverSideTools: {AnthropicServerSideTool.webFetch},
),
);
await for (final chunk in agent.sendStream(
'Retrieve https://dart.dev and summarize the main features.',
)) {
stdout.write(chunk.output);
}
DataPart instances on the message history:
final history = <ChatMessage>[];
await for (final chunk in agent.sendStream(prompt)) {
stdout.write(chunk.output);
history.addAll(chunk.messages);
}
// Access fetched documents
for (final msg in history) {
for (final part in msg.parts) {
if (part is DataPart) {
print('Fetched: ${part.name} (${part.mimeType})');
File('output/${part.name}').writeAsBytesSync(part.bytes);
}
}
}
final agent = Agent(
'anthropic',
chatModelOptions: const AnthropicChatOptions(
serverSideTools: {
AnthropicServerSideTool.webSearch,
AnthropicServerSideTool.webFetch,
},
),
);
