File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed
articles/ai-services/openai/how-to Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -206,6 +206,23 @@ Additional examples including how to handle semantic text search without `embedd
206
206
207
207
---
208
208
209
+ ## Async
210
+
211
+ OpenAI doesn't support calling asynchronous methods in the module-level client, instead you should instantiate an async client.
212
+
213
+ ``` python
214
+ from openai import AsyncAzureOpenAI
215
+
216
+ client = AsyncAzureOpenAI(
217
+ api_key = os.getenv(" AZURE_OPENAI_KEY" ),
218
+ api_version = " 2023-10-01-preview" ,
219
+ azure_endpoint = os.getenv(" AZURE_OPENAI_ENDPOINT" )
220
+ )
221
+ response = await client.chat.completions.create(model = " gpt-35-turbo" , messages = [{" role" : " user" , " content" : " Hello world" }])
222
+
223
+ print (response.model_dump_json(indent = 2 ))
224
+ ```
225
+
209
226
## Authentication
210
227
211
228
``` python
You can’t perform that action at this time.
0 commit comments