Skip to main content
RunAnywhere.llm.generate runs a single non-streaming completion and returns the text with token counts and timings.

Basic usage

With options:
Generation auto-loads whatever it needs. When options.model names a model that is not on disk, it downloads it first.

Signatures

The messages: form is covered in Chat.

LlmOptions

Sampling defaults come from RALLMGenerationOptions.defaults() rather than being hardcoded, so they track the C++ core.

GenerationResult

Reasoning models return their thinking channel separately when ReasoningOptions(includeInOutput: true) is set, rather than inline in text.

Reasoning

ReasoningMode is .on by default. The C++ core owns tag parsing and /no_think directives; you toggle the mode and render what comes back.

Structured output

mode: .constrained throws SDKException today. Engine-level constrained decoding is not wired in yet. Use .validationOnly (generate, then validate) or .repair (validate, then retry once with a repair instruction).

Errors

Throws SDKException when no model can be loaded or generation fails. See Error handling.