Skip to main content
generate() is a suspend extension function on RunAnywhere. It returns the full response plus generation metrics once the model has finished.
options is optional. Omitting it applies LLMGenerationOptions.defaults(). There is a second overload that takes the generated request message, which is what you use for multi-turn history:
See Chat for the history form.

LLMGenerationResult

LLMGenerationResult is the Wire-generated ai.runanywhere.proto.v1.LLMGenerationResult, aliased as RALLMGenerationResult. Field names are snake_case.

LLMGenerationOptions

LLMGenerationOptions is generated from idl/llm_options.proto. Wire emits a plain class with all-defaulted constructor parameters plus copy(); use named arguments, there is no builder. Defaults come from LLMGenerationOptions.defaults() (com.runanywhere.sdk.generated.convenience), which is generated from the same proto annotations the C header is generated from. Other fields on the message: stop_sequences, streaming_enabled, preferred_framework, system_prompt, thinking_pattern, disable_thinking, structured_output, tool_calling, seed, frequency_penalty, presence_penalty, repeat_last_n, min_p, grammar, response_format, echo_prompt, n_threads, and execution_target. On the wire a proto3 zero means “unset, let the engine decide”. defaults() exists for callers who want a populated value; it does not change how an unset field is interpreted. LLMGenerationOptions.validate() throws SDKException with a fieldPath when a value is out of range.

Tuning by task

Cancelling

cancelGeneration() is a suspend function. It is a no-op when the SDK is not initialized and swallows its own failures, so it is safe to call unconditionally.