# Magic Wand AI

**Note:** Also, please check out for [**Remove Object**](#remove-furniture) and [**Change Material**](#material-swap) parameters.

```
POST /v2/generate
```

**Parameters**

<table><thead><tr><th width="174">Name</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td>model</td><td>string</td><td><p><strong>Required</strong></p><p>Value must be <strong><code>magicwand</code></strong> for Magic Wand AI. Browse other <a href=""><strong>Generators</strong></a>.</p></td></tr><tr><td>image</td><td>string</td><td><p><strong>Required</strong></p><p>URL of the input image. Encode your image url if url have special characters.</p></td></tr><tr><td>mask_image</td><td>string</td><td><p><strong>Required</strong></p><p>URL of the mask image. <a href="../knowledge/what-is-mask-image">Learn more</a> about mask images. Encode your image url if url have special characters.</p></td></tr><tr><td>prompt</td><td>string</td><td><p><em>Optional</em></p><p>Description of desired design. You can use special parameters.</p></td></tr><tr><td>material_image</td><td>string</td><td><p><em>Optional</em></p><p>Material reference image to fill mask area with material. Leave empty for Prompt design or Removing objects.</p></td></tr><tr><td>remove</td><td>string</td><td>Optional<br>Use true value to Remove selected mask item</td></tr><tr><td>controlnet</td><td>string</td><td>Optional<br>Use true value for Structure-Guided Fill. It preserves mask area's painting geometry.</td></tr><tr><td>pid</td><td>integer</td><td><p>O<em>ptional</em></p><p>Persona ID to use if you want to use <a href="../personas/persona-slots">Persona Slots</a> for images.</p></td></tr><tr><td>seed</td><td>integer</td><td><p><em>Optional</em></p><p>For reproducible results</p></td></tr><tr><td>enhance_prompt</td><td>string</td><td><p><em>Optional</em></p><p>If you want to use <strong>Prompt Enhance</strong> model, use <strong><code>true</code></strong> value. If you want to continue without Prompt Enhancer don't add <strong><code>enhance_prompt</code></strong> parameter to your requests.</p></td></tr><tr><td>format</td><td>string</td><td><p><em>Optional</em></p><p>Output format values: <code>jpg</code>, <code>png</code> or <code>webp</code></p></td></tr><tr><td>processing_url</td><td>string</td><td><p><em>Optional</em></p><p>Get process results with same endpoint, alternative to <a href="../introduction/get-process-results"><strong><code>/results</code></strong></a> endpoint usage.</p></td></tr><tr><td>webhook</td><td>string</td><td><p><em>Optional</em></p><p>Get process results with real-time <a href="../introduction/webhooks">webhooks</a>, alternative to <a href="../introduction/get-process-results"><strong><code>/results</code></strong></a> endpoint usage.</p></td></tr></tbody></table>

**Curl Example**

```bash
curl -X POST https://api.luw.ai/v2/generate \
  -H "Authorization: Bearer LUW_API_TOKEN" \
  -d "model=magicwand" \
  -d "mask_image=https://example.com/roommask.jpg" \
  -d "prompt=Modern minimalist living room" \
  -d "image=https://example.com/room.jpg"
```

**Response Example**

```json
{
  "status": true,
  "progress": {
    "started_at": "2024-01-04T12:00:00Z",
    "state": "processing",
    "percent": 45
  },
  "processing": true,
  "processing_url": "abc_123..."
}
```

## ✨ Get results using the [**`/results`**](https://luw-ai.gitbook.io/api/luw.ai-api-documentation/introduction/get-process-results) endpoint.

Alternative legacy method: Add **`&processing_url={url}`** to your request.

## What is Mask Image?

A **mask image** is a black-and-white image used to define selected regions.

* **White** = the selected area (object, region, or detail)
* **Black** = the unselected background

Think of it as a spotlight: white reveals what matters, black hides the rest.

<figure><img src="https://933668614-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FQcfzRnWmd264FkUorBvB%2Fuploads%2FcyGTisFKcwLpphxV6Jfn%2FScreenshot%202025-07-21%20at%2011.04.04%E2%80%AFPM.png?alt=media&#x26;token=393a3020-fac5-4640-84ee-d049f8ad6807" alt=""><figcaption></figcaption></figure>

Mask example:

<figure><img src="https://933668614-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FQcfzRnWmd264FkUorBvB%2Fuploads%2Fxe391CayKgJyKl84RZC4%2Fmaskexample.png?alt=media&#x26;token=2c547c8b-148a-49e1-8bf1-fd98fc79ea98" alt=""><figcaption></figcaption></figure>

### Export Mask from Luw\.ai's Web Interface

<figure><img src="https://933668614-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FQcfzRnWmd264FkUorBvB%2Fuploads%2FE7F8JF2lw1RRsQjWZOed%2FScreenshot%202025-08-20%20at%208.47.52%E2%80%AFPM.png?alt=media&#x26;token=9d0b4b27-f043-4b14-88c9-9f6852024aae" alt=""><figcaption></figcaption></figure>

You want to export mask from Luw\.ai's MagicWand AI from web interface? [Click here](https://app.luw.ai/magicwand?mask_export=true) and draw your mask. Don't click "Generate with Image", rather than click "Download" button at the page's bottom. [Try WebUI Mask Exporter](https://app.luw.ai/magicwand?mask_export=true) now.

✨ Tip: Want to create masks with text prompts or get all masks?

Use **Segment AI** to generate smart mask images directly from your prompt — or retrieve masks for every object in your image. Check [Segment AI](https://luw-ai.gitbook.io/api/luw.ai-api-documentation/generators/segment-ai) for more details.

## Special Parameters

### Remove Furniture

You can execute special actions like **Remove Furniture, Remove Object or remove anything selected** with **`mask_image`** parameter, check [Mask Image](https://luw-ai.gitbook.io/api/luw.ai-api-documentation/knowledge/what-is-mask-image) section for better results.

To switch **Remove Object** mode, you can simply add **`remove`** parameter with **`true`** value like this example:

**`?remove=true`**

**Curl Example**

```bash
curl -X POST https://api.luw.ai/v2/generate \
  -H "Authorization: Bearer LUW_API_TOKEN" \
  -d "model=magicwand" \
  -d "image=https://example.com/room.jpg" \
  -d "mask_image=https://example.com/roommask.jpg" \
  -d "remove=true"
```

### Material Swap

You can execute special actions like **Swap Materials** with **`material_image`** parameter, it will change [Mask Image](https://luw-ai.gitbook.io/api/luw.ai-api-documentation/knowledge/what-is-mask-image) you provided, with the material image you provided.

To switch Material Swap mode, you can simply add **`material_image`** parameter with image url like this example:

```sh
curl -X POST https://api.luw.ai/v2/generate \
  -H "Authorization: Bearer LUW_API_TOKEN" \
  -d "model=magicwand" \
  -d "image=https://example.com/room.jpg" \
  -d "mask_image=https://example.com/roommask.jpg" \
  -d "material_image=https://example.com/material.jpg"
```
