File tree Expand file tree Collapse file tree 1 file changed +23
-4
lines changed
articles/ai-foundry/openai/includes/language-overview Expand file tree Collapse file tree 1 file changed +23
-4
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,29 @@ pip install openai --upgrade
32
32
33
33
## Authentication
34
34
35
+ # [ Microsoft Entra ID] ( #tab/python-secure )
36
+
37
+ ``` python
38
+ from openai import OpenAI
39
+ from azure.identity import DefaultAzureCredential, get_bearer_token_provider
40
+
41
+ token_provider = get_bearer_token_provider(
42
+ DefaultAzureCredential(), " https://cognitiveservices.azure.com/.default"
43
+ )
44
+
45
+ client = OpenAI(
46
+ base_url = " https://YOUR-RESOURCE-NAME.openai.azure.com/openai/v1/" ,
47
+ api_key = token_provider
48
+ )
49
+
50
+ response = client.responses.create(
51
+ model = " gpt-4.1-nano" ,
52
+ input = " This is a test"
53
+ )
54
+
55
+ print (response.model_dump_json(indent = 2 ))
56
+ ```
57
+
35
58
# [ API Key] ( #tab/python-key )
36
59
37
60
[ !INCLUDE [ Azure key vault] ( ~/reusable-content/ce-skilling/azure/includes/ai-services/security/azure-key-vault.md )]
@@ -48,10 +71,6 @@ client = OpenAI(
48
71
```
49
72
50
73
51
- # [ Microsoft Entra ID] ( #tab/python-secure )
52
-
53
- v1 support for Entra ID authentication is coming soon. To learn more, see the [ API version lifecycle guide] ( ../../api-version-lifecycle.md ) .
54
-
55
74
---
56
75
57
76
## Chat
You can’t perform that action at this time.
0 commit comments