API Reference
Generate Text

Generate Text

generateText(prompt: string, options?: GenerationOptions)

Generates text using the loaded language model.

const response = await browserAI.generateText('Write a story about space', {
  temperature: 0.7,
  maxTokens: 100,
  system_prompt: "You are a sci-fi writer."
});

Parameters

ParameterTypeRequiredDescription
promptstringYesInput text prompt
optionsGenerationOptionsNoGeneration parameters

GenerationOptions

OptionTypeDefaultDescription
temperaturenumber0.7Randomness (0.0-1.0)
maxTokensnumber100Maximum response length
topPnumber0.9Nucleus sampling
topKnumber40Top-k sampling
system_promptstring-System context
stop_tokensstring[][]Stop generation tokens

Returns

Promise<string>