# Moondream 3 Preview [Query]

> Moondream 3 is a vision language model that brings frontier-level visual reasoning with native object detection, pointing, and OCR capabilities to real-world applications requiring fast, inexpensive inference at scale.


## Overview

- **Endpoint**: `https://fal.run/fal-ai/moondream3-preview/query`
- **Model ID**: `fal-ai/moondream3-preview/query`
- **Category**: vision
- **Kind**: inference
**Tags**: Vision



## Pricing

Your request will cost $0.4 per million input tokens, and $3.5 per million output tokens.

For more details, see [fal.ai pricing](https://fal.ai/pricing).

## API Information

This model can be used via our HTTP API or more conveniently via our client libraries.
See the input and output schema below, as well as the usage examples.


### Input Schema

The API accepts the following input parameters:


- **`image_url`** (`string`, _required_):
  URL of the image to be processed
  - Examples: "https://storage.googleapis.com/falserverless/example_inputs/moondream-3-preview/query_in.jpg"

- **`prompt`** (`string`, _required_):
  Query to be asked in the image
  - Examples: "List the safety measures taken by this worker in a JSON array under `safety_measures` key"

- **`reasoning`** (`boolean`, _optional_):
  Whether to include detailed reasoning behind the answer Default value: `true`
  - Default: `true`

- **`temperature`** (`float`, _optional_):
  Sampling temperature to use, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If not set, defaults to 0.
  - Range: `0` to `1`

- **`top_p`** (`float`, _optional_):
  Nucleus sampling probability mass to use, between 0 and 1.
  - Range: `0` to `1`



**Required Parameters Example**:

```json
{
  "image_url": "https://storage.googleapis.com/falserverless/example_inputs/moondream-3-preview/query_in.jpg",
  "prompt": "List the safety measures taken by this worker in a JSON array under `safety_measures` key"
}
```

**Full Example**:

```json
{
  "image_url": "https://storage.googleapis.com/falserverless/example_inputs/moondream-3-preview/query_in.jpg",
  "prompt": "List the safety measures taken by this worker in a JSON array under `safety_measures` key",
  "reasoning": true
}
```


### Output Schema

The API returns the following output format:

- **`finish_reason`** (`string`, _required_):
  Reason for finishing the output generation
  - Examples: "stop"

- **`usage_info`** (`UsageInfo`, _required_):
  Usage information for the request
  - Examples: {"output_tokens":23,"prefill_time_ms":54.45315001998097,"input_tokens":737,"ttft_ms":91.87838807702065,"decode_time_ms":811.5944429300725}

- **`output`** (`string`, _required_):
  Answer to the query about the image
  - Examples: "{\n  \"safety_measures\": [\n    \"Red hard hat\",\n    \"Safety glasses\"\n  ]\n}"

- **`reasoning`** (`string`, _optional_):
  Detailed reasoning behind the answer, if enabled
  - Examples: "The worker is wearing a red hard hat for head protection and safety glasses for eye protection."



**Example Response**:

```json
{
  "finish_reason": "stop",
  "usage_info": {
    "output_tokens": 23,
    "prefill_time_ms": 54.45315001998097,
    "input_tokens": 737,
    "ttft_ms": 91.87838807702065,
    "decode_time_ms": 811.5944429300725
  },
  "output": "{\n  \"safety_measures\": [\n    \"Red hard hat\",\n    \"Safety glasses\"\n  ]\n}",
  "reasoning": "The worker is wearing a red hard hat for head protection and safety glasses for eye protection."
}
```


## Usage Examples

### cURL

```bash
curl --request POST \
  --url https://fal.run/fal-ai/moondream3-preview/query \
  --header "Authorization: Key $FAL_KEY" \
  --header "Content-Type: application/json" \
  --data '{
     "image_url": "https://storage.googleapis.com/falserverless/example_inputs/moondream-3-preview/query_in.jpg",
     "prompt": "List the safety measures taken by this worker in a JSON array under `safety_measures` key"
   }'
```

### Python

Ensure you have the Python client installed:

```bash
pip install fal-client
```

Then use the API client to make requests:

```python
import fal_client

def on_queue_update(update):
    if isinstance(update, fal_client.InProgress):
        for log in update.logs:
           print(log["message"])

result = fal_client.subscribe(
    "fal-ai/moondream3-preview/query",
    arguments={
        "image_url": "https://storage.googleapis.com/falserverless/example_inputs/moondream-3-preview/query_in.jpg",
        "prompt": "List the safety measures taken by this worker in a JSON array under `safety_measures` key"
    },
    with_logs=True,
    on_queue_update=on_queue_update,
)
print(result)
```

### JavaScript

Ensure you have the JavaScript client installed:

```bash
npm install --save @fal-ai/client
```

Then use the API client to make requests:

```javascript
import { fal } from "@fal-ai/client";

const result = await fal.subscribe("fal-ai/moondream3-preview/query", {
  input: {
    image_url: "https://storage.googleapis.com/falserverless/example_inputs/moondream-3-preview/query_in.jpg",
    prompt: "List the safety measures taken by this worker in a JSON array under `safety_measures` key"
  },
  logs: true,
  onQueueUpdate: (update) => {
    if (update.status === "IN_PROGRESS") {
      update.logs.map((log) => log.message).forEach(console.log);
    }
  },
});
console.log(result.data);
console.log(result.requestId);
```


## Additional Resources

### Documentation

- [Model Playground](https://fal.ai/models/fal-ai/moondream3-preview/query)
- [API Documentation](https://fal.ai/models/fal-ai/moondream3-preview/query/api)
- [OpenAPI Schema](https://fal.ai/api/openapi/queue/openapi.json?endpoint_id=fal-ai/moondream3-preview/query)

### fal.ai Platform

- [Platform Documentation](https://docs.fal.ai)
- [Python Client](https://docs.fal.ai/clients/python)
- [JavaScript Client](https://docs.fal.ai/clients/javascript)
