use serde::{Deserialize, Serialize};
use std::collections::HashMap;
#[derive(Clone, Default, Serialize, Deserialize)]
pub struct ProviderConfig {
#[serde(default)]
pub anthropic_api_key: Option<String>,
#[serde(default)]
pub openai_api_key: Option<String>,
#[serde(default)]
pub google_api_key: Option<String>,
#[serde(default)]
pub claude_code_enabled: bool,
#[serde(default)]
pub claude_code_binary: Option<String>,
#[serde(default)]
pub claude_code_effort: Option<String>,
#[serde(default)]
pub anthropic_cache_ttl: Option<leviath_providers::anthropic::CacheTtl>,
#[serde(default)]
pub fallback_order: Vec<String>,
}
impl std::fmt::Debug for ProviderConfig {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("ProviderConfig")
.field("anthropic_api_key", &redacted(&self.anthropic_api_key))
.field("openai_api_key", &redacted(&self.openai_api_key))
.field("google_api_key", &redacted(&self.google_api_key))
.field("claude_code_enabled", &self.claude_code_enabled)
.field("claude_code_binary", &self.claude_code_binary)
.field("claude_code_effort", &self.claude_code_effort)
.field("anthropic_cache_ttl", &self.anthropic_cache_ttl)
.field("fallback_order", &self.fallback_order)
.finish()
}
}
fn redacted(value: &Option<String>) -> &'static str {
match value {
Some(_) => "<set>",
None => "<unset>",
}
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct ModelProviderConfig {
#[serde(default)]
pub script: Option<String>,
#[serde(default)]
pub api_key: Option<String>,
#[serde(default)]
pub base_url: Option<String>,
#[serde(default)]
pub rate_limit: Option<leviath_providers::RateLimitConfig>,
#[serde(flatten)]
pub extra: HashMap<String, toml::Value>,
}