#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum ApiStyle {
Responses,
Anthropic,
ChatCompletions,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Auth {
Key(&'static str),
Local,
}
#[derive(Clone, Copy, Debug)]
pub struct ProviderSpec {
pub id: &'static str,
pub name: &'static str,
pub api: ApiStyle,
pub url: &'static str,
pub auth: Auth,
pub default_model: &'static str,
}
#[derive(Clone, Copy, Debug)]
pub struct ModelSpec {
pub id: &'static str,
pub name: &'static str,
pub provider: &'static str,
pub input: Option<f32>,
pub output: Option<f32>,
}
pub const PROVIDERS: &[ProviderSpec] = &[
ProviderSpec {
id: "openai",
name: "OpenAI",
api: ApiStyle::Responses,
url: "https://api.openai.com/v1/responses",
auth: Auth::Key("OPENAI_API_KEY"),
default_model: "gpt-5.6-terra",
},
ProviderSpec {
id: "anthropic",
name: "Anthropic",
api: ApiStyle::Anthropic,
url: "https://api.anthropic.com/v1/messages",
auth: Auth::Key("ANTHROPIC_API_KEY"),
default_model: "claude-sonnet-5",
},
ProviderSpec {
id: "openrouter",
name: "OpenRouter",
api: ApiStyle::ChatCompletions,
url: "https://openrouter.ai/api/v1/chat/completions",
auth: Auth::Key("OPENROUTER_API_KEY"),
default_model: "openai/gpt-5.6-terra",
},
ProviderSpec {
id: "groq",
name: "Groq",
api: ApiStyle::ChatCompletions,
url: "https://api.groq.com/openai/v1/chat/completions",
auth: Auth::Key("GROQ_API_KEY"),
default_model: "llama-3.3-70b-versatile",
},
ProviderSpec {
id: "deepseek",
name: "DeepSeek",
api: ApiStyle::ChatCompletions,
url: "https://api.deepseek.com/v1/chat/completions",
auth: Auth::Key("DEEPSEEK_API_KEY"),
default_model: "deepseek-v4-flash",
},
ProviderSpec {
id: "gemini",
name: "Google Gemini",
api: ApiStyle::ChatCompletions,
url: "https://generativelanguage.googleapis.com/v1beta/openai/chat/completions",
auth: Auth::Key("GEMINI_API_KEY"),
default_model: "gemini-2.5-flash",
},
ProviderSpec {
id: "xai",
name: "xAI",
api: ApiStyle::ChatCompletions,
url: "https://api.x.ai/v1/chat/completions",
auth: Auth::Key("XAI_API_KEY"),
default_model: "grok-4-fast",
},
ProviderSpec {
id: "mistral",
name: "Mistral",
api: ApiStyle::ChatCompletions,
url: "https://api.mistral.ai/v1/chat/completions",
auth: Auth::Key("MISTRAL_API_KEY"),
default_model: "mistral-small-latest",
},
ProviderSpec {
id: "ollama",
name: "Ollama",
api: ApiStyle::ChatCompletions,
url: "http://localhost:11434/v1/chat/completions",
auth: Auth::Local,
default_model: "llama3.1",
},
];
pub const MODELS: &[ModelSpec] = &[
ModelSpec {
id: "gpt-5.6-sol",
name: "GPT-5.6 Sol",
provider: "openai",
input: Some(5.0),
output: Some(30.0),
},
ModelSpec {
id: "gpt-5.6-terra",
name: "GPT-5.6 Terra",
provider: "openai",
input: Some(2.5),
output: Some(15.0),
},
ModelSpec {
id: "gpt-5.6-luna",
name: "GPT-5.6 Luna",
provider: "openai",
input: Some(1.0),
output: Some(6.0),
},
ModelSpec {
id: "claude-opus-5",
name: "Claude Opus 5",
provider: "anthropic",
input: Some(5.0),
output: Some(25.0),
},
ModelSpec {
id: "claude-sonnet-5",
name: "Claude Sonnet 5",
provider: "anthropic",
input: Some(3.0),
output: Some(15.0),
},
ModelSpec {
id: "claude-haiku-4-5",
name: "Claude Haiku 4.5",
provider: "anthropic",
input: Some(1.0),
output: Some(5.0),
},
ModelSpec {
id: "openai/gpt-5.6-terra",
name: "GPT-5.6 Terra",
provider: "openrouter",
input: Some(2.5),
output: Some(15.0),
},
ModelSpec {
id: "anthropic/claude-sonnet-5",
name: "Claude Sonnet 5",
provider: "openrouter",
input: Some(3.0),
output: Some(15.0),
},
ModelSpec {
id: "deepseek/deepseek-v4-flash",
name: "DeepSeek V4 Flash",
provider: "openrouter",
input: Some(0.14),
output: Some(0.28),
},
ModelSpec {
id: "deepseek-v4-pro",
name: "DeepSeek V4 Pro",
provider: "deepseek",
input: Some(0.435),
output: Some(0.87),
},
ModelSpec {
id: "deepseek-v4-flash",
name: "DeepSeek V4 Flash",
provider: "deepseek",
input: Some(0.14),
output: Some(0.28),
},
ModelSpec {
id: "llama-3.3-70b-versatile",
name: "Llama 3.3 70B",
provider: "groq",
input: Some(0.59),
output: Some(0.79),
},
ModelSpec {
id: "gemini-2.5-pro",
name: "Gemini 2.5 Pro",
provider: "gemini",
input: Some(1.25),
output: Some(10.0),
},
ModelSpec {
id: "gemini-2.5-flash",
name: "Gemini 2.5 Flash",
provider: "gemini",
input: Some(0.15),
output: Some(1.25),
},
ModelSpec {
id: "grok-4.5",
name: "Grok 4.5",
provider: "xai",
input: Some(2.0),
output: Some(6.0),
},
ModelSpec {
id: "grok-4-fast",
name: "Grok 4 Fast",
provider: "xai",
input: Some(0.20),
output: Some(0.50),
},
ModelSpec {
id: "mistral-large-latest",
name: "Mistral Large 3",
provider: "mistral",
input: Some(0.50),
output: Some(1.50),
},
ModelSpec {
id: "mistral-small-latest",
name: "Mistral Small 4",
provider: "mistral",
input: Some(0.15),
output: Some(0.60),
},
ModelSpec {
id: "llama3.1",
name: "Llama 3.1",
provider: "ollama",
input: Some(0.0),
output: Some(0.0),
},
];
pub fn provider(id: &str) -> Option<&'static ProviderSpec> {
let id = match id {
"apikey" => "openai",
"google" => "gemini",
"grok" => "xai",
"local" => "ollama",
other => other,
};
PROVIDERS.iter().find(|provider| provider.id == id)
}
pub fn model(id: &str) -> Option<&'static ModelSpec> {
MODELS.iter().find(|model| model.id == id)
}
pub fn models_for(provider_id: &str) -> Vec<&'static ModelSpec> {
let canonical = provider(provider_id).map(|p| p.id).unwrap_or(provider_id);
MODELS
.iter()
.filter(move |model| model.provider == canonical)
.collect()
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn provider_aliases_resolve_to_canonical_routes() {
assert_eq!(provider("apikey").map(|spec| spec.id), Some("openai"));
assert_eq!(provider("google").map(|spec| spec.id), Some("gemini"));
assert_eq!(provider("grok").map(|spec| spec.id), Some("xai"));
assert_eq!(provider("local").map(|spec| spec.id), Some("ollama"));
}
#[test]
fn aliased_model_queries_use_the_canonical_provider() {
let google_models = models_for("google");
assert!(!google_models.is_empty());
assert!(google_models.iter().all(|model| model.provider == "gemini"));
}
#[test]
fn every_catalog_model_references_a_provider() {
for model in MODELS {
assert!(
provider(model.provider).is_some(),
"unknown provider for {}",
model.id
);
}
}
}