1use std::collections::HashMap;
2
3#[derive(Debug, Clone, Default)]
4pub struct Config {
5 pub default_provider: Option<String>,
6 pub providers: HashMap<String, ProviderConfig>,
7}
8
9#[derive(Debug, Clone, Default)]
10pub struct ProviderConfig {
11 pub base_url: Option<String>,
12 pub api_key_env: Option<String>,
13 pub api_key: Option<String>,
14 pub kind: ProviderKind,
15 pub no_auth: bool,
16 pub extra_headers: HashMap<String, String>,
17}
18
19#[derive(Debug, Clone, Default, PartialEq, Eq)]
20pub enum ProviderKind {
21 #[default]
22 OpenAICompatible,
23 OpenAIResponses,
25 Anthropic,
26 Gemini,
27}
28
29impl ProviderConfig {
30 pub fn with_base_url(mut self, base: impl Into<String>) -> Self {
31 self.base_url = Some(base.into());
32 self
33 }
34
35 pub fn with_api_key_env(mut self, env: impl Into<String>) -> Self {
36 self.api_key_env = Some(env.into());
37 self
38 }
39
40 pub fn with_api_key(mut self, key: impl Into<String>) -> Self {
41 self.api_key = Some(key.into());
42 self
43 }
44
45 pub fn with_kind(mut self, kind: ProviderKind) -> Self {
46 self.kind = kind;
47 self
48 }
49
50 pub fn with_no_auth(mut self, no_auth: bool) -> Self {
51 self.no_auth = no_auth;
52 self
53 }
54
55 pub fn with_header(mut self, key: impl Into<String>, value: impl Into<String>) -> Self {
56 self.extra_headers.insert(key.into(), value.into());
57 self
58 }
59}