pub struct LlmConfig {
pub provider: LlmProvider,
pub api_key: String,
pub model: String,
pub base_url: Option<String>,
}Expand description
Complete configuration for an LLM client.
Use endpoint to resolve the effective API URL,
which respects any custom base_url override.
§Example
use devops_models::llm::provider::{LlmConfig, LlmProvider};
let config = LlmConfig {
provider: LlmProvider::Anthropic,
api_key: "sk-ant-...".to_string(),
model: "claude-sonnet-4-20250514".to_string(),
base_url: None,
};
assert!(config.endpoint().contains("anthropic.com"));Fields§
§provider: LlmProviderWhich LLM backend to target.
api_key: StringAPI key (or empty string for Ollama / local setups).
model: StringModel identifier (e.g. "claude-sonnet-4-20250514", "gpt-4o").
base_url: Option<String>Optional URL override. When None, the provider’s default endpoint is used.
Implementations§
Source§impl LlmConfig
impl LlmConfig
Sourcepub fn endpoint(&self) -> String
pub fn endpoint(&self) -> String
Resolve the effective API endpoint URL.
Returns base_url if set, otherwise the provider’s default endpoint.
§Example
use devops_models::llm::provider::{LlmConfig, LlmProvider};
let config = LlmConfig {
provider: LlmProvider::Ollama,
api_key: String::new(),
model: "qwen3:8b".to_string(),
base_url: Some("http://my-ollama:11434/v1/chat/completions".to_string()),
};
assert_eq!(config.endpoint(), "http://my-ollama:11434/v1/chat/completions");Sourcepub fn default_model(&self) -> &str
pub fn default_model(&self) -> &str
Return the recommended default model identifier for this provider.
This is a convenience helper for new configurations; callers should always allow the user to override with a specific model string.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for LlmConfig
impl<'de> Deserialize<'de> for LlmConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for LlmConfig
impl RefUnwindSafe for LlmConfig
impl Send for LlmConfig
impl Sync for LlmConfig
impl Unpin for LlmConfig
impl UnsafeUnpin for LlmConfig
impl UnwindSafe for LlmConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more