pub struct ClientBuilder { /* private fields */ }Expand description
Builder for creating a LLMKitClient.
Implementations§
Source§impl ClientBuilder
impl ClientBuilder
Sourcepub fn with_embedding_provider(
self,
name: impl Into<String>,
provider: Arc<dyn EmbeddingProvider>,
) -> Self
pub fn with_embedding_provider( self, name: impl Into<String>, provider: Arc<dyn EmbeddingProvider>, ) -> Self
Add an embedding provider.
Sourcepub fn with_speech_provider(
self,
name: impl Into<String>,
provider: Arc<dyn SpeechProvider>,
) -> Self
pub fn with_speech_provider( self, name: impl Into<String>, provider: Arc<dyn SpeechProvider>, ) -> Self
Add a speech (TTS) provider.
Sourcepub fn with_transcription_provider(
self,
name: impl Into<String>,
provider: Arc<dyn TranscriptionProvider>,
) -> Self
pub fn with_transcription_provider( self, name: impl Into<String>, provider: Arc<dyn TranscriptionProvider>, ) -> Self
Add a transcription (STT) provider.
Sourcepub fn with_image_provider(
self,
name: impl Into<String>,
provider: Arc<dyn ImageProvider>,
) -> Self
pub fn with_image_provider( self, name: impl Into<String>, provider: Arc<dyn ImageProvider>, ) -> Self
Add an image generation provider.
Sourcepub fn with_video_provider(
self,
name: impl Into<String>,
provider: Arc<dyn VideoProvider>,
) -> Self
pub fn with_video_provider( self, name: impl Into<String>, provider: Arc<dyn VideoProvider>, ) -> Self
Add a video generation provider.
Sourcepub fn with_ranking_provider(
self,
name: impl Into<String>,
provider: Arc<dyn RankingProvider>,
) -> Self
pub fn with_ranking_provider( self, name: impl Into<String>, provider: Arc<dyn RankingProvider>, ) -> Self
Add a ranking/reranking provider.
Sourcepub fn with_moderation_provider(
self,
name: impl Into<String>,
provider: Arc<dyn ModerationProvider>,
) -> Self
pub fn with_moderation_provider( self, name: impl Into<String>, provider: Arc<dyn ModerationProvider>, ) -> Self
Add a moderation provider.
Sourcepub fn with_classification_provider(
self,
name: impl Into<String>,
provider: Arc<dyn ClassificationProvider>,
) -> Self
pub fn with_classification_provider( self, name: impl Into<String>, provider: Arc<dyn ClassificationProvider>, ) -> Self
Add a classification provider.
Sourcepub fn with_retry(self, config: RetryConfig) -> Self
pub fn with_retry(self, config: RetryConfig) -> Self
Sourcepub fn with_default_retry(self) -> Self
pub fn with_default_retry(self) -> Self
Enable automatic retry with default production configuration.
Uses RetryConfig::default() which provides:
- 10 retry attempts
- Exponential backoff from 1s up to 5 minutes
- Jitter enabled for better distributed retry timing
Sourcepub fn with_provider(
self,
name: impl Into<String>,
provider: Arc<dyn Provider>,
) -> Self
pub fn with_provider( self, name: impl Into<String>, provider: Arc<dyn Provider>, ) -> Self
Add a custom provider.
Sourcepub fn with_default(self, name: impl Into<String>) -> Self
pub fn with_default(self, name: impl Into<String>) -> Self
Set the default provider by name.
Sourcepub fn with_anthropic_from_env(self) -> Self
pub fn with_anthropic_from_env(self) -> Self
Add Anthropic provider from environment.
Sourcepub fn with_anthropic(self, api_key: impl Into<String>) -> Result<Self>
pub fn with_anthropic(self, api_key: impl Into<String>) -> Result<Self>
Add Anthropic provider with API key.
Sourcepub fn with_anthropic_config(self, config: ProviderConfig) -> Result<Self>
pub fn with_anthropic_config(self, config: ProviderConfig) -> Result<Self>
Add Anthropic provider with custom config.
Sourcepub fn with_openai_from_env(self) -> Self
pub fn with_openai_from_env(self) -> Self
Add OpenAI provider from environment.
Also registers OpenAI as an embedding provider for text-embedding-* models.
Sourcepub fn with_openai(self, api_key: impl Into<String>) -> Result<Self>
pub fn with_openai(self, api_key: impl Into<String>) -> Result<Self>
Add OpenAI provider with API key.
Also registers OpenAI as an embedding provider for text-embedding-* models.
Sourcepub fn with_openai_config(self, config: ProviderConfig) -> Result<Self>
pub fn with_openai_config(self, config: ProviderConfig) -> Result<Self>
Add OpenAI provider with custom config.
Also registers OpenAI as an embedding provider for text-embedding-* models.
Sourcepub async fn build(self) -> Result<LLMKitClient>
pub async fn build(self) -> Result<LLMKitClient>
Build the client.
This is an async method that initializes all pending providers (Vertex AI, Bedrock) that require async credential discovery.
If retry configuration was set via with_retry() or with_default_retry(),
all providers will be wrapped with automatic retry logic.