You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/ai-services/openai/includes/python.md
+40-32Lines changed: 40 additions & 32 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -29,10 +29,20 @@ keywords:
29
29
30
30
Install the OpenAI Python client library with:
31
31
32
+
# [OpenAI Python 0.28.1](#tab/python)
33
+
32
34
```console
33
35
pip install openai==0.28.1
34
36
```
35
37
38
+
# [OpenAI Python 1.0](#tab/python-new)
39
+
40
+
```console
41
+
pip install openai
42
+
```
43
+
44
+
---
45
+
36
46
> [!NOTE]
37
47
> This library is maintained by OpenAI and is currently in preview. Refer to the [release history](https://github.com/openai/openai-python/releases) or the [version.py commit history](https://github.com/openai/openai-python/commits/main/openai/version.py) to track the latest updates to the library.
38
48
@@ -64,48 +74,46 @@ Create and assign persistent environment variables for your key and endpoint.
64
74
65
75
2. Replace the contents of quickstart.py with the following code. Modify the code to add your key, endpoint, and deployment name:
66
76
67
-
# [Python 0.28.1](#tab/python)
77
+
# [OpenAI Python 0.28.1](#tab/python)
68
78
69
79
```python
70
-
import os
71
-
import requests
72
-
import json
73
-
import openai
74
-
75
-
openai.api_key = os.getenv("AZURE_OPENAI_KEY")
76
-
openai.api_base = os.getenv("AZURE_OPENAI_ENDPOINT") # your endpoint should look like the following https://YOUR_RESOURCE_NAME.openai.azure.com/
77
-
openai.api_type ='azure'
78
-
openai.api_version ='2023-05-15'# this may change in the future
79
-
80
-
deployment_name='REPLACE_WITH_YOUR_DEPLOYMENT_NAME'#This will correspond to the custom name you chose for your deployment when you deployed a model.
81
-
82
-
# Send a completion call to generate an answer
83
-
print('Sending a test completion job')
84
-
start_phrase ='Write a tagline for an ice cream shop. '
0 commit comments