Skip to main content

ModelProvider

Enum ModelProvider 

Source
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

Fields

§base_url: String
§api_key: Option<String>
§project_id: Option<String>
§

AzureOpenAI

Fields

§base_url: String
§api_key: Option<String>
§deployment: String
§api_version: String
§

Anthropic

Fields

§base_url: Option<String>
§api_key: Option<String>
§

Gemini

Fields

§base_url: String
§api_key: Option<String>
§

AzureAiFoundry

Fields

§resource: String

Azure resource name (e.g. distri-tts-resource), not a URL. Every endpoint URL is derived from this — see ModelProvider::completion_url / ModelProvider::tts_url.

§api_key: Option<String>
§

AwsBedrock

Fields

§base_url: String
§api_key: Option<String>
§

GoogleVertex

Fields

§base_url: String
§api_key: Option<String>
§project_id: Option<String>
§

AlibabaCloud

Fields

§base_url: String
§api_key: Option<String>
§

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>.

Fields

§api_key: Option<String>

Implementations§

Source§

impl ModelProvider

Source

pub fn openai_base_url() -> String

Source

pub fn anthropic_base_url() -> Option<String>

Source

pub fn gemini_base_url() -> String

Source

pub fn azure_api_version() -> String

Source

pub fn alibaba_cloud_base_url() -> String

Source

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>.

Source

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.

Source

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.

Source

pub fn provider_type(&self) -> ProviderType

Returns the provider type enum for this provider.

Source

pub fn provider_id(&self) -> &str

Returns the provider ID string for secret lookup and “provider/model” format.

Source

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.

Source

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.

Source

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.

Source

pub fn azure_ai_foundry_resource(&self) -> Option<&str>

Azure AI Foundry resource name, if this is that provider.

Source

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.

Source

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.

Source

pub fn stt_url(&self) -> Option<String>

Resolved STT base URL — see ModelProvider::tts_url.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn display_name(&self) -> &'static str

Get the human-readable name for a provider

Source

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

Source§

fn clone(&self) -> ModelProvider

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ModelProvider

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ModelProvider

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for ModelProvider

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl JsonSchema for ModelProvider

Source§

fn schema_name() -> Cow<'static, str>

The name of the generated JSON Schema. Read more
Source§

fn schema_id() -> Cow<'static, str>

Returns a string that uniquely identifies the schema produced by this type. Read more
Source§

fn json_schema(generator: &mut SchemaGenerator) -> Schema

Generates a JSON Schema for this type. Read more
Source§

fn inline_schema() -> bool

Whether JSON Schemas generated for this type should be included directly in parent schemas, rather than being re-used where possible using the $ref keyword. Read more
Source§

impl Serialize for ModelProvider

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more