Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Azure OpenAI Token Authentication #329

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

Verticaleap
Copy link

Overview

This pull requests extends the Azure OpenAI Client to provide authentication via token.

References:

https://learn.microsoft.com/en-us/azure/ai-services/openai/reference#authentication

Add authentication via token for Azure OpenAI.
@Verticaleap Verticaleap marked this pull request as draft February 28, 2025 21:46
@Verticaleap Verticaleap marked this pull request as ready for review February 28, 2025 23:27
@0xMochan
Copy link
Contributor

0xMochan commented Mar 1, 2025

Thanks for the PR, most of the team is traveling but we'll get this reviewed as soon as we are back!

Copy link
Contributor

@0xMochan 0xMochan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly some ergonomic suggesitions

/// * `api_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
pub fn new(api_key: &str, api_version: &str, azure_endpoint: &str) -> Self {
pub fn new(auth: AzureOpenAIAuth, api_version: &str, azure_endpoint: &str) -> Self {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there's two forms of auth, I think there should be 2 additional methods that take in either api_key: &str or token: &str.

new would be the same, taking in auth (could also consider changing into impl Into<AzureOpenAIAuth> choosing a reasonable default for strings too for backwards compat).

Then from_api_key and from_token would define specific versions of the enum directly which is self-documenting and also user-friendly (no need to deal with the enum directly).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All docs with Client::new should either be reverted if impl Into<...> is added OR using one of the new constructors being added.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants