> ## Documentation Index
> Fetch the complete documentation index at: https://docs.runanywhere.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# generate()

> One-shot text generation

```ts theme={null}
const result = await RunAnywhere.llm.generate('Name three colours')
console.log(result.text, result.tokensPerSecond)
```

## Signature

One method takes either a prompt or a conversation:

```ts theme={null}
generate(input: string | ChatMessage[], options?: LlmOptions): Promise<GenerationResult>
```

## With options

```ts theme={null}
const result = await RunAnywhere.llm.generate('Explain quantum computing', {
  model: 'qwen3-0.6b',
  maxOutputTokens: 200,
  temperature: 0.7,
})
```

Generation auto-loads what it needs, and downloads when `options.model` names a model that is
absent.

## LlmOptions

| 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`                         |

A desktop has real headroom, so `maxOutputTokens` can be higher here than on a phone. It is
still the biggest lever on how long the user waits.

## From the renderer

The same call works through the context bridge:

```ts theme={null}
const result = await window.runanywhere.llm.generate('Hello')
```

## Errors

Throws `SDKException` when no model is loaded and `options.model` is absent, or when generation
fails. See [Error handling](/electron/error-handling).
