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 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
Converts
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>
Converts
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 more