Skip to content

Commit 61863c2

Browse files
Merge pull request #7461 from mrbullwinkle/mrb_10_03_2025_python_update
[Azure OpenAI] Fix v1 support
2 parents 3982b72 + 4512b3a commit 61863c2

File tree

1 file changed

+23
-4
lines changed
  • articles/ai-foundry/openai/includes/language-overview

1 file changed

+23
-4
lines changed

articles/ai-foundry/openai/includes/language-overview/python.md

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,29 @@ pip install openai --upgrade
3232

3333
## Authentication
3434

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+
3558
# [API Key](#tab/python-key)
3659

3760
[!INCLUDE [Azure key vault](~/reusable-content/ce-skilling/azure/includes/ai-services/security/azure-key-vault.md)]
@@ -48,10 +71,6 @@ client = OpenAI(
4871
```
4972

5073

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-
5574
---
5675

5776
## Chat

0 commit comments

Comments
 (0)