# Material Swap

This could involve changing the type of material used for a particular element, such as switching from wood to metal for a furniture piece or from traditional tiles to marble for a flooring surface.

## ENDPOINT&#x20;

<mark style="color:green;">**`POST`**</mark>  <mark style="color:purple;">**`/material_swap`**</mark>

An API URL would be like <mark style="color:blue;"><https://homedesigns.ai/api/v2/material\\_swap></mark>

{% hint style="info" %} <mark style="color:blue;">Replace materials on surfaces to explore different textures and finishes.</mark>
{% endhint %}

{% tabs %}
{% tab title="Request" %}
{% hint style="info" %} <mark style="color:blue;">An API request must be in the</mark> <mark style="color:orange;">**`form-data`**</mark> <mark style="color:blue;">format.</mark>
{% endhint %}

### Request

<table><thead><tr><th width="232">Parameters &#x26; Data Type</th><th width="181">Value</th><th>Description</th></tr></thead><tbody><tr><td><p><mark style="color:red;"><strong><code>image</code></strong></mark>  </p><p>file[ .jpg, .jpeg, .png] / base64 Image <mark style="color:green;"><code>string</code></mark></p></td><td>-</td><td>The image to be processed by the API. The image dimensions must be 512x512 pixels or greater for optimal results. <strong>(Required Parameter)</strong></td></tr><tr><td><mark style="color:red;"><strong><code>masked_image</code></strong></mark><br>file[ .jpg, .jpeg, .png] / base64 Image <mark style="color:green;"><code>string</code></mark></td><td>-</td><td>The image to be processed by the API. The image dimensions must be 512x512 pixels or greater for optimal results. <a href="https://homedesigns.ai/get-mask-image">Click Here</a> to generate a mask image <a href="https://youtu.be/2wmHz2ze0t4">Video Tutorial.</a> <strong>(Required Parameter)</strong></td></tr><tr><td><p><mark style="color:red;"><strong><code>no_design</code></strong></mark> </p><p><mark style="color:green;"><code>integer</code></mark></p></td><td>Min - 2, Max - 5</td><td>Specifies the number of design variations you want the API to generate. The minimum is 2 and the maximum is 5.                    <strong>(Required Parameter)</strong></td></tr><tr><td><p><mark style="color:red;"><strong><code>texture_image</code></strong></mark></p><p>file[ .jpg, .jpeg, .png] / base64 Image <mark style="color:green;"><code>string</code></mark></p></td><td>The texture image should be uploaded according to your preference.</td><td><p>The image to be processed by the API. </p><p><strong>(Required Parameter)</strong></p></td></tr><tr><td><mark style="color:red;"><strong><code>no_of_texture</code></strong></mark></td><td>The number of textures must be either The number of textures must be either 1 X 1, 2 X 2, 3 X 3, 4 X 4, 5 X 5.</td><td>The number of textures can be changed according to your preference. <strong>(Required Parameter)</strong></td></tr></tbody></table>
{% endtab %}

{% tab title="Errors" %}

### Parameters & Errors

<mark style="color:red;">**`image`**</mark>

<table><thead><tr><th width="327">Error Messages</th><th>Reason</th></tr></thead><tbody><tr><td>Image field required</td><td>Image not provided</td></tr><tr><td>Invalid image size. The image width and height must be 512x512 or greater than 512x512 pixels.</td><td>Image Size Not Proper.</td></tr><tr><td>Invalid image format. Only PNG, JPEG and JPG images are allowed.</td><td>Image Format not valid.</td></tr></tbody></table>

<mark style="color:red;">**`masked_image`**</mark>

<table><thead><tr><th width="327">Error Messages</th><th>Reason</th></tr></thead><tbody><tr><td>masked_image field required</td><td>masked_image not provided</td></tr><tr><td>Invalid image size. The image width and height must be 512x512 or greater than 512x512 pixels.</td><td>masked_image Size must be greater than 512x512.</td></tr><tr><td>Invalid image format. Only PNG, JPEG and JPG images are allowed.</td><td>masked_image Format not valid.</td></tr></tbody></table>

<mark style="color:red;">**`no_design`**</mark>

<table><thead><tr><th width="327">Error Messages</th><th>Reason</th></tr></thead><tbody><tr><td>no_design field required</td><td>no_design not provided</td></tr><tr><td>no_design value is not a valid enumeration member; permitted:  2, 3, 4, 5.</td><td>no_design not provided properly</td></tr></tbody></table>

<mark style="color:red;">**`texture_image`**</mark>

<table><thead><tr><th width="327">Error Messages</th><th>Reason</th></tr></thead><tbody><tr><td>The texture_image field is required.</td><td>whether the texture_image is required to get the results.</td></tr><tr><td>The texture_image field must be a file of type: jpeg, png, jpg</td><td>Image Format is not valid.</td></tr></tbody></table>

<mark style="color:red;">**`no_of_texture`**</mark>

<table><thead><tr><th width="327">Error Messages</th><th>Reason</th></tr></thead><tbody><tr><td>no_of_texture field required</td><td>no_of_texture not provided</td></tr><tr><td>no_of_texture value is not a valid enumeration member; permitted: <br>1 X 1, 2 X 2, 3 X 3, 4 X 4, 5 X 5.</td><td>no_of_texture not provided properly</td></tr></tbody></table>
{% endtab %}

{% tab title="Response" %}

<pre class="language-json"><code class="lang-json"><strong>
</strong><strong>//Output should be in list of array depends on no of designs as shown below:
</strong>
{
    "input_image": "https://storage.googleapis.com/generativeartbucket/UserGenerations/cristian/input-9a87be38-4cbf-4a6f-9e8c-434c0a8f73ef-2024-05-30-11-08-30.png",
    "output_images": [
            "https://storage.googleapis.com/generativeartbucket/UserGenerations/cristian/output-9a87be38-4cbf-4a6f-9e8c-434c0a8f73ef-1.png",
            "https://storage.googleapis.com/generativeartbucket/UserGenerations/cristian/output-9a87be38-4cbf-4a6f-9e8c-434c0a8f73ef-2.png",
            "https://storage.googleapis.com/generativeartbucket/UserGenerations/cristian/output-9a87be38-4cbf-4a6f-9e8c-434c0a8f73ef-2.png"
    ]
}



</code></pre>

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://api.homedesigns.ai/homedesignsai-api-documentation/core-apis/material-swap.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
