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

# Moondream Vision

> MoondreamService runs local image analysis and visual question answering with the Moondream vision model.

## Overview

`MoondreamService` provides local image analysis and question-answering capabilities using the Moondream model. It runs entirely on your local machine, supporting various hardware acceleration options including CUDA, Intel XPU, and Apple MPS for privacy-focused computer vision applications.

> [card] [Moondream Vision API Reference](https://reference-server.pipecat.ai/en/latest/api/pipecat.services.moondream.vision.html)
>
> Pipecat's API methods for Moondream vision integration

> [card] [Example Implementation](https://github.com/pipecat-ai/pipecat/blob/main/examples/vision/vision-moondream.py)
>
> Browse examples using Moondream vision

> [card] [Moondream Documentation](https://docs.moondream.ai/)
>
> Official Moondream model documentation

> [card] [Hugging Face Model](https://huggingface.co/vikhyatk/moondream2)
>
> Access Moondream model on Hugging Face

## Installation

To use Moondream services, install the required dependencies:

```bash theme={null}
uv add "pipecat-ai[moondream]"
```

## Prerequisites

### Local Model Setup

Before using Moondream vision services, you need:

1. **Model Download**: First run will automatically download the Moondream model from Hugging Face
2. **Hardware Configuration**: Set up CUDA, Intel XPU, or Apple MPS for optimal performance
3. **Storage Space**: Ensure sufficient disk space for model files
4. **Memory Requirements**: Adequate RAM/VRAM for model inference

### Hardware Acceleration

The service automatically detects and uses the best available hardware:

* **Intel XPU**: Requires intel\_extension\_for\_pytorch
* **NVIDIA CUDA**: For GPU acceleration
* **Apple Metal (MPS)**: For Apple Silicon optimization
* **CPU**: Fallback option for any system

### Configuration Options

* **Model Selection**: Choose Moondream model version and revision
* **Hardware Override**: Force CPU usage if needed
* **Local Processing**: Complete privacy with no external API calls

> [!TIP]
>
> No API keys required - Moondream runs entirely locally for complete privacy
> and control.

## Configuration

**model** `str | None` *deprecated* (default: None)

*Deprecated since 0.0.105, removed in 2.0.0.* Use
`settings=MoondreamService.Settings(model=...)` instead.

**revision** `str` (default: 2025-06-21)

Specific model revision to use.

**use\_cpu** `bool` (default: False)

Whether to force CPU usage instead of hardware acceleration. When `False`, the
service automatically detects and uses the best available device (Intel XPU,
CUDA, MPS, or CPU).

**settings** `MoondreamService.Settings` (default: None)

Runtime-configurable settings. See [Settings](#settings) below.

### Settings

Runtime-configurable settings passed via the `settings` constructor argument using `MoondreamService.Settings(...)`. See [Service Settings](https://docs.pipecat.ai/pipecat/fundamentals/service-settings.md) for details.

| Parameter | Type | Default | Description |
| - | - | - | - |
| `model` | `str` | `"vikhyatk/moondream2"` | Moondream model identifier. *(Inherited from base settings.)* |

## Usage

### Basic Setup

```python theme={null}
from pipecat.services.moondream.vision import MoondreamService

vision = MoondreamService()
```

### With Settings and CPU Override

```python theme={null}
vision = MoondreamService(
    revision="2025-06-21",
    use_cpu=True,
    settings=MoondreamService.Settings(
        model="vikhyatk/moondream2",
    ),
)
```

> [!TIP]
>
> The deprecated `model` constructor parameter is replaced by `Settings` as of
> v0.0.105. Use `Settings` / `settings=` instead. See the [Service Settings
> guide](https://docs.pipecat.ai/pipecat/fundamentals/service-settings.md) for migration details.

## Notes

* **First-run download**: The model is automatically downloaded from Hugging Face on first use. Ensure sufficient disk space and network access.
* **Hardware auto-detection**: When `use_cpu=False` (the default), the service detects available hardware in this priority order: Intel XPU, NVIDIA CUDA, Apple Metal (MPS), then CPU.
* **Data types**: CUDA and MPS use `float16` for faster inference, while XPU and CPU use `float32`.
* **Blocking inference**: Image analysis runs in a separate thread via `asyncio.to_thread` to avoid blocking the event loop.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.