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

# Vision Language

> Answer questions about an image

`RunAnywhere.vlm` answers a prompt about one image. It takes the same `LlmOptions` and returns the
same `GenerationResult` as `llm`, so metrics and reasoning behave identically.

```dart theme={null}
final image = ImageInput.file('/path/to/photo.jpg');

final result = await RunAnywhere.vlm.generate(image, 'What is in this photo?');
print(result.text);
```

The prompt is a parameter, never a field inside the options. The call loads a multimodal model,
downloading it when needed, and throws `SDKException` when none is available.

## ImageInput

```dart theme={null}
ImageInput.file('/path/to/photo.jpg');       // read by path
ImageInput.bytes(pngOrJpegBytes);            // encoded bytes
ImageInput.rawRgb(rgbBytes, width, height);  // tightly packed RGB8
```

`rawRgb` is the only layout [segmentation](/flutter/segmentation) accepts. For VLM any of the three
works.

## Streaming

```dart theme={null}
await for (final event in RunAnywhere.vlm.generateStream(image, 'Describe this')) {
  switch (event) {
    case GenerationToken(:final text):
      setState(() => _caption += text);
    case GenerationCompleted(:final result):
      debugPrint('${result.outputTokens} tokens');
    default:
      break;
  }
}
```

Cancel by cancelling the subscription, or call `RunAnywhere.vlm.cancel()`.

## Options

```dart theme={null}
final result = await RunAnywhere.vlm.generate(
  image,
  'Read the text in this image.',
  options: LlmOptions(maxOutputTokens: 512, temperature: 0.2),
);
```

Fields you leave unset take the vision defaults rather than the language ones: `maxOutputTokens`
2048, `temperature` 0.7, `topP` 0.9, `repetitionPenalty` 1.1.

## Models

Vision models register under `MODEL_CATEGORY_MULTIMODAL`. GGUF vision models need their projector
alongside the weights, which usually means an archive or a multi-file registration.

```dart theme={null}
await RunAnywhere.models.register(
  ModelRegistration.archive(
    id: 'smolvlm-500m-instruct-q8_0',
    name: 'SmolVLM 500M Instruct',
    url: 'https://example.com/smolvlm-500m-instruct-q8_0.tar.gz',
    archiveType: ArchiveType.ARCHIVE_TYPE_TAR_GZ,
    structure: ArchiveStructure.ARCHIVE_STRUCTURE_NESTED_DIRECTORY,
    framework: InferenceFramework.INFERENCE_FRAMEWORK_LLAMA_CPP,
    category: ModelCategory.MODEL_CATEGORY_MULTIMODAL,
    memoryRequirementBytes: 900000000,
  ),
);
```

Register the llama.cpp backend to get vision support. `LlamaCpp.register()` fills the LLM and VLM
slots of one engine; there is no separate vision registration.

## See also

<CardGroup cols={2}>
  <Card title="generate()" icon="sparkles" href="/flutter/llm/generate">
    Text generation and options
  </Card>

  <Card title="Segmentation" icon="object-group" href="/flutter/segmentation">
    Per-pixel class masks
  </Card>
</CardGroup>
