use std::env;
pub trait OpenAiCompatConfig: Send + Sync + 'static {
fn base_url(&self) -> &str;
fn api_key(&self) -> &str;
fn provider_name(&self) -> &'static str;
fn supports_json_schema(&self) -> bool;
fn default_model(&self) -> &str;
fn small_model(&self) -> &str;
}
pub struct OpenAiModel;
impl OpenAiModel {
pub const GPT_5_5: &str = "gpt-5.5";
pub const GPT_5_4: &str = "gpt-5.4";
pub const GPT_5_4_MINI: &str = "gpt-5.4-mini";
pub const GPT_5_4_NANO: &str = "gpt-5.4-nano";
pub const GPT_4_1: &str = "gpt-4.1";
pub const GPT_4_1_MINI: &str = "gpt-4.1-mini";
pub const GPT_4_1_NANO: &str = "gpt-4.1-nano";
pub const GPT_4O: &str = "gpt-4o";
pub const GPT_4O_MINI: &str = "gpt-4o-mini";
}
pub struct MistralModel;
impl MistralModel {
pub const MEDIUM_3_5: &str = "mistral-medium-3.5";
pub const LARGE: &str = "mistral-large-latest";
pub const SMALL: &str = "mistral-small-latest";
pub const CODESTRAL: &str = "codestral-latest";
pub const MEDIUM: &str = "mistral-medium-latest";
}
pub struct OpenAiConfig {
api_key: String,
base_url: String,
}
impl OpenAiConfig {
pub fn from_env() -> Self {
Self {
api_key: env::var("OPENAI_API_KEY").expect("OPENAI_API_KEY must be set"),
base_url: env::var("OPENAI_BASE_URL")
.unwrap_or_else(|_| "https://api.openai.com/v1".to_string()),
}
}
pub fn new(api_key: String, base_url: String) -> Self {
Self { api_key, base_url }
}
}
impl OpenAiCompatConfig for OpenAiConfig {
fn base_url(&self) -> &str {
&self.base_url
}
fn api_key(&self) -> &str {
&self.api_key
}
fn provider_name(&self) -> &'static str {
"openai"
}
fn supports_json_schema(&self) -> bool {
true
}
fn default_model(&self) -> &str {
OpenAiModel::GPT_5_5
}
fn small_model(&self) -> &str {
OpenAiModel::GPT_5_4_MINI
}
}
pub struct MistralConfig {
api_key: String,
}
impl MistralConfig {
pub fn from_env() -> Self {
Self {
api_key: env::var("MISTRAL_API_KEY").expect("MISTRAL_API_KEY must be set"),
}
}
pub fn new(api_key: String) -> Self {
Self { api_key }
}
}
impl OpenAiCompatConfig for MistralConfig {
fn base_url(&self) -> &str {
"https://api.mistral.ai/v1"
}
fn api_key(&self) -> &str {
&self.api_key
}
fn provider_name(&self) -> &'static str {
"mistral"
}
fn supports_json_schema(&self) -> bool {
false
}
fn default_model(&self) -> &str {
MistralModel::MEDIUM_3_5
}
fn small_model(&self) -> &str {
MistralModel::SMALL
}
}
pub struct NvidiaModel;
impl NvidiaModel {
pub const GLM_5_1: &str = "z-ai/glm-5.1";
pub const KIMI_K2_6: &str = "moonshotai/kimi-k2.6";
pub const DEEPSEEK_V4_PRO: &str = "deepseek-ai/deepseek-v4-pro";
pub const DEEPSEEK_V4_FLASH: &str = "deepseek-ai/deepseek-v4-flash";
pub const QWEN3_5_397B: &str = "qwen/qwen3.5-397b-a17b";
pub const QWEN3_5_122B: &str = "qwen/qwen3.5-122b-a10b";
pub const QWEN3_CODER: &str = "qwen/qwen3-coder-480b-a35b-instruct";
pub const QWEN3_NEXT: &str = "qwen/qwen3-next-80b-a3b-instruct";
pub const GEMMA_4_31B: &str = "google/gemma-4-31b-it";
pub const GEMMA_3N_E4B: &str = "google/gemma-3n-e4b-it";
pub const GEMMA_3_12B: &str = "google/gemma-3-12b-it";
pub const LLAMA_4_MAVERICK: &str = "meta/llama-4-maverick-17b-128e-instruct";
pub const LLAMA_3_3_70B: &str = "meta/llama-3.3-70b-instruct";
pub const LLAMA_3_1_8B: &str = "meta/llama-3.1-8b-instruct";
pub const NEMOTRON_ULTRA_253B: &str = "nvidia/llama-3.1-nemotron-ultra-253b-v1";
pub const NEMOTRON_SUPER_49B: &str = "nvidia/llama-3.3-nemotron-super-49b-v1.5";
pub const NEMOTRON_3_SUPER_120B: &str = "nvidia/nemotron-3-super-120b-a12b";
pub const NEMOTRON_NANO_9B: &str = "nvidia/nvidia-nemotron-nano-9b-v2";
pub const MINIMAX_M2_7: &str = "minimaxai/minimax-m2.7";
pub const GPT_OSS_120B: &str = "openai/gpt-oss-120b";
pub const MISTRAL_LARGE_3: &str = "mistralai/mistral-large-3-675b-instruct-2512";
pub const MISTRAL_MEDIUM_3_5: &str = "mistralai/mistral-medium-3.5-128b";
pub const STEP_3_5_FLASH: &str = "stepfun-ai/step-3.5-flash";
pub const SEED_OSS_36B: &str = "bytedance/seed-oss-36b-instruct";
}
pub struct NvidiaConfig {
api_key: String,
}
impl NvidiaConfig {
pub fn from_env() -> Self {
Self {
api_key: env::var("NVIDIA_API_KEY").expect("NVIDIA_API_KEY must be set"),
}
}
pub fn new(api_key: String) -> Self {
Self { api_key }
}
}
impl OpenAiCompatConfig for NvidiaConfig {
fn base_url(&self) -> &str {
"https://integrate.api.nvidia.com/v1"
}
fn api_key(&self) -> &str {
&self.api_key
}
fn provider_name(&self) -> &'static str {
"nvidia"
}
fn supports_json_schema(&self) -> bool {
false
}
fn default_model(&self) -> &str {
NvidiaModel::DEEPSEEK_V4_FLASH
}
fn small_model(&self) -> &str {
NvidiaModel::NEMOTRON_NANO_9B
}
}