pub enum Provider {
OpenAi,
OpenRouter {
app_url: Option<String>,
app_name: Option<String>,
},
Custom {
base_url: String,
},
}Expand description
Endpoint provider target.
Variants§
OpenAi
Official OpenAI API endpoint (https://api.openai.com/v1).
OpenRouter
OpenRouter API endpoint (https://openrouter.ai/api/v1) with optional attribution headers.
Fields
Custom
Any custom OpenAI-compatible server (e.g. vLLM, Ollama, Groq, Together, DeepSeek).
Implementations§
Source§impl Provider
impl Provider
Sourcepub fn openrouter() -> Self
pub fn openrouter() -> Self
Create an OpenRouter provider with default settings.
Sourcepub fn openrouter_with_attribution(
app_url: impl Into<String>,
app_name: impl Into<String>,
) -> Self
pub fn openrouter_with_attribution( app_url: impl Into<String>, app_name: impl Into<String>, ) -> Self
Create an OpenRouter provider with site URL and application name for OpenRouter rankings.
Sourcepub fn custom(base_url: impl Into<String>) -> Self
pub fn custom(base_url: impl Into<String>) -> Self
Create a custom OpenAI-compatible provider with a specific base URL.
Sourcepub fn default_env_var(&self) -> Option<&'static str>
pub fn default_env_var(&self) -> Option<&'static str>
Returns the canonical environment variable name for this provider’s API key.
Sourcepub fn endpoint_url(&self, path: &str) -> Result<Url, ClientError>
pub fn endpoint_url(&self, path: &str) -> Result<Url, ClientError>
Constructs a full URL for a given relative path (e.g. /chat/completions).
Sourcepub fn apply_headers(
&self,
headers: &mut HeaderMap,
api_key: Option<&str>,
) -> Result<(), ClientError>
pub fn apply_headers( &self, headers: &mut HeaderMap, api_key: Option<&str>, ) -> Result<(), ClientError>
Injects authentication and provider-specific headers into a request header map.
Trait Implementations§
impl Eq for Provider
impl StructuralPartialEq for Provider
Auto Trait Implementations§
impl Freeze for Provider
impl RefUnwindSafe for Provider
impl Send for Provider
impl Sync for Provider
impl Unpin for Provider
impl UnsafeUnpin for Provider
impl UnwindSafe for Provider
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more