ProviderConfig

Trait ProviderConfig 

Source
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§

Source

fn provider_name(&self) -> &'static str

Get the provider identifier (e.g., “openai”, “anthropic”).

Source

fn max_context_tokens(&self) -> usize

Get the maximum context window size in tokens.

Source

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
Source

fn base_url(&self) -> &str

Get the base URL for API requests.

Source

fn api_key(&self) -> Option<&str>

Get the API key, if one is configured.

Source

fn default_model(&self) -> &str

Get the default model name for this provider.

Source

fn as_any(&self) -> &dyn Any

Downcast helper for accessing concrete config types.

Source

fn retry_policy(&self) -> &RetryPolicy

Get the retry policy for transient failures.

Implementors§