File tree Expand file tree Collapse file tree 1 file changed +21
-1
lines changed
articles/ai-foundry/openai/includes/language-overview Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -50,7 +50,27 @@ client = OpenAI(
50
50
51
51
# [ Microsoft Entra ID] ( #tab/python-secure )
52
52
53
- v1 support for Entra ID authentication is coming soon. To learn more, see the [ API version lifecycle guide] ( ../../api-version-lifecycle.md ) .
53
+ ``` python
54
+ from openai import OpenAI
55
+ from azure.identity import DefaultAzureCredential, get_bearer_token_provider
56
+
57
+ token_provider = get_bearer_token_provider(
58
+ DefaultAzureCredential(), " https://cognitiveservices.azure.com/.default"
59
+ )
60
+
61
+ client = OpenAI(
62
+ base_url = " https://YOUR-RESOURCE-NAME.openai.azure.com/openai/v1/" ,
63
+ api_key = token_provider
64
+ )
65
+
66
+ response = client.responses.create(
67
+ model = " gpt-4.1-nano" ,
68
+ input = " This is a test"
69
+ )
70
+
71
+ print (response.model_dump_json(indent = 2 ))
72
+ ```
73
+
54
74
55
75
---
56
76
You can’t perform that action at this time.
0 commit comments