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/chatgpt-python.md
+68-27Lines changed: 68 additions & 27 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -30,52 +30,93 @@ keywords:
30
30
31
31
Install the OpenAI Python client library with:
32
32
33
+
# [OpenAI Python 0.28.1](#tab/python)
34
+
33
35
```console
34
36
pip install openai==0.28.1
35
37
```
36
38
39
+
# [OpenAI Python 1.0](#tab/python-new)
40
+
41
+
```console
42
+
pip install openai
43
+
```
44
+
45
+
---
46
+
37
47
> [!NOTE]
38
48
> 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.
> [I ran into an issue with the setup.](https://microsoft.qualtrics.com/jfe/form/SV_0Cl5zkG3CnDjq6O?PLanguage=PYTHON&Pillar=AOAI&Product=Chatgpt&Page=quickstart&Section=Set-up)
47
56
48
57
## Create a new Python application
49
58
50
59
1. Create a new Python file called quickstart.py. Then open it up in your preferred editor or IDE.
51
60
52
-
2. Replace the contents of quickstart.py with the following code. You need to set the `engine` variable to the deployment name you chose when you deployed the GPT-35-Turbo or GPT-4 models. Entering the model name will result in an error unless you chose a deployment name that is identical to the underlying model name.
53
-
54
-
```python
55
-
#Note: The openai-python library support for Azure OpenAI is in preview.
2. Replace the contents of quickstart.py with the following code.
62
+
63
+
# [OpenAI Python 0.28.1](#tab/python)
64
+
65
+
You need to set the `engine` variable to the deployment name you chose when you deployed the GPT-3.5-Turbo or GPT-4 models. Entering the model name will result in an error unless you chose a deployment name that is identical to the underlying model name.
You need to set the `model` variable to the deployment name you chose when you deployed the GPT-3.5-Turbo or GPT-4 models. Entering the model name will result in an error unless you chose a deployment name that is identical to the underlying model name.
model="gpt-35-turbo", # model = "deployment_name".
105
+
messages=[
106
+
{"role": "system", "content": "You are a helpful assistant."},
107
+
{"role": "user", "content": "Does Azure OpenAI support customer managed keys?"},
108
+
{"role": "assistant", "content": "Yes, customer managed keys are supported by Azure OpenAI."},
109
+
{"role": "user", "content": "Do other Azure AI services support this too?"}
110
+
]
111
+
)
112
+
113
+
print(response.choices[0].message.content)
114
+
```
115
+
116
+
---
76
117
77
-
> [!IMPORTANT]
78
-
> For production, use a secure way of storing and accessing your credentials like [Azure Key Vault](../../../key-vault/general/overview.md). For more information about credential security, see the Azure AI services [security](../../security-features.md) article.
118
+
> [!IMPORTANT]
119
+
> For production, use a secure way of storing and accessing your credentials like [Azure Key Vault](../../../key-vault/general/overview.md). For more information about credential security, see the Azure AI services [security](../../security-features.md) article.
79
120
80
121
3. Run the application with the `python` command on your quickstart file:
0 commit comments