generate runs one non-streaming generation and resolves with the full proto result.
Signature
generate is overloaded. Pass a prompt string with optional options, or a whole
LLMGenerateRequest.
LLMGenerationOptions and LLMGenerationResult from
@runanywhere/proto-ts/llm_options, LLMGenerateRequest from
@runanywhere/proto-ts/llm_service. They are not re-exported from @runanywhere/core.
It throws SDKException when the SDK is not initialized, when the native module is missing, or
when the backend fails.
Options
The sampling defaults below are declared once in the IDL and read by every SDK. A field left unset gets the default; a field explicitly set to the proto zero value means “let the engine decide”.Result
LLMGenerationResult fields you are most likely to read:
There is no
latencyMs, tokensUsed, or nested performanceMetrics object on this result.
Temperature
Stop sequences
System prompt
Thinking models
Models that emit<think> blocks (Qwen3, LFM2, DeepSeek-R1) put the reasoning trace in
thinkingContent and the answer in text. Register the model with supportsThinking: true so the
registry records the capability.
disableThinking: true to suppress the thinking phase for one call. Commons injects the
model’s own no-think directive at the prompt level, so do not prepend /no_think yourself.
Cancellation
cancelGeneration() is a no-op when the SDK is not initialized. A cancelled generation surfaces
finishReason: 'cancelled', and isSDKException(e) && e.isExpected is true for the corresponding
error code, so you can skip crash reporting on it.
Related
Chat
Multi-turn conversations
Streaming
Token streaming
System Prompts
Control model behavior
Error Handling
SDKException reference