LLMBuilder class

Builder for configuring and instantiating LLM providers

Provides a fluent interface for setting various configuration options like model selection, API keys, generation parameters, etc.

The new version uses the provider registry system for extensibility.

Constructors

LLMBuilder.new()
Creates a new empty builder instance with default values

Properties

currentConfig LLMConfig
Gets the current configuration (for internal use by builders)
no setter
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

advancedWebSearch({WebSearchStrategy? strategy, WebSearchContextSize? contextSize, String? searchPrompt, int? maxUses, int? maxResults, List<String>? allowedDomains, List<String>? blockedDomains, WebSearchLocation? location, String? mode, String? fromDate, String? toDate, WebSearchType? searchType}) LLMBuilder
Advanced web search configuration with full control
anthropic([AnthropicBuilder configure(AnthropicBuilder)?]) LLMBuilder
apiKey(String key) LLMBuilder
Sets the API key for authentication
audioFormat(String format) LLMBuilder
Audio configuration methods
audioProcessingMode(String mode) LLMBuilder
Advanced audio configuration methods
audioQuality(String quality) LLMBuilder
audioSeed(int seed) LLMBuilder
baseUrl(String url) LLMBuilder
Sets the base URL for API requests
batchSize(int size) LLMBuilder
build() Future<ChatCapability>
Builds and returns a configured LLM provider instance
buildAssistant() Future<AssistantCapability>
Builds a provider with AssistantCapability
buildAudio() Future<AudioCapability>
Builds a provider with AudioCapability
buildEmbedding() Future<EmbeddingCapability>
Builds a provider with EmbeddingCapability
buildFileManagement() Future<FileManagementCapability>
Builds a provider with FileManagementCapability
buildGoogleTTS() Future<GoogleTTSCapability>
Builds a Google provider with TTS capability
buildImageGeneration() Future<ImageGenerationCapability>
Builds a provider with ImageGenerationCapability
buildModelListing() Future<ModelListingCapability>
Builds a provider with ModelListingCapability
buildModeration() Future<ModerationCapability>
Builds a provider with ModerationCapability
buildOpenAIResponses() Future<OpenAIProvider>
Builds an OpenAI provider with Responses API enabled
cloudStorageUrl(String url) LLMBuilder
deepseek() LLMBuilder
deepseekOpenAI() LLMBuilder
Convenience methods for OpenAI-compatible providers These use the OpenAI interface but with provider-specific configurations
diarize(bool enabled) LLMBuilder
STT-specific configuration methods
elevenlabs([ElevenLabsBuilder configure(ElevenLabsBuilder)?]) LLMBuilder
embeddingDimensions(int dimensions) LLMBuilder
embeddingEncodingFormat(String format) LLMBuilder
Convenience methods for common extensions
enableLogging(bool enabled) LLMBuilder
enableWebSearch() LLMBuilder
Web Search configuration methods
extension(String key, dynamic value) LLMBuilder
Sets provider-specific extension
githubCopilot() LLMBuilder
google([GoogleLLMBuilder configure(GoogleLLMBuilder)?]) LLMBuilder
googleOpenAI() LLMBuilder
groq() LLMBuilder
groqOpenAI() LLMBuilder
guidanceScale(double scale) LLMBuilder
http(HttpConfig configure(HttpConfig)) LLMBuilder
Configure HTTP settings using a fluent builder
imageSeed(String seed) LLMBuilder
imageSize(String size) LLMBuilder
Image generation configuration methods
includeTimestamps(bool enabled) LLMBuilder
instructions(String instructions) LLMBuilder
interleavedThinking(bool enable) LLMBuilder
Enables interleaved thinking for Anthropic (Claude 4 models only)
jsonSchema(StructuredOutputFormat schema) LLMBuilder
Sets structured output schema for JSON responses
languageCode(String code) LLMBuilder
maxTokens(int tokens) LLMBuilder
Sets the maximum number of tokens to generate
model(String model) LLMBuilder
Sets the model identifier to use
newsSearch({int? maxResults, String? fromDate, String? toDate, List<String>? blockedDomains}) LLMBuilder
Enables news search functionality
nextText(String text) LLMBuilder
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
numInferenceSteps(int steps) LLMBuilder
numSpeakers(int count) LLMBuilder
ollama([OllamaBuilder configure(OllamaBuilder)?]) LLMBuilder
openai([OpenAIBuilder configure(OpenAIBuilder)?]) LLMBuilder
Convenience methods for built-in providers
openRouter([OpenRouterBuilder configure(OpenRouterBuilder)?]) LLMBuilder
optimizeStreamingLatency(int level) LLMBuilder
phind() LLMBuilder
phindOpenAI() LLMBuilder
previousText(String text) LLMBuilder
prompt(String prompt) LLMBuilder
promptEnhancement(bool enabled) LLMBuilder
provider(String providerId) LLMBuilder
Sets the provider to use (new registry-based approach)
quickWebSearch({int maxResults = 5, List<String>? blockedDomains}) LLMBuilder
Quick web search setup with basic options
reasoning(bool enable) LLMBuilder
Enables reasoning/thinking for supported providers (Anthropic, OpenAI o1)
reasoningEffort(ReasoningEffort? effort) LLMBuilder
Sets the reasoning effort for models that support it (e.g., OpenAI o1, Gemini) Valid values: ReasoningEffort.low, ReasoningEffort.medium, ReasoningEffort.high, or null to disable
responseFormat(String format) LLMBuilder
sampleRate(int rate) LLMBuilder
searchLocation(WebSearchLocation location) LLMBuilder
Configures search location for localized results
serviceTier(ServiceTier tier) LLMBuilder
Sets service tier for API requests
stopSequences(List<String> sequences) LLMBuilder
Sets stop sequences for generation
systemPrompt(String prompt) LLMBuilder
Sets the system prompt/context
tagAudioEvents(bool enabled) LLMBuilder
temperature(double temp) LLMBuilder
Sets the temperature for controlling response randomness (0.0-1.0)
textNormalization(String mode) LLMBuilder
thinkingBudgetTokens(int tokens) LLMBuilder
Sets thinking budget tokens for Anthropic extended thinking
timeout(Duration timeout) LLMBuilder
Sets the global timeout for all HTTP operations
timestampGranularity(String granularity) LLMBuilder
togetherAI() LLMBuilder
toolChoice(ToolChoice choice) LLMBuilder
Sets the tool choice
tools(List<Tool> tools) LLMBuilder
Sets the function tools
topK(int topK) LLMBuilder
Sets the top-k sampling parameter
topP(double topP) LLMBuilder
Sets the top-p (nucleus) sampling parameter
toString() String
A string representation of this object.
inherited
user(String userId) LLMBuilder
Sets user identifier for tracking and analytics
voice(String voiceName) LLMBuilder
Sets voice for text-to-speech (OpenAI providers)
webhook(bool enabled) LLMBuilder
webSearch({int? maxUses, int? maxResults, List<String>? allowedDomains, List<String>? blockedDomains, WebSearchLocation? location, String? mode, String? fromDate, String? toDate}) LLMBuilder
Configures web search with detailed options
xai() LLMBuilder
xaiOpenAI() LLMBuilder

Operators

operator ==(Object other) bool
The equality operator.
inherited