Skip to main content

Reasoning

curl -X POST https://api.moondream.ai/v1/query \
-H 'Content-Type: application/json' \
-H 'X-Moondream-Auth: YOUR_API_KEY' \
-d '{
"image_url": "data:image/jpeg;base64,/9j//gAQTGF2YzYxLjE5LjEwMQD/2wBDAAg+Pkk+SVVVVVVVVWRdZGhoaGRkZGRoaGhwcHCDg4NwcHBoaHBwfHyDg4+Tj4eHg4eTk5ubm7q6srLZ2eD/////xABZAAADAQEBAQAAAAAAAAAAAAAABgcFCAECAQEAAAAAAAAAAAAAAAAAAAAAEAADAAMBAQEBAAAAAAAAAAAAAQIDIREEURKBEQEAAAAAAAAAAAAAAAAAAAAA/8AAEQgAGQAZAwESAAISAAMSAP/aAAwDAQACEQMRAD8A5/PQAAABirHyVS2mUip/Pm4/vQAih9ABuRUrVLqMEALVNead7/pFgAfc+d5NLSEEAAAA/9k=",
"question": "What is in this image?",
"reasoning": true
}'

Enable Moondream's reasoning capabilities to improve result quality for complex visual questions. When reasoning is enabled, the model takes more time to analyze the image and formulate better answers.

When to Use Reasoning

  • Complex visual analysis: Multi-step reasoning about spatial relationships, counting, or detailed observations
  • Nuanced questions: Questions requiring careful interpretation or inference
  • High accuracy requirements: When you need the most accurate possible answer

Trade-offs

  • Speed: Reasoning adds minor latency to requests (typically 10-20% longer)

SDK Examples

View Python SDK Documentation →

import moondream as md
from PIL import Image

# Initialize with your API key
model = md.vl(api_key="YOUR_API_KEY")

# Load an image
image = Image.open("path/to/image.jpg")

# Query with reasoning enabled
result = model.query(image, "What is in this image?", reasoning=True)
print(result["answer"])