Andrea Barghigiani

Generating Text

Generating text with AI SDK is a really simple task. Once you have selected the model you want to use and the prompt you want to send, all it’s left it’s calling the right function!

import { google } from '@ai-sdk/google';
import { generateText } from 'ai'; // <- This is what you're looking for!

const model = google('gemini-2.5-flash-lite');
const prompt = 'What is the capital of France?';

const result = await generateText({model, prompt});

console.log(result.text) // <- This is the answer

As you can see, AI SDK makes interacting with LLM a task that’s incredibly easy. But don’t get fooled generateText has plenty of parameters that let’s you customize in great details how we want it to behave.


Andrea Barghigiani

Andrea Barghigiani

Frontend and Product Engineer in Palermo , He/Him

cupofcraft