Using Asynchronous Client with AsyncOpenAI

Hello,

In the OpenAI github repo, it says that one could use AsyncOpenAI and await for asynchronous programming. Could someone please elaborate on these two questions:

  1. Given the following code, if all the code we have is calling different OpenAI APIs for various tasks, then is there any point in this async and await, or should we just use the sync client?

Screenshot 2024-02-12 at 8.22.28 PM

  1. Given the following steps mentioned here for creating an assistant: https://platform.openai.com/docs/assistants/overview
    does async client make any sense given that there is an order in these steps or not?

I would really appreciate your response and clarification. Thank you.

Hi!

I guess in this case it’s a matter of taste. Async allows you to manage asynchronous tasks, such as for example when you want to send off a bunch of http calls in paralllel and then gather the responses later.

If everything you do is synchronous, then you’re right, it doesn’t matter! Might as well use the synchronous methods.

1 Like