Generate Text
When you need to get a quick answer from a language model, the simplest approach is to send a text prompt and receive a text response. This example shows how to initialize an LLM and generate text with a single line of code.
import { Mastra } from '@mastra/core';
const mastra = new Mastra();
const llm = mastra.LLM({
provider: 'OPEN_AI',
name: 'gpt-4o',
});
const response = await llm.generate('What is a wormhole? Explain briefly.');
console.log(response.text);
View Example on GitHub