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

# moondream

> Generate text response from image using Moondream

Generate text response from image using Moondream.

## Parameters

<ParamField body="image_input" type="Union[str, Image.Image, np.ndarray]" required>
  RGB image.
</ParamField>

<ParamField body="task" type="str" required>
  Task type - "vqa" (Visual Question Answering), "caption" (Image Captioning), "detect" (Object Detection), or "point" (Pointing/Clickable points).
</ParamField>

<ParamField body="prompt" type="str" default="''">
  Text prompt/question about the image (required for vqa, detect, point tasks).
</ParamField>

<ParamField body="length" type="str" default="'normal'">
  Caption length - "short" or "normal" (only for caption task).
</ParamField>

<ParamField body="timeout" type="float | None">
  Optional HTTP timeout.
</ParamField>

## Returns

Dict\[str, Any]: Backend JSON response containing generated text or structured data.

* For vqa/caption: \{"output": "text response"}
* For detect: \{"output": \{"boxes": \[...], "scores": \[...], "labels": \[...]}}
* For point: \{"output": numpy array of (x,y) points}

## Example

```python theme={null}
from grid_cortex_client import CortexClient, ModelType
import numpy as np
from PIL import Image
client = CortexClient()
image = np.array(Image.open("path/to/kitchen.jpg"))
result = client.run(ModelType.MOONDREAM, image_input=image, task="vqa", prompt="How many cups are on the table?")
print(result["output"])  # Text answer
result = client.run(ModelType.MOONDREAM, image_input=image, task="caption", length="short")
print(result["output"])  # Text caption
result = client.run(ModelType.MOONDREAM, image_input=image, task="detect", prompt="cup, plate, bowl")
print(result["output"])  # Dict with boxes, scores, labels
result = client.run(ModelType.MOONDREAM, image_input=image, task="point", prompt="the red cup")
print(result["output"])  # Numpy array of (x,y) points
```

## Example Output

<img src="https://mintcdn.com/scaledfoundations/lgZgGQWKvUIw0C7n/assets/images/cortex/moondream-output.jpg?fit=max&auto=format&n=lgZgGQWKvUIw0C7n&q=85&s=f4202926a8983ff39b67abc36bdfec4f" alt="Moondream VQA, caption, detect, and point task outputs" width="1004" height="818" data-path="assets/images/cortex/moondream-output.jpg" />

```python theme={null}
from grid_cortex_client import CortexClient
import numpy as np
from PIL import Image

client = CortexClient()
image = np.array(Image.open("scene.jpg"))  # 640x480 RGB

# Visual Question Answering
vqa = client.run(model_id="moondream", image_input=image, task="vqa",
                 prompt="What kind of scene is this?")
print(vqa["output"])
# "This is a city street scene, featuring a wide, empty road with
#  buildings on both sides."

# Image Captioning
caption = client.run(model_id="moondream", image_input=image, task="caption", length="short")
print(caption["output"])
# "A bustling city street at night features tall buildings, colorful
#  signs, and streetlights, with a train station and overpass in the
#  distance."

# Object Detection
dets = client.run(model_id="moondream", image_input=image, task="detect",
                  prompt="sign")
print(len(dets["output"]["boxes"]))
# 9
print(dets["output"]["boxes"][:3])
# [[86.25, 4.22, 142.5, 93.28],
#  [1.56, 33.05, 48.44, 109.45],
#  [176.25, 131.25, 203.75, 191.25]]

# Pointing
points = client.run(model_id="moondream", image_input=image, task="point",
                    prompt="street light")
print(points["output"]["points"][:3])
# [[584.375, 116.25], [589.375, 121.41], [531.875, 129.375]]
```


## Related topics

- [moondream](/models/cortex/moondream.md)
