Skip to main content
API Reference / @modelence/ai / generateText
generateText(options): Promise<GenerateTextResult<ToolSet, Output<any, any, any>>>
Defined in: index.ts:77 Generates text using AI models with built-in Modelence configuration and telemetry. This is a wrapper around the AI SDK’s generateText function that automatically configures providers using Modelence’s server-side configuration system.

Example

import { generateText } from '@modelence/ai';

const response = await generateText({
  provider: 'anthropic',
  model: 'claude-sonnet-4-6',
  messages: [
    { role: 'user', content: 'Write a haiku about programming' }
  ],
  temperature: 0.7
});

console.log(response.text);

Parameters

ParameterTypeDescription
optionsGenerateTextOptionsConfiguration options for text generation

Returns

Promise<GenerateTextResult<ToolSet, Output<any, any, any>>> A promise that resolves to the generated text result