# Upscale

<mark style="color:green;">`POST`</mark> `https://europe-west1-gepettoai.cloudfunctions.net/v1/upscale`

#### Headers

| Name                                            | Type   | Description         |
| ----------------------------------------------- | ------ | ------------------- |
| Authorization<mark style="color:red;">\*</mark> | String | Bearer {{API\_KEY}} |

#### Request Body

| Name                                  | Type                                 | Description                                                                                                                                                                              |
| ------------------------------------- | ------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| url<mark style="color:red;">\*</mark> | String                               | <p>Image URL of the room to be redesigned.</p><p>Ex: <a href="https://thumbs.dreamstime.com/b/empty-room-26533582.jpg"><https://thumbs.dreamstime.com/b/empty-room-26533582.jpg></a></p> |
| scale                                 | <p>Number - 2 or 3<br>Default: 2</p> | <p>(optional) Define the scale of the output. 3 being the largest size it will take more time to compute.<br>Scale of 2 is recommended for an optimal time to result.</p>                |
| webhook                               | String                               | <p>(optional) Webhook <strong>POST</strong> URL to send the result on completion.<br><br>If not provided, the request will wait for the result.</p>                                      |

{% tabs %}
{% tab title="200: OK If webhook is not set" %}

```json
{
  "base64": "<base64 encoded image>",
  "status": "success"
}
```

{% endtab %}

{% tab title="200: OK If webhook is provided" %}

```json
{
  "status": "pending",
  "id": "xxxxxxxxxxxxxx", // You can use that id with Get Job
  "mode": "upscale"
}
```

{% endtab %}

{% tab title="400: Bad Request " %}

{% endtab %}

{% tab title="401: Unauthorized " %}

{% endtab %}

{% tab title="500: Internal Server Error " %}

{% endtab %}
{% endtabs %}

### Code Examples

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

```bash

curl --location 'https://europe-west1-gepettoai.cloudfunctions.net/v1/upscale' \
--header 'Authorization: Bearer {{API_KEY}}' \
--header 'Content-Type: application/json' \
--data '{
  "url": "https://thumbs.dreamstime.com/b/empty-room-26533582.jpg"
}'
```

{% endtab %}

{% tab title="Node.js" %}

```javascript
var myHeaders = new Headers();
myHeaders.append("Authorization", "Bearer {{API_KEY}}");
myHeaders.append("Content-Type", "application/json");

var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: JSON.stringify({
    "url": "https://thumbs.dreamstime.com/b/empty-room-26533582.jpg"
  })
};

const response = await fetch("https://europe-west1-gepettoai.cloudfunctions.net/v1/upscale", requestOptions)
const body = await reponse.json();
console.log(body)
```

{% endtab %}

{% tab title="Python" %}

```python
import requests
import json

url = "https://europe-west1-gepettoai.cloudfunctions.net/v1/upscale"

payload = json.dumps({
  "url": "https://thumbs.dreamstime.com/b/empty-room-26533582.jpg"
})
headers = {
  'Authorization': 'Bearer {{API_KEY}}',
  'Content-Type': 'application/json'
}

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

print(response.text)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
$client = new Client();
$headers = [
  'Authorization' => 'Bearer {{API_KEY}}',
  'Content-Type' => 'application/json'
];
$body = '{
  "url": "https://thumbs.dreamstime.com/b/empty-room-26533582.jpg"
}';
$request = new Request('POST', 'https://europe-west1-gepettoai.cloudfunctions.net/v1/upscale', $headers, $body);
$res = $client->sendAsync($request)->wait();
echo $res->getBody();

```

{% endtab %}

{% tab title="GO" %}

```go
package main

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

func main() {

  url := "https://europe-west1-gepettoai.cloudfunctions.net/v1/upscale"
  method := "POST"

  payload := strings.NewReader(`{
    "url": "https://thumbs.dreamstime.com/b/empty-room-26533582.jpg"
}`)

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

  if err != nil {
    fmt.Println(err)
    return
  }
  req.Header.Add("Authorization", "Bearer {{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="Ruby" %}

```ruby
require "uri"
require "json"
require "net/http"

url = URI("https://europe-west1-gepettoai.cloudfunctions.net/v1/upscale")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = "Bearer {{API_KEY}}"
request["Content-Type"] = "application/json"
request.body = JSON.dump({
  "url": "https://thumbs.dreamstime.com/b/empty-room-26533582.jpg"
})

response = https.request(request)
puts response.read_body

```

{% endtab %}
{% endtabs %}

### Results

<figure><img src="https://3386250929-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FG6Nk007rm3iTJDH6P5EJ%2Fuploads%2FkVI6JPblqU3Zga4d8XNW%2Ff583a912-b5cf-472a-aa84-2f761899db5a.jpg?alt=media&#x26;token=daac9b40-5eda-4cb3-8ee1-2eef7e2404c0" alt=""><figcaption><p>BEFORE UPSCALE</p></figcaption></figure>

<figure><img src="https://3386250929-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FG6Nk007rm3iTJDH6P5EJ%2Fuploads%2FJ1IWtTOWtomFKGRbw1Jf%2F4967591c-9675-44d2-a229-c960f6afd253.jpg?alt=media&#x26;token=51ee4859-23d2-40ef-9a0c-144fb0e00b94" alt=""><figcaption><p>AFTER UPSCALE</p></figcaption></figure>

<figure><img src="https://3386250929-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FG6Nk007rm3iTJDH6P5EJ%2Fuploads%2FLcIRN8fZmNc3f8PSONNV%2F170fa683-1e92-43ce-8b1f-ab40e45ae73e.jpg?alt=media&#x26;token=2434dd73-d4cc-4841-b742-295e19ba56ce" alt=""><figcaption><p>BEFORE UPSCALE</p></figcaption></figure>

<figure><img src="https://3386250929-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FG6Nk007rm3iTJDH6P5EJ%2Fuploads%2F8RY5lNFEMlhmywUusf6o%2F4b5e6751-a9b5-4f3f-8a94-cfa9afa71fd4.jpg?alt=media&#x26;token=b3780442-95d1-4a16-9c17-bf8a48019ade" alt=""><figcaption><p>AFTER UPSCALE</p></figcaption></figure>
