# Create renders from image style transferring

<div><figure><img src="https://1051631996-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWpWB3PhSXYf1uN1tGGIQ%2Fuploads%2FOy4a3qiDGUnPTI4AWi9U%2Foriginal_image.jpeg?alt=media&#x26;token=411c673e-42d9-4bbb-a065-f46dddff15f1" alt=""><figcaption><p>Before</p></figcaption></figure> <figure><img src="https://1051631996-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWpWB3PhSXYf1uN1tGGIQ%2Fuploads%2FV75fXXpsEPdDCF8qK8Ow%2Fnew_output.png?alt=media&#x26;token=10c81b67-d3b1-4b07-850e-36d89c9db43a" alt=""><figcaption><p>After</p></figcaption></figure></div>

<div data-full-width="true"><figure><img src="https://1051631996-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWpWB3PhSXYf1uN1tGGIQ%2Fuploads%2FBajZUs6Cr0pgUBdml9ys%2Fstyles.png?alt=media&#x26;token=7e0e74ca-36a3-423a-81c9-e73c86050e7c" alt="" width="352"><figcaption><p>Style input</p></figcaption></figure></div>

## Description

Apply your chosen style to any room by uploading a style reference image.

## Use cases

1. Create a quick design from your customer’s brief.

## Credit

1 successful Space Design API call = 1 credit.

## API

<mark style="color:green;">`POST`</mark> `https://api.spacely.ai/api/v1/generate/style-transfer`

This endpoint is used to style transfer generate

#### Headers

| Name                                        | Type   | Description |
| ------------------------------------------- | ------ | ----------- |
| X-API-KEY<mark style="color:red;">\*</mark> | String |             |

#### Request Body

| Name                                            | Type   | Description                                                                                                                                                                                                                                                                                 |
| ----------------------------------------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| imageUrl<mark style="color:red;">\*</mark>      | String | <p>The URL of the image representing the room or space to be designed/renovated.</p><p>(e.g., "<a href="https://storage.googleapis.com/spacely/public/image/roomstyle3/bathroom-modern.jpg"><https://storage.googleapis.com/spacely/public/image/roomstyle3/bathroom-modern.jpg></a>").</p> |
| spaceType<mark style="color:red;">\*</mark>     | String | The type of the space (e.g., "bedroom", "living\_room", "kitchen", etc.).                                                                                                                                                                                                                   |
| styleImageUrl<mark style="color:red;">\*</mark> | String | The URL pointing to additional references or inspirations for the design                                                                                                                                                                                                                    |
| renovateType<mark style="color:red;">\*</mark>  | String | The type of renovation, whether "**residential**", "**commercial**" or "**exterior**"                                                                                                                                                                                                       |

{% tabs %}
{% tab title="200: OK Response ref Id for pulling data" %}

```json
{
  "data": REF_ID
}
```

{% endtab %}

{% tab title="400: Bad Request Not Found: Requested resource not found on the server." %}

{% endtab %}

{% tab title="401: Unauthorized The API key provided was invalid or missing." %}

{% endtab %}

{% tab title="500: Internal Server Error Unexpected condition on the server preventing request fulfillment." %}

{% endtab %}
{% endtabs %}

## Example

{% tabs %}
{% tab title="cURL" %}

```sh
curl --location 'https://api.spacely.ai/api/v1/generate/style-transfer' \
--header 'X-API-KEY: YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
    "spaceType": "bathroom",
    "imageUrl": "https://storage.googleapis.com/spacely/public/image/roomstyle3/bathroom-modern.jpg",
    "styleImageUrl": "https://storage.googleapis.com/spacely/public/image/residential-room-style-2/nordic-bedroom.jpg",
    "renovateType": "residential"
}'
```

{% endtab %}

{% tab title="JavaScript  " %}

```javascript
var myHeaders = new Headers();
myHeaders.append("X-API-KEY", YOUR_API_KEY);
myHeaders.append("Content-Type", "application/json");

var raw = JSON.stringify({
  "spaceType": "bathroom",
  "imageUrl": "https://storage.googleapis.com/spacely/public/image/roomstyle3/bathroom-modern.jpg",
  "styleImageUrl": "https://storage.googleapis.com/spacely/public/image/residential-room-style-2/nordic-bedroom.jpg",
  "renovateType": "residential"
});

var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("https://api.spacely.ai/api/v1/generate/style-transfer", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));
```

{% endtab %}

{% tab title="NodeJs" %}

```javascript
const axios = require('axios');
let data = JSON.stringify({
  "spaceType": "bathroom",
  "imageUrl": "https://storage.googleapis.com/spacely/public/image/roomstyle3/bathroom-modern.jpg",
  "styleImageUrl": "https://storage.googleapis.com/spacely/public/image/residential-room-style-2/nordic-bedroom.jpg",
  "renovateType": "residential"
});

let config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://api.spacely.ai/api/v1/generate/style-transfer',
  headers: { 
    'X-API-KEY': YOUR_API_KEY, 
    'Content-Type': 'application/json'
  },
  data : data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});

```

{% endtab %}

{% tab title="Go" %}

```go
package main

import (
  "fmt"
  "strings"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://api.spacely.ai/api/v1/generate/style-transfer"
  method := "POST"

  payload := strings.NewReader(`{
    "spaceType": "bathroom",
    "imageUrl": "https://storage.googleapis.com/spacely/public/image/roomstyle3/bathroom-modern.jpg",
    "styleImageUrl": "https://storage.googleapis.com/spacely/public/image/residential-room-style-2/nordic-bedroom.jpg",
    "renovateType": "residential"
}`)

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, payload)

  if err != nil {
    fmt.Println(err)
    return
  }
  req.Header.Add("X-API-KEY", YOUR_API_KEY)
  req.Header.Add("Content-Type", "application/json")

  res, err := client.Do(req)
  if err != nil {
    fmt.Println(err)
    return
  }
  defer res.Body.Close()

  body, err := ioutil.ReadAll(res.Body)
  if err != nil {
    fmt.Println(err)
    return
  }
  fmt.Println(string(body))
}
```

{% endtab %}

{% tab title="Python" %}

```python
import requests
import json

url = "https://api.spacely.ai/api/v1/generate/style-transfer"

payload = json.dumps({
  "spaceType": "bathroom",
  "imageUrl": "https://storage.googleapis.com/spacely/public/image/roomstyle3/bathroom-modern.jpg",
  "styleImageUrl": "https://storage.googleapis.com/spacely/public/image/residential-room-style-2/nordic-bedroom.jpg",
  "renovateType": "residential"
})
headers = {
  'X-API-KEY': YOUR_API_KEY,
  'Content-Type': 'application/json'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

```

{% endtab %}
{% endtabs %}

## Tips and tricks

After receiving the response, use this api to retrieve the data.

{% content-ref url="../other-endpoints/get-resources" %}
[get-resources](https://docs.enterprise.spacely.ai/spacely-ai-enterprise/other-endpoints/get-resources)
{% endcontent-ref %}

## Support

Any question? Contact us at <support@spacely.ai>
