pub enum Provider {
Anthropic,
OpenAI,
OpenAIApi,
OllamaCloud,
Groq,
Mistral,
Together,
OpenRouter,
DeepSeek,
Fireworks,
Gemini,
Local,
}Variants§
Anthropic
Anthropic claude.ai — OAuth, Anthropic wire format.
OpenAI
OpenAI chatgpt.com — OAuth, OpenAI-compat wire format.
OpenAIApi
OpenAI API (api.openai.com) — API key, OpenAI-compat wire format.
OllamaCloud
Ollama Cloud (api.ollama.com) — API key, OpenAI-compat wire format.
Groq
Groq (api.groq.com) — API key, OpenAI-compat wire format.
Mistral
Mistral AI (api.mistral.ai) — API key, OpenAI-compat wire format.
Together
Together AI (api.together.xyz) — API key, OpenAI-compat wire format.
OpenRouter
OpenRouter (openrouter.ai) — API key, OpenAI-compat wire format.
DeepSeek
DeepSeek (api.deepseek.com) — API key, OpenAI-compat wire format.
Fireworks
Fireworks AI (api.fireworks.ai) — API key, OpenAI-compat wire format.
Gemini
Google Gemini (generativelanguage.googleapis.com) — API key, OpenAI-compat wire format.
Local
Generic local OpenAI-compatible server (Ollama local, LM Studio, llama.cpp).
Implementations§
Source§impl Provider
impl Provider
pub fn from_str(s: &str) -> Self
Sourcepub fn wire_protocol(&self) -> WireProtocol
pub fn wire_protocol(&self) -> WireProtocol
Wire protocol used for requests/responses.
Sourcepub fn default_model(&self) -> &'static str
pub fn default_model(&self) -> &'static str
Default model name to use when the incoming request specifies a claude-*
model that doesn’t exist on this provider.
Returns "" for Local — the model name is passed through unchanged so
the local server decides what to serve.
Sourcepub fn accepts_claude_models(&self) -> bool
pub fn accepts_claude_models(&self) -> bool
True when this provider understands claude-* model names natively.
When false, incoming claude-* model names are remapped before forwarding.
Sourcepub fn api_key_env_var(&self) -> Option<&'static str>
pub fn api_key_env_var(&self) -> Option<&'static str>
Well-known environment variable that holds an API key for this provider.
None for OAuth and Local providers.
Sourcepub fn default_upstream_url(&self) -> &'static str
pub fn default_upstream_url(&self) -> &'static str
Default upstream API base URL.
Sourcepub fn default_port(&self) -> u16
pub fn default_port(&self) -> u16
Default local proxy port (used when multiple providers are active).
Sourcepub fn inject_auth_headers(
&self,
headers: &mut HeaderMap,
token: &str,
) -> Result<()>
pub fn inject_auth_headers( &self, headers: &mut HeaderMap, token: &str, ) -> Result<()>
Inject provider-specific auth and protocol headers into an upstream request.
Called by the forwarder before each proxied request. The live token has already been retrieved by the caller.
Sourcepub fn prefetch_extra_headers(&self) -> &'static [(&'static str, &'static str)]
pub fn prefetch_extra_headers(&self) -> &'static [(&'static str, &'static str)]
Additional non-auth headers required for prefetch requests (not normal proxy requests).
Returns (header-name, header-value) pairs as static strings.
Sourcepub fn prefetch_request(&self) -> Option<(&'static str, Value)>
pub fn prefetch_request(&self) -> Option<(&'static str, Value)>
Path and minimal JSON body for a prefetch request that returns rate-limit headers.
Returns None if this provider doesn’t support prefetching.
Sourcepub fn auth_probe_get_path(&self) -> Option<&'static str>
pub fn auth_probe_get_path(&self) -> Option<&'static str>
GET path for a lightweight auth-validity check (no rate-limit data expected).
Used for providers where prefetch_request is unavailable.
Sourcepub fn parse_rate_limits(&self, headers: &HeaderMap) -> Option<RateLimitInfo>
pub fn parse_rate_limits(&self, headers: &HeaderMap) -> Option<RateLimitInfo>
Extract rate-limit utilization from an upstream response’s headers.
Returns None when the response carries no recognisable rate-limit data.
Sourcepub fn read_local_credentials(&self) -> Option<Credential>
pub fn read_local_credentials(&self) -> Option<Credential>
Read credentials from the provider’s local CLI tool or well-known environment variable.
- OAuth providers: import from the provider’s local CLI auth store.
- API-key providers: read from the well-known environment variable.
- Local provider: always returns
None(no auth needed).
Sourcepub async fn refresh_token(
&self,
cred: &OAuthCredential,
) -> Result<OAuthCredential>
pub async fn refresh_token( &self, cred: &OAuthCredential, ) -> Result<OAuthCredential>
Refresh an expired access token using the provider’s token endpoint.
Only applicable to OAuth providers. Returns an error for API-key and Local providers.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Provider
impl<'de> Deserialize<'de> for Provider
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>,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
CompactString. Read moreSource§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.