pub struct AzureAuth { /* private fields */ }Expand description
Azure OpenAI API authentication configuration
Handles authentication for Azure OpenAI Service, which uses different header names and endpoint URL patterns than the standard OpenAI API.
§Header Format
api-key: {key}§Endpoint Format
The base_url should be a complete endpoint URL including deployment path,
API path (e.g., /chat/completions), and query parameters (e.g., ?api-version=...).
The endpoint() method returns this URL as-is.
§Example
use openai_tools::common::auth::AzureAuth;
// For Chat API
let auth = AzureAuth::new(
"your-api-key",
"https://my-resource.openai.azure.com/openai/deployments/gpt-4o/chat/completions?api-version=2024-08-01-preview"
);
// For Embedding API
let auth = AzureAuth::new(
"your-api-key",
"https://my-resource.openai.azure.com/openai/deployments/text-embedding/embeddings?api-version=2024-08-01-preview"
);Implementations§
Source§impl AzureAuth
impl AzureAuth
Sourcepub fn new<T: Into<String>>(api_key: T, base_url: T) -> Self
pub fn new<T: Into<String>>(api_key: T, base_url: T) -> Self
Creates a new Azure OpenAI authentication configuration
§Arguments
api_key- Azure OpenAI API keybase_url- Complete endpoint URL including deployment path, API path, and api-version
§Returns
A new AzureAuth instance
§Example
use openai_tools::common::auth::AzureAuth;
// Complete endpoint URL for Chat API
let auth = AzureAuth::new(
"your-api-key",
"https://my-resource.openai.azure.com/openai/deployments/gpt-4o/chat/completions?api-version=2024-08-01-preview"
);Trait Implementations§
Auto Trait Implementations§
impl Freeze for AzureAuth
impl RefUnwindSafe for AzureAuth
impl Send for AzureAuth
impl Sync for AzureAuth
impl Unpin for AzureAuth
impl UnsafeUnpin for AzureAuth
impl UnwindSafe for AzureAuth
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