pub enum AuthMethod {
VirtualKey {
virtual_key: String,
},
ProviderAuth {
provider: String,
authorization: String,
custom_host: Option<String>,
},
Config {
config_id: String,
},
}Expand description
Authentication method for Portkey API.
Portkey supports multiple authentication methods for routing requests to different LLM providers.
Variants§
VirtualKey
Virtual Key authentication - managed provider credentials in Portkey.
Uses x-portkey-virtual-key header. Virtual keys are managed in the
Portkey dashboard and securely store provider API keys.
§Example
use portkey_sdk::builder::AuthMethod;
let auth = AuthMethod::VirtualKey {
virtual_key: "your-virtual-key".to_string(),
};ProviderAuth
Provider authentication with direct provider credentials.
Uses x-portkey-provider and Authorization headers to directly
authenticate with a provider.
§Example
use portkey_sdk::builder::AuthMethod;
let auth = AuthMethod::ProviderAuth {
provider: "openai".to_string(),
authorization: "Bearer sk-...".to_string(),
custom_host: None,
};Fields
Authorization header value (e.g., “Bearer sk-…”)
Config
Config-based authentication using Portkey configs.
Uses x-portkey-config header. Configs define complex routing,
fallback, and load balancing rules in the Portkey dashboard.
§Example
use portkey_sdk::builder::AuthMethod;
let auth = AuthMethod::Config {
config_id: "pc-config-123".to_string(),
};Implementations§
Source§impl AuthMethod
impl AuthMethod
Sourcepub fn virtual_key(virtual_key: impl Into<String>) -> Self
pub fn virtual_key(virtual_key: impl Into<String>) -> Self
Creates a virtual key authentication method.
§Example
use portkey_sdk::builder::AuthMethod;
let auth = AuthMethod::virtual_key("your-virtual-key");Sourcepub fn provider_auth(
provider: impl Into<String>,
authorization: impl Into<String>,
) -> Self
pub fn provider_auth( provider: impl Into<String>, authorization: impl Into<String>, ) -> Self
Creates a provider authentication method.
§Example
use portkey_sdk::builder::AuthMethod;
let auth = AuthMethod::provider_auth("openai", "Bearer sk-...");Sourcepub fn provider_auth_with_host(
provider: impl Into<String>,
authorization: impl Into<String>,
custom_host: impl Into<String>,
) -> Self
pub fn provider_auth_with_host( provider: impl Into<String>, authorization: impl Into<String>, custom_host: impl Into<String>, ) -> Self
Creates a provider authentication method with a custom host.
§Example
use portkey_sdk::builder::AuthMethod;
let auth = AuthMethod::provider_auth_with_host(
"openai",
"Bearer sk-...",
"https://custom.openai.com"
);Trait Implementations§
Source§impl Clone for AuthMethod
impl Clone for AuthMethod
Source§fn clone(&self) -> AuthMethod
fn clone(&self) -> AuthMethod
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more