> ## 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.

# Image Generation

> Generate images on-device

`RunAnywhere.images` generates an image from a prompt.

```ts theme={null}
const result = await RunAnywhere.images.generate('A lighthouse at dusk, oil painting', {
  negativePrompt: 'blurry, text, watermark',
  width: 512,
  height: 512,
  steps: 20,
  seed: 42,
})
```

## Options

| Field            | Default       | Meaning                                            |
| ---------------- | ------------- | -------------------------------------------------- |
| `negativePrompt` | none          | What to avoid                                      |
| `width`          | model default | Output width                                       |
| `height`         | model default | Output height                                      |
| `steps`          | model default | Denoising steps; more is slower and usually better |
| `guidanceScale`  | model default | How closely to follow the prompt                   |
| `seed`           | random        | Fix it to reproduce an image                       |
| `mode`           | generate      | Generate or inpaint                                |
| `reportPartials` | `false`       | Emit intermediate images while streaming           |

## Watching it appear

With `reportPartials` on, the stream emits intermediate images, so you can show the picture
resolving rather than a spinner.

```ts theme={null}
for await (const event of RunAnywhere.images.generateStream('A lighthouse at dusk', {
  steps: 20,
  reportPartials: true,
})) {
  if (event.type === 'partial') showPreview(event.image)
  if (event.type === 'completed') showFinal(event.result)
}
```

Put the progress on the taskbar or dock icon as well as in the window:

```ts theme={null}
win.setProgressBar(fraction)
```

## Reproducing an image

Fix the seed and every other option, and the same prompt produces the same image. Without a
fixed seed, it will not. A desktop app that lets people iterate on a prompt should surface the
seed, so a result they liked can be recovered.

## Saving

```ts theme={null}
import { writeFile } from 'node:fs/promises'
import { dialog } from 'electron'

const { filePath } = await dialog.showSaveDialog({ defaultPath: 'image.png' })
if (filePath) await writeFile(filePath, result.image)
```

## Cost

Image generation is the heaviest thing in the SDK. A desktop has the headroom a phone does not,
but it still takes far longer than a text completion and spins the fans. Run one at a time,
show progress, and allow cancellation.

## Availability

A diffusion model has to be registered and a backend has to serve it. On `win32-arm64` only
QHexRT loads, so check `capabilities()` before offering this.
