webSearch method
Configures web search with detailed options
This method provides fine-grained control over web search behavior using a unified configuration that adapts to each provider's API.
Example:
final provider = await ai()
.anthropic()
.apiKey(apiKey)
.webSearch(
maxUses: 3,
allowedDomains: ['wikipedia.org', 'github.com'],
location: WebSearchLocation.sanFrancisco(),
)
.build();
Implementation
LLMBuilder webSearch({
int? maxUses,
int? maxResults,
List<String>? allowedDomains,
List<String>? blockedDomains,
WebSearchLocation? location,
String? mode,
String? fromDate,
String? toDate,
}) {
final config = WebSearchConfig(
maxUses: maxUses,
maxResults: maxResults,
allowedDomains: allowedDomains,
blockedDomains: blockedDomains,
location: location,
mode: mode,
fromDate: fromDate,
toDate: toDate,
);
return extension('webSearchConfig', config);
}