Signature
One method takes either a prompt or a conversation:With options
options.model names a model that is
absent.
LlmOptions
Structured output
Errors
ThrowsSDKException when no model can be loaded or generation fails. See
Error handling.Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
One-shot text generation
const result = await RunAnywhere.llm.generate('Name three colours')
console.log(result.text)
generate(
input: string | readonly ChatMessage[],
options?: LlmOptions
): Promise<GenerationResult>
const result = await RunAnywhere.llm.generate('Explain quantum computing', {
model: 'qwen3-0.6b',
maxOutputTokens: 200,
temperature: 0.7,
})
console.log(result.text, result.tokensPerSecond)
options.model names a model that is
absent.
| Field | Type | Default |
|---|---|---|
model | string | none; uses the loaded model |
maxOutputTokens | number | proto default |
temperature | number | proto default |
topP | number | proto default |
systemPrompt | string | none |
stopSequences | string[] | [] |
reasoning | ReasoningOptions | none |
tools | ToolDefinition[] | [] |
toolChoice | ToolChoice | auto |
maxToolCalls | number | 5 |
const result = await RunAnywhere.llm.generateStructured(
'Extract the name and age: Dana is 34.',
schema,
'validationOnly'
)
| Mode | Behaviour |
|---|---|
'validationOnly' | Generate freely, then validate. The default. |
'repair' | Validate, then retry once with a repair instruction. |
'constrained' | Throws today. |
'constrained' throws unsupportedCapability. It needs engine-level constrained decoding, which
is not wired in yet.SDKException when no model can be loaded or generation fails. See
Error handling.