From the course: A Start to Using Generative AI in .NET

Unlock the full course today

Join today to access over 23,400 courses taught by industry experts.

Hello chat

Hello chat

- [Instructor] After all the preparation we are finally ready to make our first request to the OpenAI API. Let's try to figure out how to make a request to the OpenAI API. Previously, I mentioned that the central object was the OpenAIClient object, which we have created. So, let's type client., and then chat. This should filter the OpenAIClient's methods to only show the ones that contain the word chat. As you can see, we have four options. GetChatCompletions is the simplest one. The others provide asynchronous and streaming versions to the same. So, let's just stick with the simplest one for now, GetChatCompletions. The term chat completion may sound a bit strange by the way, but it essentially means that it completes the conversation with an answer. The GetChatCompletions method requires a ChatCompletionsOptions parameter and an optional cancellation token, which we will generously ignore for now. So, we need a ChatCompletions object. Let's create one, ChatCompletionsOptions, let's…

Contents