AzureOpenAIProviderSettings

Struct AzureOpenAIProviderSettings 

Source
pub struct AzureOpenAIProviderSettings {
    pub resource_name: Option<String>,
    pub base_url: Option<String>,
    pub api_key: Option<String>,
    pub headers: Option<HashMap<String, String>>,
    pub api_version: String,
    pub use_deployment_based_urls: bool,
}
Expand description

Configuration options for creating an Azure OpenAI provider.

Azure OpenAI has unique authentication and URL patterns compared to standard OpenAI:

  • Uses api-key header instead of Authorization: Bearer
  • Requires API version in query parameters
  • Supports both deployment-based and v1 API URL formats
  • Can use either resourceName or custom baseURL

Fields§

§resource_name: Option<String>

Name of the Azure OpenAI resource. Either this or base_url can be used.

The resource name is used in the assembled URL: https://{resource_name}.openai.azure.com/openai/v1{path}

§base_url: Option<String>

Use a different URL prefix for API calls, e.g. to use proxy servers. Either this or resource_name can be used. When a base_url is provided, the resource_name is ignored.

With a base_url, the resolved URL is {base_url}/v1{path}.

§api_key: Option<String>

API key for authenticating requests. If not provided, will attempt to read from AZURE_API_KEY environment variable.

§headers: Option<HashMap<String, String>>

Custom headers to include in the requests.

§api_version: String

Custom API version to use. Defaults to “v1”.

Azure OpenAI requires an API version parameter in all requests. Common versions include “2023-05-15”, “2024-02-15-preview”, etc.

§use_deployment_based_urls: bool

Use deployment-based URLs for specific model types.

Set to true to use legacy deployment format: {base_url}/deployments/{deployment_id}{path}?api-version={api_version}

Set to false (default) to use v1 API format: {base_url}/v1{path}?api-version={api_version}

Implementations§

Source§

impl AzureOpenAIProviderSettings

Source

pub fn new() -> Self

Creates a new Azure OpenAI provider configuration.

You must provide either a resource_name or base_url before using the provider.

Source

pub fn with_resource_name(self, resource_name: impl Into<String>) -> Self

Sets the Azure OpenAI resource name.

The resource name is used to construct the base URL: https://{resource_name}.openai.azure.com/openai

Source

pub fn with_base_url(self, base_url: impl Into<String>) -> Self

Sets a custom base URL for API calls.

When set, this takes precedence over resource_name.

Source

pub fn with_api_key(self, api_key: impl Into<String>) -> Self

Sets the API key for authentication.

Source

pub fn with_headers(self, headers: HashMap<String, String>) -> Self

Sets additional headers to include in requests.

Source

pub fn with_header( self, key: impl Into<String>, value: impl Into<String>, ) -> Self

Adds a single header to include in requests.

Source

pub fn with_api_version(self, api_version: impl Into<String>) -> Self

Sets the API version to use in requests.

Defaults to “v1”. Common versions include “2023-05-15”, “2024-02-15-preview”, etc.

Source

pub fn with_use_deployment_based_urls( self, use_deployment_based_urls: bool, ) -> Self

Sets whether to use deployment-based URLs.

When true, uses format: {base_url}/deployments/{deployment_id}{path} When false (default), uses format: {base_url}/v1{path}

Trait Implementations§

Source§

impl Clone for AzureOpenAIProviderSettings

Source§

fn clone(&self) -> AzureOpenAIProviderSettings

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AzureOpenAIProviderSettings

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for AzureOpenAIProviderSettings

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,