From the course: Integrating Generative AI into JavaScript Web Projects

Unlock this course with a free trial

Join today to access over 25,500 courses taught by industry experts.

Define prompts and a system message

Define prompts and a system message

- [Instructor] Now after configuring the project with OpenAI, so we have set up an API key, the next step is to send our first API request. And we're going to do that right under this if statement. In this video, we learn to define prompts and to generate completions from a single text prompt. So let's go back to the documentation. We're going to find the developer quickstart guide. We're going to scroll down and find the example under the Node.js library. And that's going to be under step three to send our first API request. So we're going to copy from line six to 11. Let's go back to the source code, and we're going to add this example and we're going to see how it is set up. So we have two keys. So first, messages. That takes a list of messages as an input. And we also specify the language model. And here you see that we've got this list of messages as an input. And the first ever message will be a system message. And this is to indicate the assistant how to behave. What is the…

Contents