pub enum ModelProvider {
OpenAI {},
OpenAICompatible {
base_url: String,
api_key: Option<String>,
project_id: Option<String>,
},
AzureOpenAI {
base_url: String,
api_key: Option<String>,
deployment: String,
api_version: String,
},
Anthropic {
base_url: Option<String>,
api_key: Option<String>,
},
Gemini {
base_url: String,
api_key: Option<String>,
},
AzureAiFoundry {
resource: String,
api_key: Option<String>,
},
AwsBedrock {
base_url: String,
api_key: Option<String>,
},
GoogleVertex {
base_url: String,
api_key: Option<String>,
project_id: Option<String>,
},
AlibabaCloud {
base_url: String,
api_key: Option<String>,
},
FalAi {
api_key: Option<String>,
},
}Variants§
OpenAI
OpenAICompatible
AzureOpenAI
Anthropic
Gemini
AzureAiFoundry
Fields
resource: StringAzure resource name (e.g. distri-tts-resource), not a URL.
Every endpoint URL is derived from this — see
ModelProvider::completion_url / ModelProvider::tts_url.
AwsBedrock
GoogleVertex
AlibabaCloud
FalAi
fal.ai — image-generation provider. The model id is the fal endpoint
path (e.g. fal-ai/flux/dev); the gateway POSTs to
https://fal.run/<model_id> with Authorization: Key <api_key>.
Implementations§
Source§impl ModelProvider
impl ModelProvider
pub fn openai_base_url() -> String
pub fn anthropic_base_url() -> Option<String>
pub fn gemini_base_url() -> String
pub fn azure_api_version() -> String
pub fn alibaba_cloud_base_url() -> String
Sourcepub fn fal_ai_base_url() -> &'static str
pub fn fal_ai_base_url() -> &'static str
fal.ai sync invocation root. The full URL is
https://fal.run/<model_id>; auth is Authorization: Key <key>.
Sourcepub fn api_key_slot_mut(&mut self) -> Option<&mut Option<String>>
pub fn api_key_slot_mut(&mut self) -> Option<&mut Option<String>>
Mutable reference to this provider’s api_key slot, if any.
Plain OpenAI returns None because it uses an env var directly.
Sourcepub fn base_url_slot_mut(&mut self) -> Option<&mut String>
pub fn base_url_slot_mut(&mut self) -> Option<&mut String>
Mutable reference to this provider’s base_url slot when it
participates in endpoint-secret hydration. Anthropic’s
Option<String> base_url is excluded — it has a default and no
endpoint secret. Plain OpenAI has no base_url field.
Sourcepub fn provider_type(&self) -> ProviderType
pub fn provider_type(&self) -> ProviderType
Returns the provider type enum for this provider.
Sourcepub fn provider_id(&self) -> &str
pub fn provider_id(&self) -> &str
Returns the provider ID string for secret lookup and “provider/model” format.
Sourcepub fn api_key_secret(&self) -> &'static str
pub fn api_key_secret(&self) -> &'static str
The canonical secret-store key under which this provider’s API key lives.
Single source of truth. Every layer that needs to look up or
validate the API key MUST go through this method — the gateway
(ProviderClientConfig), workspace-level resolution
(WorkspaceStore::resolve_model_settings), and the validator
(required_secret_keys) all rely on it. The UI’s user-facing key list
in default_models.json is kept in sync with this via a unit test.
Sourcepub fn endpoint_secret(&self) -> Option<&'static str>
pub fn endpoint_secret(&self) -> Option<&'static str>
The canonical secret-store key for this provider’s endpoint URL, or
None if the provider has a fixed endpoint baked into the variant.
Only providers that require a tenant-specific endpoint (Azure, Bedrock,
Vertex) return Some; everything else uses a default base URL.
Sourcepub fn azure_ai_foundry_base_url(resource: &str) -> String
pub fn azure_ai_foundry_base_url(resource: &str) -> String
OpenAI-compatible API base URL for an Azure AI Foundry resource name.
Azure AI Foundry exposes the OpenAI v1 API at
https://<resource>.openai.azure.com/openai/v1 — one endpoint serving
chat completions and OpenAI-style audio (TTS/STT). The Foundry
project endpoint (*.services.ai.azure.com/api/projects/...) is the
Agents SDK surface and is deliberately not used for model calls.
Sourcepub fn azure_ai_foundry_resource(&self) -> Option<&str>
pub fn azure_ai_foundry_resource(&self) -> Option<&str>
Azure AI Foundry resource name, if this is that provider.
Sourcepub fn completion_url(&self) -> Option<String>
pub fn completion_url(&self) -> Option<String>
Resolved chat-completions base URL for providers whose endpoint is
derived from config (Azure AI Foundry) rather than user-supplied.
None means the caller should fall back to the provider’s own
base_url/default.
Sourcepub fn tts_url(&self) -> Option<String>
pub fn tts_url(&self) -> Option<String>
Resolved TTS base URL. Azure AI Foundry serves TTS on the same OpenAI-compatible endpoint as chat today; kept as a separate method so a future non-OpenAI surface (e.g. Azure Speech) changes only here.
Sourcepub fn stt_url(&self) -> Option<String>
pub fn stt_url(&self) -> Option<String>
Resolved STT base URL — see ModelProvider::tts_url.
Sourcepub fn image_url(&self) -> Option<String>
pub fn image_url(&self) -> Option<String>
Resolved image-generation base URL.
Azure AI Foundry exposes image generation on
https://<resource>.services.ai.azure.com/openai/v1 — a different
subdomain from chat/TTS (which use *.openai.azure.com). The image
dispatcher consults this method so a Foundry resource routes to the
right host without changing the chat path.
Sourcepub fn resolved_endpoint(&self) -> (Option<String>, Option<String>)
pub fn resolved_endpoint(&self) -> (Option<String>, Option<String>)
(base_url, api_key) for this provider — call after hydrate_creds.
base_url is the OpenAI-compatible endpoint to probe; used by the
/providers/test validation flow.
Sourcepub fn required_secret_keys(&self) -> Vec<&'static str>
pub fn required_secret_keys(&self) -> Vec<&'static str>
Returns the required secret keys for this provider — i.e. keys that
must resolve via the secret store or environment for the LLM call to
succeed. If the provider has an inline api_key already configured on
the provider variant, no secret lookup is required.
Sourcepub fn all_provider_definitions() -> Vec<ProviderSecretDefinition>
pub fn all_provider_definitions() -> Vec<ProviderSecretDefinition>
Returns all provider secret definitions — the built-in basics from
default_models.json merged with any registered extensions.
Sourcepub fn well_known_models() -> Vec<ProviderModels>
pub fn well_known_models() -> Vec<ProviderModels>
Returns the well-known models grouped by provider — the built-in
basics from default_models.json merged with registered extensions.
Sourcepub fn display_name(&self) -> &'static str
pub fn display_name(&self) -> &'static str
Get the human-readable name for a provider
Sourcepub fn otel_provider_name(&self) -> &'static str
pub fn otel_provider_name(&self) -> &'static str
OTel gen_ai.provider.name attribute value for this provider.
Uses the semantic convention identifiers from the 2025 GenAI spec.
Trait Implementations§
Source§impl Clone for ModelProvider
impl Clone for ModelProvider
Source§fn clone(&self) -> ModelProvider
fn clone(&self) -> ModelProvider
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ModelProvider
impl Debug for ModelProvider
Source§impl Default for ModelProvider
impl Default for ModelProvider
Source§impl<'de> Deserialize<'de> for ModelProvider
impl<'de> Deserialize<'de> for ModelProvider
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl JsonSchema for ModelProvider
impl JsonSchema for ModelProvider
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read more