Skip to content

Commit 5b5c991

Browse files
committed
update
1 parent 3982b72 commit 5b5c991

File tree

1 file changed

+21
-1
lines changed
  • articles/ai-foundry/openai/includes/language-overview

1 file changed

+21
-1
lines changed

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

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,27 @@ client = OpenAI(
5050

5151
# [Microsoft Entra ID](#tab/python-secure)
5252

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+
5474

5575
---
5676

0 commit comments

Comments
 (0)