Skip to main content

ralph_workflow/agents/providers/
metadata.rs

1//! Provider Metadata
2//!
3//! Display names, prefixes, and authentication commands for each provider.
4
5use super::types::OpenCodeProviderType;
6
7impl OpenCodeProviderType {
8    /// Get the display name for this provider.
9    #[must_use]
10    pub const fn name(self) -> &'static str {
11        match self {
12            Self::OpenCodeZen => "OpenCode Zen",
13            Self::ZaiDirect => "Z.AI Direct",
14            Self::ZaiCodingPlan => "Z.AI Coding Plan",
15            Self::Moonshot => "Moonshot AI",
16            Self::MiniMax => "MiniMax",
17            Self::Anthropic => "Anthropic",
18            Self::OpenAI => "OpenAI",
19            Self::Google => "Google AI",
20            Self::GoogleVertex => "Google Vertex AI",
21            Self::AmazonBedrock => "Amazon Bedrock",
22            Self::AzureOpenAI => "Azure OpenAI",
23            Self::GithubCopilot => "GitHub Copilot",
24            Self::Groq => "Groq",
25            Self::Together => "Together AI",
26            Self::Fireworks => "Fireworks AI",
27            Self::Cerebras => "Cerebras",
28            Self::SambaNova => "SambaNova",
29            Self::DeepInfra => "DeepInfra",
30            Self::OpenRouter => "OpenRouter",
31            Self::Cloudflare => "Cloudflare Workers AI",
32            Self::Vercel => "Vercel AI Gateway",
33            Self::Helicone => "Helicone",
34            Self::ZenMux => "ZenMux",
35            Self::DeepSeek => "DeepSeek",
36            Self::Xai => "xAI",
37            Self::Mistral => "Mistral AI",
38            Self::Cohere => "Cohere",
39            Self::Perplexity => "Perplexity",
40            Self::AI21 => "AI21 Labs",
41            Self::VeniceAI => "Venice AI",
42            Self::HuggingFace => "HuggingFace",
43            Self::Replicate => "Replicate",
44            Self::Baseten => "Baseten",
45            Self::Cortecs => "Cortecs",
46            Self::Scaleway => "Scaleway",
47            Self::OVHcloud => "OVHcloud",
48            Self::IONet => "IO.NET",
49            Self::Nebius => "Nebius",
50            Self::SapAICore => "SAP AI Core",
51            Self::AzureCognitiveServices => "Azure Cognitive Services",
52            Self::Ollama => "Ollama",
53            Self::LMStudio => "LM Studio",
54            Self::OllamaCloud => "Ollama Cloud",
55            Self::LlamaCpp => "llama.cpp",
56            Self::Custom => "Custom",
57        }
58    }
59
60    /// Get authentication command/instructions for this provider.
61    #[must_use]
62    pub const fn auth_command(self) -> &'static str {
63        match self {
64            Self::OpenCodeZen => "Run: opencode auth login -> select 'OpenCode Zen'",
65            Self::ZaiDirect => "Run: opencode auth login -> select 'Z.AI' or 'Z.AI Coding Plan'",
66            Self::ZaiCodingPlan => "Run: opencode auth login -> select 'Z.AI Coding Plan'",
67            Self::Moonshot => {
68                "Set MOONSHOT_API_KEY or run: opencode auth login -> select 'Moonshot'"
69            }
70            Self::MiniMax => "Set MINIMAX_API_KEY or run: opencode auth login -> select 'MiniMax'",
71            Self::Anthropic => "Set ANTHROPIC_API_KEY environment variable",
72            Self::OpenAI => "Set OPENAI_API_KEY environment variable",
73            Self::Google => "Set GOOGLE_AI_API_KEY environment variable",
74            Self::GoogleVertex => {
75                "Configure GCP credentials: gcloud auth application-default login"
76            }
77            Self::AmazonBedrock => {
78                "Configure AWS credentials: aws configure or set AWS_ACCESS_KEY_ID"
79            }
80            Self::AzureOpenAI => "Set AZURE_OPENAI_API_KEY and AZURE_OPENAI_ENDPOINT",
81            Self::GithubCopilot => "Run: gh auth login (requires GitHub Copilot subscription)",
82            Self::Groq => "Set GROQ_API_KEY environment variable",
83            Self::Together => "Set TOGETHER_API_KEY environment variable",
84            Self::Fireworks => "Set FIREWORKS_API_KEY environment variable",
85            Self::Cerebras => "Set CEREBRAS_API_KEY environment variable",
86            Self::SambaNova => "Set SAMBANOVA_API_KEY environment variable",
87            Self::DeepInfra => "Set DEEPINFRA_API_KEY environment variable",
88            Self::OpenRouter => "Set OPENROUTER_API_KEY environment variable",
89            Self::Cloudflare => "Set CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN",
90            Self::Vercel => "Set VERCEL_API_KEY environment variable",
91            Self::Helicone => "Set HELICONE_API_KEY environment variable",
92            Self::ZenMux => "Set ZENMUX_API_KEY environment variable",
93            Self::DeepSeek => "Set DEEPSEEK_API_KEY environment variable",
94            Self::Xai => "Set XAI_API_KEY environment variable",
95            Self::Mistral => "Set MISTRAL_API_KEY environment variable",
96            Self::Cohere => "Set COHERE_API_KEY environment variable",
97            Self::Perplexity => "Set PERPLEXITY_API_KEY environment variable",
98            Self::AI21 => "Set AI21_API_KEY environment variable",
99            Self::VeniceAI => "Set VENICE_API_KEY environment variable",
100            Self::HuggingFace => "Set HUGGINGFACE_API_KEY environment variable",
101            Self::Replicate => "Set REPLICATE_API_TOKEN environment variable",
102            Self::Baseten => "Set BASETEN_API_KEY environment variable",
103            Self::Cortecs => "Set CORTECS_API_KEY environment variable",
104            Self::Scaleway => "Set SCALEWAY_API_KEY environment variable",
105            Self::OVHcloud => "Set OVHCLOUD_API_KEY environment variable",
106            Self::IONet => "Set IONET_API_KEY environment variable",
107            Self::Nebius => "Set NEBIUS_API_KEY environment variable",
108            Self::SapAICore => {
109                "Set AICORE_CLIENT_ID, AICORE_CLIENT_SECRET, AICORE_AUTH_URL, and AICORE_API_BASE"
110            }
111            Self::AzureCognitiveServices => {
112                "Set AZURE_COGNITIVE_SERVICES_KEY and AZURE_COGNITIVE_SERVICES_ENDPOINT"
113            }
114            Self::Ollama => "Ollama runs locally - no API key needed",
115            Self::LMStudio => "LM Studio runs locally - no API key needed",
116            Self::OllamaCloud => "Set OLLAMA_CLOUD_API_KEY environment variable",
117            Self::LlamaCpp => "llama.cpp runs locally - no API key needed",
118            Self::Custom => "Check provider documentation or run: opencode /connect",
119        }
120    }
121
122    /// Get the model prefix for this provider.
123    #[must_use]
124    pub const fn prefix(self) -> &'static str {
125        match self {
126            Self::OpenCodeZen => "opencode/",
127            Self::ZaiDirect => "zai/",
128            Self::ZaiCodingPlan => "zai-coding/",
129            Self::Moonshot => "moonshot/",
130            Self::MiniMax => "minimax/",
131            Self::Anthropic => "anthropic/",
132            Self::OpenAI => "openai/",
133            Self::Google => "google/",
134            Self::GoogleVertex => "google-vertex/",
135            Self::AmazonBedrock => "amazon-bedrock/",
136            Self::AzureOpenAI => "azure-openai/",
137            Self::GithubCopilot => "copilot/",
138            Self::Groq => "groq/",
139            Self::Together => "together/",
140            Self::Fireworks => "fireworks/",
141            Self::Cerebras => "cerebras/",
142            Self::SambaNova => "sambanova/",
143            Self::DeepInfra => "deep-infra/",
144            Self::OpenRouter => "openrouter/",
145            Self::Cloudflare => "cloudflare/",
146            Self::Vercel => "vercel/",
147            Self::Helicone => "helicone/",
148            Self::ZenMux => "zenmux/",
149            Self::DeepSeek => "deepseek/",
150            Self::Xai => "xai/",
151            Self::Mistral => "mistral/",
152            Self::Cohere => "cohere/",
153            Self::Perplexity => "perplexity/",
154            Self::AI21 => "ai21/",
155            Self::VeniceAI => "venice-ai/",
156            Self::HuggingFace => "huggingface/",
157            Self::Replicate => "replicate/",
158            Self::Baseten => "baseten/",
159            Self::Cortecs => "cortecs/",
160            Self::Scaleway => "scaleway/",
161            Self::OVHcloud => "ovhcloud/",
162            Self::IONet => "io-net/",
163            Self::Nebius => "nebius/",
164            Self::SapAICore => "sap-ai-core/",
165            Self::AzureCognitiveServices => "azure-cognitive-services/",
166            Self::Ollama => "ollama/",
167            Self::LMStudio => "lmstudio/",
168            Self::OllamaCloud => "ollama-cloud/",
169            Self::LlamaCpp => "llama.cpp/",
170            Self::Custom => "any other provider/*",
171        }
172    }
173
174    /// Check if this provider requires special cloud configuration.
175    #[must_use]
176    pub const fn requires_cloud(self) -> bool {
177        matches!(
178            self,
179            Self::GoogleVertex
180                | Self::AmazonBedrock
181                | Self::AzureOpenAI
182                | Self::SapAICore
183                | Self::AzureCognitiveServices
184        )
185    }
186
187    /// Check if this is a local provider (no API key needed).
188    #[must_use]
189    pub const fn is_local(self) -> bool {
190        matches!(self, Self::Ollama | Self::LMStudio | Self::LlamaCpp)
191    }
192}