I've created a new file in the root of our project called for generate text because this is lesson four. And I'll do the same for a lot of the subsequent lessons. What is in this file? Well, everything that you need to generate text with the AI SDK.
The first thing we do is import the generate text function from the core AI package, and the Google provider from the Google provider package. After that, we call generate text, passing it the Google model that we desire to use for the text generation. Notice that this is type safe and we get a list of options to choose from depending on our needs. 5 flash.
And then we'll pass in the prompt, who is the most powerful superhero and why be concise. That will give us a result. And the text property on the result should be the LLMs generated response. In my terminal, let's run NPM run TSX and point it at our file.
And whoops, it looks like I didn't actually set the value for my API key. So I'll do that off camera. And now with that API key set, let's run it one more time. Give it just a few moments.
This is going off and speaking with the Google API. And yeah, now we have the answer generated for us. Google thinks that Dr. Manhattan is the most powerful superhero because he possesses near omnipotence, the ability to manipulate matter, so on and so forth.
This looks pretty good and took almost zero code to accomplish. Now that you've got your first hit of AI magic in the next lesson, let's talk about text versus system versus message prompts.