pub trait ProviderConfig:
Send
+ Sync
+ Debug
+ Any {
// Required methods
fn provider_name(&self) -> &'static str;
fn max_context_tokens(&self) -> usize;
fn validate(&self) -> LlmResult<()>;
fn base_url(&self) -> &str;
fn api_key(&self) -> Option<&str>;
fn default_model(&self) -> &str;
fn as_any(&self) -> &dyn Any;
fn retry_policy(&self) -> &RetryPolicy;
}Expand description
Trait for provider-specific configuration.
All provider configs (OpenAI, Anthropic, etc.) implement this trait. You typically don’t need to implement this yourself unless adding a custom provider.
§Provided Implementations
Required Methods§
Sourcefn provider_name(&self) -> &'static str
fn provider_name(&self) -> &'static str
Get the provider identifier (e.g., “openai”, “anthropic”).
Sourcefn max_context_tokens(&self) -> usize
fn max_context_tokens(&self) -> usize
Get the maximum context window size in tokens.
Sourcefn validate(&self) -> LlmResult<()>
fn validate(&self) -> LlmResult<()>
Validate that the configuration is complete and valid.
§Errors
Returns LlmError::ConfigurationError if:
- Required fields are missing (e.g., API key for cloud providers)
- Field values are invalid (e.g., malformed URLs)
- Provider-specific validation fails
Sourcefn default_model(&self) -> &str
fn default_model(&self) -> &str
Get the default model name for this provider.
Sourcefn retry_policy(&self) -> &RetryPolicy
fn retry_policy(&self) -> &RetryPolicy
Get the retry policy for transient failures.