pub struct AzureOpenAIClient { /* private fields */ }Expand description
An Azure OpenAI chat client
(POST {endpoint}/openai/deployments/{deployment}/chat/completions).
Implementations§
Source§impl AzureOpenAIClient
impl AzureOpenAIClient
Sourcepub fn new(
endpoint: impl Into<String>,
deployment: impl Into<String>,
api_key: impl Into<String>,
) -> Self
pub fn new( endpoint: impl Into<String>, deployment: impl Into<String>, api_key: impl Into<String>, ) -> Self
Create a client authenticating with a static API key
(api-key header).
Sourcepub fn with_token_credential(
endpoint: impl Into<String>,
deployment: impl Into<String>,
credential: Arc<dyn TokenCredential>,
) -> Self
pub fn with_token_credential( endpoint: impl Into<String>, deployment: impl Into<String>, credential: Arc<dyn TokenCredential>, ) -> Self
Create a client authenticating via a TokenCredential
(Authorization: Bearer <token>, e.g. Microsoft Entra ID).
Sourcepub fn from_env() -> Result<Self>
pub fn from_env() -> Result<Self>
Build an API-key-authenticated client from AZURE_OPENAI_ENDPOINT,
AZURE_OPENAI_API_KEY, AZURE_OPENAI_CHAT_DEPLOYMENT_NAME, and
optional AZURE_OPENAI_API_VERSION.
Sourcepub fn with_api_version(self, api_version: impl Into<String>) -> Self
pub fn with_api_version(self, api_version: impl Into<String>) -> Self
Override the API version (default "2024-10-21").
Sourcepub fn deployment(&self) -> &str
pub fn deployment(&self) -> &str
The deployment name this client targets.
Sourcepub fn api_version(&self) -> &str
pub fn api_version(&self) -> &str
The API version this client sends.
Trait Implementations§
Source§impl ChatClient for AzureOpenAIClient
impl ChatClient for AzureOpenAIClient
Source§fn get_response<'life0, 'async_trait>(
&'life0 self,
messages: Vec<Message>,
options: ChatOptions,
) -> Pin<Box<dyn Future<Output = Result<ChatResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_response<'life0, 'async_trait>(
&'life0 self,
messages: Vec<Message>,
options: ChatOptions,
) -> Pin<Box<dyn Future<Output = Result<ChatResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Get a complete (non-streaming) response.
Source§fn get_streaming_response<'life0, 'async_trait>(
&'life0 self,
messages: Vec<Message>,
options: ChatOptions,
) -> Pin<Box<dyn Future<Output = Result<ChatStream>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_streaming_response<'life0, 'async_trait>(
&'life0 self,
messages: Vec<Message>,
options: ChatOptions,
) -> Pin<Box<dyn Future<Output = Result<ChatStream>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Get a streaming response as a sequence of updates.
Source§impl Clone for AzureOpenAIClient
impl Clone for AzureOpenAIClient
Auto Trait Implementations§
impl !RefUnwindSafe for AzureOpenAIClient
impl !UnwindSafe for AzureOpenAIClient
impl Freeze for AzureOpenAIClient
impl Send for AzureOpenAIClient
impl Sync for AzureOpenAIClient
impl Unpin for AzureOpenAIClient
impl UnsafeUnpin for AzureOpenAIClient
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