enableWebSearch method

LLMBuilder enableWebSearch()

Web Search configuration methods

These methods provide a unified interface for configuring web search across different providers (xAI, Anthropic, etc.). The implementation details are handled automatically based on the selected provider. Enables web search functionality

This is a universal method that works across all providers that support web search. The underlying implementation varies by provider:

  • xAI: Uses Live Search with search_parameters
  • Anthropic: Uses web_search tool
  • Others: Provider-specific implementations

Example:

final provider = await ai()
    .xai()  // or .anthropic(), etc.
    .apiKey(apiKey)
    .enableWebSearch()
    .build();

Implementation

/// Enables web search functionality
///
/// This is a universal method that works across all providers that support
/// web search. The underlying implementation varies by provider:
/// - **xAI**: Uses Live Search with search_parameters
/// - **Anthropic**: Uses web_search tool
/// - **Others**: Provider-specific implementations
///
/// Example:
/// ```dart
/// final provider = await ai()
///     .xai()  // or .anthropic(), etc.
///     .apiKey(apiKey)
///     .enableWebSearch()
///     .build();
/// ```
LLMBuilder enableWebSearch() => extension('webSearchEnabled', true);