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.
Google’s server-side search tool uses Google Search to ground responses in
real-time web data. Results are automatically woven into the model’s response.
Enable Google Search
final agent = Agent(
'google',
chatModelOptions: const GoogleChatModelOptions(
serverSideTools: {GoogleServerSideTool.googleSearch},
),
);
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.
Google Search results include grounding metadata in the response. Access it via
the message metadata to show citations or sources:
final history = <ChatMessage>[];
await for (final chunk in agent.sendStream(prompt)) {
stdout.write(chunk.output);
history.addAll(chunk.messages);
}
// Check for grounding metadata in the final message
for (final msg in history) {
final grounding = msg.metadata['grounding'];
if (grounding != null) {
print('Sources: $grounding');
}
}
Example