pub struct Client { /* private fields */ }
Implementations§
Source§impl Client
impl Client
Sourcepub fn new(
auth: impl Into<AzureOpenAIAuth>,
api_version: &str,
azure_endpoint: &str,
) -> Self
pub fn new( auth: impl Into<AzureOpenAIAuth>, api_version: &str, azure_endpoint: &str, ) -> Self
Creates a new Azure OpenAI client.
§Arguments
auth
- Azure OpenAI API key or token required for authenticationapi_version
- API version to use (e.g., “2024-10-21” for GA, “2024-10-01-preview” for preview)azure_endpoint
- Azure OpenAI endpoint URL, for example: https://{your-resource-name}.openai.azure.com
Sourcepub fn with_custom_client(self, client: Client) -> Self
pub fn with_custom_client(self, client: Client) -> Self
Use your own reqwest::Client
.
The required headers will be automatically attached upon trying to make a request.
Sourcepub fn from_api_key(
api_key: &str,
api_version: &str,
azure_endpoint: &str,
) -> Self
pub fn from_api_key( api_key: &str, api_version: &str, azure_endpoint: &str, ) -> Self
Creates a new Azure OpenAI client from an API key.
§Arguments
api_key
- Azure OpenAI API key required for authenticationapi_version
- API version to use (e.g., “2024-10-21” for GA, “2024-10-01-preview” for preview)azure_endpoint
- Azure OpenAI endpoint URL
Sourcepub fn from_token(token: &str, api_version: &str, azure_endpoint: &str) -> Self
pub fn from_token(token: &str, api_version: &str, azure_endpoint: &str) -> Self
Creates a new Azure OpenAI client from a token.
§Arguments
token
- Azure OpenAI token required for authenticationapi_version
- API version to use (e.g., “2024-10-21” for GA, “2024-10-01-preview” for preview)azure_endpoint
- Azure OpenAI endpoint URL
Trait Implementations§
Source§impl CompletionClient for Client
impl CompletionClient for Client
Source§fn completion_model(&self, model: &str) -> CompletionModel
fn completion_model(&self, model: &str) -> CompletionModel
Create a completion model with the given name.
§Example
use rig::providers::azure::{Client, self};
// Initialize the Azure OpenAI client
let azure = Client::new("YOUR_API_KEY", "YOUR_API_VERSION", "YOUR_ENDPOINT");
let gpt4 = azure.completion_model(azure::GPT_4);
Source§type CompletionModel = CompletionModel
type CompletionModel = CompletionModel
Source§fn agent(&self, model: &str) -> AgentBuilder<Self::CompletionModel>
fn agent(&self, model: &str) -> AgentBuilder<Self::CompletionModel>
Source§fn extractor<T: JsonSchema + for<'a> Deserialize<'a> + Serialize + Send + Sync>(
&self,
model: &str,
) -> ExtractorBuilder<T, Self::CompletionModel>
fn extractor<T: JsonSchema + for<'a> Deserialize<'a> + Serialize + Send + Sync>( &self, model: &str, ) -> ExtractorBuilder<T, Self::CompletionModel>
Source§impl EmbeddingsClient for Client
impl EmbeddingsClient for Client
Source§fn embedding_model(&self, model: &str) -> EmbeddingModel
fn embedding_model(&self, model: &str) -> EmbeddingModel
Create an embedding model with the given name.
Note: default embedding dimension of 0 will be used if model is not known.
If this is the case, it’s better to use function embedding_model_with_ndims
§Example
use rig::providers::azure::{Client, self};
// Initialize the Azure OpenAI client
let azure = Client::new("YOUR_API_KEY", "YOUR_API_VERSION", "YOUR_ENDPOINT");
let embedding_model = azure.embedding_model(azure::TEXT_EMBEDDING_3_LARGE);
Source§fn embedding_model_with_ndims(
&self,
model: &str,
ndims: usize,
) -> EmbeddingModel
fn embedding_model_with_ndims( &self, model: &str, ndims: usize, ) -> EmbeddingModel
Create an embedding model with the given name and the number of dimensions in the embedding generated by the model.
§Example
use rig::providers::azure::{Client, self};
// Initialize the Azure OpenAI client
let azure = Client::new("YOUR_API_KEY", "YOUR_API_VERSION", "YOUR_ENDPOINT");
let embedding_model = azure.embedding_model("model-unknown-to-rig", 3072);
Source§type EmbeddingModel = EmbeddingModel
type EmbeddingModel = EmbeddingModel
Source§fn embeddings<D: Embed>(
&self,
model: &str,
) -> EmbeddingsBuilder<Self::EmbeddingModel, D>
fn embeddings<D: Embed>( &self, model: &str, ) -> EmbeddingsBuilder<Self::EmbeddingModel, D>
Source§fn embeddings_with_ndims<D: Embed>(
&self,
model: &str,
ndims: usize,
) -> EmbeddingsBuilder<Self::EmbeddingModel, D>
fn embeddings_with_ndims<D: Embed>( &self, model: &str, ndims: usize, ) -> EmbeddingsBuilder<Self::EmbeddingModel, D>
Source§impl ProviderClient for Client
impl ProviderClient for Client
Source§fn from_env() -> Self
fn from_env() -> Self
Create a new Azure OpenAI client from the AZURE_API_KEY
or AZURE_TOKEN
, AZURE_API_VERSION
, and AZURE_ENDPOINT
environment variables.
Source§fn boxed(self) -> Box<dyn ProviderClient>where
Self: Sized + 'static,
fn boxed(self) -> Box<dyn ProviderClient>where
Self: Sized + 'static,
Source§fn from_env_boxed<'a>() -> Box<dyn ProviderClient + 'a>where
Self: Sized + 'a,
fn from_env_boxed<'a>() -> Box<dyn ProviderClient + 'a>where
Self: Sized + 'a,
Source§impl TranscriptionClient for Client
impl TranscriptionClient for Client
Source§fn transcription_model(&self, model: &str) -> TranscriptionModel
fn transcription_model(&self, model: &str) -> TranscriptionModel
Create a transcription model with the given name.
§Example
use rig::providers::azure::{Client, self};
// Initialize the Azure OpenAI client
let azure = Client::new("YOUR_API_KEY", "YOUR_API_VERSION", "YOUR_ENDPOINT");
let whisper = azure.transcription_model("model-unknown-to-rig");
Source§type TranscriptionModel = TranscriptionModel
type TranscriptionModel = TranscriptionModel
Auto Trait Implementations§
impl Freeze for Client
impl !RefUnwindSafe for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl !UnwindSafe for Client
Blanket Implementations§
Source§impl<T> AsCompletion for Twhere
T: CompletionClientDyn + Clone + 'static,
impl<T> AsCompletion for Twhere
T: CompletionClientDyn + Clone + 'static,
fn as_completion(&self) -> Option<Box<dyn CompletionClientDyn>>
Source§impl<T> AsEmbeddings for Twhere
T: EmbeddingsClientDyn + Clone + 'static,
impl<T> AsEmbeddings for Twhere
T: EmbeddingsClientDyn + Clone + 'static,
fn as_embeddings(&self) -> Option<Box<dyn EmbeddingsClientDyn>>
Source§impl<T> AsTranscription for Twhere
T: TranscriptionClientDyn + Clone + 'static,
impl<T> AsTranscription for Twhere
T: TranscriptionClientDyn + Clone + 'static,
fn as_transcription(&self) -> Option<Box<dyn TranscriptionClientDyn>>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T, M, R> CompletionClientDyn for Twhere
T: CompletionClient<CompletionModel = M>,
M: CompletionModel<StreamingResponse = R> + 'static,
R: Clone + Unpin + 'static,
impl<T, M, R> CompletionClientDyn for Twhere
T: CompletionClient<CompletionModel = M>,
M: CompletionModel<StreamingResponse = R> + 'static,
R: Clone + Unpin + 'static,
Source§fn completion_model<'a>(&self, model: &str) -> Box<dyn CompletionModelDyn + 'a>
fn completion_model<'a>(&self, model: &str) -> Box<dyn CompletionModelDyn + 'a>
Source§fn agent<'a>(&self, model: &str) -> AgentBuilder<CompletionModelHandle<'a>>
fn agent<'a>(&self, model: &str) -> AgentBuilder<CompletionModelHandle<'a>>
Source§impl<T, M> EmbeddingsClientDyn for Twhere
T: EmbeddingsClient<EmbeddingModel = M>,
M: EmbeddingModel + 'static,
impl<T, M> EmbeddingsClientDyn for Twhere
T: EmbeddingsClient<EmbeddingModel = M>,
M: EmbeddingModel + 'static,
Source§fn embedding_model<'a>(&self, model: &str) -> Box<dyn EmbeddingModelDyn + 'a>
fn embedding_model<'a>(&self, model: &str) -> Box<dyn EmbeddingModelDyn + 'a>
embedding_model_with_ndims