pub struct AzureOpenAIResponsesClient { /* private fields */ }Expand description
An Azure OpenAI Responses API chat client
(POST {endpoint}/openai/v1/responses).
See the module docs for the URL/api-version rationale.
Implementations§
Source§impl AzureOpenAIResponsesClient
impl AzureOpenAIResponsesClient
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_RESPONSES_DEPLOYMENT_NAME, and
optional AZURE_OPENAI_API_VERSION/AZURE_OPENAI_BASE_URL — the same
generic AZURE_OPENAI_* variables
AzureOpenAIClient::from_env
reads, except for the Responses-specific deployment variable (mirrors
upstream’s responses_deployment_name settings field, distinct from
Chat Completions’ AZURE_OPENAI_CHAT_DEPLOYMENT_NAME, so a resource
with differently named deployments per API surface works;
azure/_shared.py:102-103, docstring at
azure/_responses_client.py:53-56).
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 "preview").
Sourcepub fn without_api_version(self) -> Self
pub fn without_api_version(self) -> Self
Send no api-version query parameter at all.
Microsoft’s v1 Responses examples call the bare
{endpoint}/openai/v1/responses URL, and the v1 lifecycle removes
dated api-version parameters — GA v1 resources and some
OpenAI-compatible gateways reject or misroute requests carrying one.
The "preview" default mirrors upstream Python
(_responses_client.py:112); use this to produce the documented
query-less URL instead. (Also reachable by setting the
AZURE_OPENAI_API_VERSION env var to an empty string with
from_env.)
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 used to build requests, taking precedence
over the endpoint-derived /openai/v1/ route. Mirrors upstream’s
base_url parameter, which “must end with /openai/v1/”
(azure/_responses_client.py:60-62) — e.g. for a differently-shaped
gateway or proxy in front of Azure OpenAI.
Sourcepub fn deployment(&self) -> &str
pub fn deployment(&self) -> &str
The deployment name this client targets (sent as the request body’s
model field; see the module docs).
Sourcepub fn api_version(&self) -> Option<&str>
pub fn api_version(&self) -> Option<&str>
The API version this client sends, or None when the query
parameter is omitted (see without_api_version).
Sourcepub fn base_url(&self) -> Option<&str>
pub fn base_url(&self) -> Option<&str>
The effective base URL requests are built against: the explicit
with_base_url override when set, otherwise
None (the endpoint-derived /openai/v1/ route is computed lazily by
url).