From the course: AI Programming for JavaScript Developers
Unlock the full course today
Join today to access over 24,900 courses taught by industry experts.
Solution: Configuring AI Inputs - JavaScript Tutorial
From the course: AI Programming for JavaScript Developers
Solution: Configuring AI Inputs
(energetic music) - [Instructor] We already have our OpenAI constructor here. The next step we need to take is we need to complete our initialized OpenAI function. So this will take in the API key, which we'll need to connect to that API. We also need the model name. And the model name should be set to GPT-3.5 Turbo. Now within the function, we can create the client, which is just a new instance of OpenAI class, and then we'll pass the API key in here. From here, we also need to configure our model, that'll look like this. So const model config, set that equal to model, model name, and temperature 0.7. Now we don't need the null here because we have defined the client already, and then we also can get rid of the empty object next to the model config. So if I test the code, it looks like I did it correctly, awesome. So we've successfully set up our OpenAI API client. This is exactly what it looks like, even though we still are mocking the model here, we're going to be able to connect…