Skip to content

Commit 9f50c43

Browse files
authored
Merge pull request #3771 from MicrosoftDocs/main
Merge main to live, 4 AM
2 parents 9ce1ceb + 50641d1 commit 9f50c43

File tree

6 files changed

+45
-38
lines changed

6 files changed

+45
-38
lines changed

articles/ai-services/openai/includes/python.md

Lines changed: 25 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: Walkthrough on how to get started with Azure OpenAI and make your f
55
manager: nitinme
66
ms.service: azure-ai-openai
77
ms.topic: include
8-
ms.date: 01/03/2024
8+
ms.date: 03/26/2025
99
---
1010

1111
<a href="https://github.com/openai/openai-python" target="_blank">Library source code</a> | <a href="https://pypi.org/project/openai/" target="_blank">Package (PyPi)</a> |
@@ -22,22 +22,10 @@ ms.date: 01/03/2024
2222

2323
Install the OpenAI Python client library with:
2424

25-
# [OpenAI Python 1.x](#tab/python-new)
26-
2725
```console
2826
pip install openai
2927
```
3028

31-
# [OpenAI Python 0.28.1](#tab/python)
32-
33-
[!INCLUDE [Deprecation](../includes/deprecation.md)]
34-
35-
```console
36-
pip install openai==0.28.1
37-
```
38-
39-
---
40-
4129
> [!NOTE]
4230
> This library is maintained by OpenAI. Refer to the [release history](https://github.com/openai/openai-python/releases) to track the latest updates to the library.
4331
@@ -64,16 +52,21 @@ Go to your resource in the Azure portal. The **Keys and Endpoint** can be found
6452

6553
2. Replace the contents of quickstart.py with the following code. Modify the code to add your key, endpoint, and deployment name:
6654

67-
# [OpenAI Python 1.x](#tab/python-new)
55+
# [Microsoft Entra ID](#tab/entra)
6856

6957
```python
7058
import os
7159
from openai import AzureOpenAI
60+
from azure.identity import DefaultAzureCredential, get_bearer_token_provider
61+
62+
token_provider = get_bearer_token_provider(
63+
DefaultAzureCredential(), "https://cognitiveservices.azure.com/.default"
64+
)
7265

7366
client = AzureOpenAI(
74-
api_key=os.getenv("AZURE_OPENAI_API_KEY"),
75-
api_version="2024-02-01",
76-
azure_endpoint = os.getenv("AZURE_OPENAI_ENDPOINT")
67+
azure_endpoint = os.getenv("AZURE_OPENAI_ENDPOINT"),
68+
azure_ad_token_provider=token_provider,
69+
api_version="2024-10-21"
7770
)
7871

7972
deployment_name='REPLACE_WITH_YOUR_DEPLOYMENT_NAME' #This will correspond to the custom name you chose for your deployment when you deployed a model. Use a gpt-35-turbo-instruct deployment.
@@ -85,25 +78,27 @@ response = client.completions.create(model=deployment_name, prompt=start_phrase,
8578
print(start_phrase+response.choices[0].text)
8679
```
8780

88-
# [OpenAI Python 0.28.1](#tab/python)
81+
# [API Key](#tab/key)
82+
83+
[!INCLUDE [Azure key vault](~/reusable-content/ce-skilling/azure/includes/ai-services/security/azure-key-vault.md)]
8984

9085
```python
9186
import os
92-
import openai
93-
94-
openai.api_key = os.getenv("AZURE_OPENAI_API_KEY")
95-
openai.api_base = os.getenv("AZURE_OPENAI_ENDPOINT") # your endpoint should look like the following https://YOUR_RESOURCE_NAME.openai.azure.com/
96-
openai.api_type = 'azure'
97-
openai.api_version = '2024-02-01' # this might change in the future
98-
99-
deployment_name='REPLACE_WITH_YOUR_DEPLOYMENT_NAME' #This will correspond to the custom name you chose for your deployment when you deployed a model.
100-
87+
from openai import AzureOpenAI
88+
89+
client = AzureOpenAI(
90+
api_key=os.getenv("AZURE_OPENAI_API_KEY"),
91+
api_version="2024-10-21",
92+
azure_endpoint = os.getenv("AZURE_OPENAI_ENDPOINT")
93+
)
94+
95+
deployment_name='REPLACE_WITH_YOUR_DEPLOYMENT_NAME' #This will correspond to the custom name you chose for your deployment when you deployed a model. Use a gpt-35-turbo-instruct deployment.
96+
10197
# Send a completion call to generate an answer
10298
print('Sending a test completion job')
10399
start_phrase = 'Write a tagline for an ice cream shop. '
104-
response = openai.Completion.create(engine=deployment_name, prompt=start_phrase, max_tokens=10)
105-
text = response['choices'][0]['text'].replace('\n', '').replace(' .', '.').strip()
106-
print(start_phrase+text)
100+
response = client.completions.create(model=deployment_name, prompt=start_phrase, max_tokens=10)
101+
print(start_phrase+response.choices[0].text)
107102
```
108103

109104
---
@@ -128,7 +123,6 @@ Write a tagline for an ice cream shop. The coldest ice cream in town!
128123

129124
Run the code a few more times to see what other types of responses you get as the response won't always be the same.
130125

131-
132126
### Understanding your results
133127

134128
Since our example of `Write a tagline for an ice cream shop.` provides little context, it's normal for the model to not always return expected results. You can adjust the maximum number of tokens if the response seems unexpected or truncated.

articles/ai-services/openai/includes/rest.md

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: Walkthrough on how to get started with Azure OpenAI and make your f
55
manager: nitinme
66
ms.service: azure-ai-openai
77
ms.topic: include
8-
ms.date: 02/02/2023
8+
ms.date: 03/26/2025
99
---
1010

1111
## Prerequisites
@@ -38,14 +38,27 @@ Go to your resource in the Azure portal. The **Endpoint and Keys** can be found
3838

3939
In a bash shell, run the following command. You will need to replace `gpt-35-turbo-instruct` with the deployment name you chose when you deployed the `gpt-35-turbo-instruct` model. Entering the model name will result in an error unless you chose a deployment name that is identical to the underlying model name.
4040

41+
# [Microsoft Entra ID](#tab/entra)
42+
4143
```bash
42-
curl $AZURE_OPENAI_ENDPOINT/openai/deployments/gpt-35-turbo-instruct/completions?api-version=2024-02-01 \
44+
curl $AZURE_OPENAI_ENDPOINT/openai/deployments/gpt-35-turbo-instruct/completions?api-version=2024-10-21 \
45+
-H "Content-Type: application/json" \
46+
-H "Authorization: Bearer $AZURE_OPENAI_AUTH_TOKEN" \
47+
-d "{\"prompt\": \"Once upon a time\"}"
48+
```
49+
50+
# [API Key](#tab/key)
51+
52+
```bash
53+
curl $AZURE_OPENAI_ENDPOINT/openai/deployments/gpt-35-turbo-instruct/completions?api-version=2024-10-21 \
4354
-H "Content-Type: application/json" \
4455
-H "api-key: $AZURE_OPENAI_API_KEY" \
4556
-d "{\"prompt\": \"Once upon a time\"}"
4657
```
4758

48-
The format of your first line of the command with an example endpoint would appear as follows `curl https://docs-test-001.openai.azure.com/openai/deployments/{YOUR-DEPLOYMENT_NAME_HERE}/completions?api-version=2024-02-01 \`. If you encounter an error double check to make sure that you don't have a doubling of the `/` at the separation between your endpoint and `/openai/deployments`.
59+
---
60+
61+
The format of your first line of the command with an example endpoint would appear as follows `curl https://docs-test-001.openai.azure.com/openai/deployments/{YOUR-DEPLOYMENT_NAME_HERE}/completions?api-version=2024-10-21 \`. If you encounter an error double check to make sure that you don't have a doubling of the `/` at the separation between your endpoint and `/openai/deployments`.
4962

5063
If you want to run this command in a normal Windows command prompt you would need to alter the text to remove the `\` and line breaks.
5164

articles/ai-services/openai/includes/studio.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: Walkthrough on how to get started with Azure OpenAI and make your f
55
manager: nitinme
66
ms.service: azure-ai-openai
77
ms.topic: include
8-
ms.date: 09/19/2023
8+
ms.date: 03/26/2025
99
---
1010

1111
## Prerequisites

articles/ai-services/openai/quickstart.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ ms.custom: devx-track-dotnet, devx-track-python, devx-track-extended-java, devx-
88
ms.topic: quickstart
99
author: mrbullwinkle
1010
ms.author: mbullwin
11-
ms.date: 09/05/2024
11+
ms.date: 03/26/2025
1212
zone_pivot_groups: openai-quickstart-new
1313
recommendations: false
1414
---

articles/machine-learning/concept-data-privacy.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ ms.service: azure-ai-foundry
77
ms.custom:
88
- ignite-2023
99
ms.topic: how-to
10-
ms.date: 5/22/2024
10+
ms.date: 03/27/2025
1111
ms.reviewer: jcioffi
1212
ms.author: ssalgado
1313
author: ssalgadodev

articles/machine-learning/how-to-setup-vs-code.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ author: ssalgadodev
88
ms.author: ssalgado
99
ms.service: azure-machine-learning
1010
ms.subservice: core
11-
ms.date: 01/16/2024
11+
ms.date: 03/25/2025
1212
ms.topic: how-to
1313
ms.custom: devplatv2, build-2023
1414
monikerRange: 'azureml-api-1 || azureml-api-2'

0 commit comments

Comments
 (0)