/caption

Generate natural language descriptions of images.

Quick Start

First, install the package:

pip install moondream pillow

Place an image file in your working directory, then:

import moondream as md
from PIL import Image
 
# Initialize with API key
model = md.vl(api_key="your-api-key")
 
# Load an image
image = Image.open("path/to/image.jpg")
 
# Generate a caption
caption = model.caption(image)["caption"]
print("Caption:", caption)
 
# Stream the response
for chunk in model.caption(image, stream=True)["caption"]:
    print(chunk, end="", flush=True)

The client libraries provide the simplest integration for working with the Moondream API.