Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add Azure AD authentication support #92

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

Merged
merged 5 commits into from
Jun 24, 2022

Conversation

t-asutedjo
Copy link
Contributor

This PR adds support for authentication using azure active directory.

For azure_ad authentication the api_type needs to be set to "azure_ad" (or alternatively "azuread") and the credentials token needs to be passed to api_key. Similar to the azure key-based authentication, the api_version has to be specified

from azure.identity import DefaultAzureCredential
import openai

default_credential = DefaultAzureCredential(
    exclude_interactive_browser_credential=False)
token = default_credential.get_token("https://cognitiveservices.azure.com")

openai.api_type = "azure_ad"
openai.api_key = token.token
openai.api_version = "2022-03-01-preview"

openai.api_base = "https://your-endpoint.openai.azure.com/"

@t-asutedjo t-asutedjo marked this pull request as ready for review May 25, 2022 07:44
@t-asutedjo t-asutedjo requested a review from hallacy June 23, 2022 08:34
@hallacy
Copy link
Collaborator

hallacy commented Jun 23, 2022

@sorinsuciu-msft I think this looks good. Good to merge from your side?

GinoBacallao pushed a commit to GinoBacallao/openai-python that referenced this pull request Jun 24, 2022
* Make embeddings_utils be importable (openai#104)

* Make embeddings_utils be importable

* Small tweaks to dicts for typing

* Remove default api_prefix and move v1 prefix to default api_base (openai#95)

* make construct_from key argument optional (openai#92)

* Split search.prepare_data into answers/classifications/search versions (openai#93)

* Break out prepare_data into answers, classifications, and search

* And cleaned up CLI

* Validate search files (openai#69)

* Add validators for search files

* Clean up fields

Co-authored-by: kennyhsu5 <[email protected]>
Co-authored-by: Madeleine Thompson <[email protected]>
@sorinsuciu-msft
Copy link
Contributor

@sorinsuciu-msft I think this looks good. Good to merge from your side?

Yes, looks good to me, thank you.

@hallacy hallacy merged commit 53e5ba4 into openai:main Jun 24, 2022
cgayapr pushed a commit to cgayapr/openai-python that referenced this pull request Dec 14, 2024
* Make embeddings_utils be importable (openai#104)

* Make embeddings_utils be importable

* Small tweaks to dicts for typing

* Remove default api_prefix and move v1 prefix to default api_base (openai#95)

* make construct_from key argument optional (openai#92)

* Split search.prepare_data into answers/classifications/search versions (openai#93)

* Break out prepare_data into answers, classifications, and search

* And cleaned up CLI

* Validate search files (openai#69)

* Add validators for search files

* Clean up fields

Co-authored-by: kennyhsu5 <[email protected]>
Co-authored-by: Madeleine Thompson <[email protected]>
cgayapr pushed a commit to cgayapr/openai-python that referenced this pull request Dec 14, 2024
* Add Azure AD authentication support

* Add azure_ad code examples

* Remove debug print statement

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

Successfully merging this pull request may close these issues.

4 participants