pub struct FoundryChatClient { /* private fields */ }Expand description
A ChatClient for the Azure AI Foundry project Responses API.
A thin wrapper around AzureOpenAIResponsesClient: constructs it
against the Foundry project endpoint and model (deployment) with
without_api_version
applied (see the module docs). All request building, response
parsing, SSE streaming, and HTTP-error classification are reused verbatim
from that client — this type adds nothing beyond Foundry-shaped
constructors and a plain delegating ChatClient impl.
Implementations§
Source§impl FoundryChatClient
impl FoundryChatClient
Sourcepub fn new(
endpoint: impl Into<String>,
model: impl Into<String>,
api_key: impl Into<String>,
) -> Self
pub fn new( endpoint: impl Into<String>, model: 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>,
model: impl Into<String>,
credential: Arc<dyn TokenCredential>,
) -> Self
pub fn with_token_credential( endpoint: impl Into<String>, model: impl Into<String>, credential: Arc<dyn TokenCredential>, ) -> Self
Create a client authenticating via a TokenCredential (Microsoft
Entra ID Authorization: Bearer <token>) — the primary Foundry auth
path. The credential should already be scoped to FOUNDRY_SCOPE,
e.g. AzureCliCredential::new(FOUNDRY_SCOPE).
Sourcepub fn from_env() -> Result<Self>
pub fn from_env() -> Result<Self>
Build a client from environment variables.
Reads FOUNDRY_ENDPOINT (alias FOUNDRY_PROJECT_ENDPOINT) and
FOUNDRY_MODEL — the FOUNDRY_*/model naming mirrors upstream’s
shift away from the old AZURE_AI_*/model_deployment_name
convention. When FOUNDRY_API_KEY is set it authenticates with that
key; otherwise it falls back to a
DefaultAzureCredential
scoped to FOUNDRY_SCOPE (a chain that tries a managed identity,
then client-secret env vars, then the Azure CLI).
§Errors
Error::Configuration when neither endpoint variable, or
FOUNDRY_MODEL, is set.
Sourcepub fn with_base_url(self, base_url: impl Into<String>) -> Self
pub fn with_base_url(self, base_url: impl Into<String>) -> Self
Override the full base URL requests are built against — see
AzureOpenAIResponsesClient::with_base_url.
Sourcepub fn model_name(&self) -> &str
pub fn model_name(&self) -> &str
The model deployment name this client targets.
Trait Implementations§
Source§impl ChatClient for FoundryChatClient
impl ChatClient for FoundryChatClient
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,
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,
Source§impl Clone for FoundryChatClient
impl Clone for FoundryChatClient
Source§fn clone(&self) -> FoundryChatClient
fn clone(&self) -> FoundryChatClient
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more