# Upscale - Documentation

> For the complete documentation index, see [llms.txt](/llms.txt). Markdown is available with `Accept: text/markdown` and `.md` URL variants.

Source: /docs/api-reference/model-apis-upscale

# Upscale

POST

/

v3

/

async

/

upscale

Try it

Upscale

cURL

```
curl --request POST \
--url https://api.novita.ai/v3/async/upscale \
--header 'Authorization: &#x3C;authorization>' \
--header 'Content-Type: &#x3C;content-type>' \
--data '
{
"extra": {
"response_image_type": "&#x3C;string>",
"webhook": {
"url": "&#x3C;string>",
"test_mode": {
"enabled": true,
"return_task_status": "&#x3C;string>"
}
},
"custom_storage": {
"aws_s3": {
"region": "&#x3C;string>",
"bucket": "&#x3C;string>",
"path": "&#x3C;string>",
"save_to_path_directly": true
}
},
"enterprise_plan": {
"enabled": true
},
"enable_nsfw_detection": true,
"nsfw_detection_level": 123
},
"request": {
"model_name": "&#x3C;string>",
"image_base64": "&#x3C;string>",
"scale_factor": 123
}
}
'
```

```
import requestsurl = "https://api.novita.ai/v3/async/upscale"payload = { "extra": { "response_image_type": "&#x3C;string>", "webhook": { "url": "&#x3C;string>", "test_mode": { "enabled": True, "return_task_status": "&#x3C;string>" } }, "custom_storage": { "aws_s3": { "region": "&#x3C;string>", "bucket": "&#x3C;string>", "path": "&#x3C;string>", "save_to_path_directly": True } }, "enterprise_plan": { "enabled": True }, "enable_nsfw_detection": True, "nsfw_detection_level": 123 }, "request": { "model_name": "&#x3C;string>", "image_base64": "&#x3C;string>", "scale_factor": 123 }}headers = { "Content-Type": "&#x3C;content-type>", "Authorization": "&#x3C;authorization>"}response = requests.post(url, json=payload, headers=headers)print(response.text)
```

```
const options = { method: 'POST', headers: {'Content-Type': '&#x3C;content-type>', Authorization: '&#x3C;authorization>'}, body: JSON.stringify({ extra: { response_image_type: '&#x3C;string>', webhook: {url: '&#x3C;string>', test_mode: {enabled: true, return_task_status: '&#x3C;string>'}}, custom_storage: { aws_s3: { region: '&#x3C;string>', bucket: '&#x3C;string>', path: '&#x3C;string>', save_to_path_directly: true } }, enterprise_plan: {enabled: true}, enable_nsfw_detection: true, nsfw_detection_level: 123 }, request: {model_name: '&#x3C;string>', image_base64: '&#x3C;string>', scale_factor: 123} })};fetch('https://api.novita.ai/v3/async/upscale', options) .then(res => res.json()) .then(res => console.log(res)) .catch(err => console.error(err));
```

```
&#x3C;?php$curl = curl_init();curl_setopt_array($curl, [ CURLOPT_URL => "https://api.novita.ai/v3/async/upscale", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => json_encode([ 'extra' => [ 'response_image_type' => '&#x3C;string>', 'webhook' => [ 'url' => '&#x3C;string>', 'test_mode' => [ 'enabled' => true, 'return_task_status' => '&#x3C;string>' ] ], 'custom_storage' => [ 'aws_s3' => [ 'region' => '&#x3C;string>', 'bucket' => '&#x3C;string>', 'path' => '&#x3C;string>', 'save_to_path_directly' => true ] ], 'enterprise_plan' => [ 'enabled' => true ], 'enable_nsfw_detection' => true, 'nsfw_detection_level' => 123 ], 'request' => [ 'model_name' => '&#x3C;string>', 'image_base64' => '&#x3C;string>', 'scale_factor' => 123 ] ]), CURLOPT_HTTPHEADER => [ "Authorization: &#x3C;authorization>", "Content-Type: &#x3C;content-type>" ],]);$response = curl_exec($curl);$err = curl_error($curl);curl_close($curl);if ($err) { echo "cURL Error #:" . $err;} else { echo $response;}
```

```
package mainimport (	"fmt"	"strings"	"net/http"	"io")func main() {	url := "https://api.novita.ai/v3/async/upscale"	payload := strings.NewReader("{\n \"extra\": {\n \"response_image_type\": \"&#x3C;string>\",\n \"webhook\": {\n \"url\": \"&#x3C;string>\",\n \"test_mode\": {\n \"enabled\": true,\n \"return_task_status\": \"&#x3C;string>\"\n }\n },\n \"custom_storage\": {\n \"aws_s3\": {\n \"region\": \"&#x3C;string>\",\n \"bucket\": \"&#x3C;string>\",\n \"path\": \"&#x3C;string>\",\n \"save_to_path_directly\": true\n }\n },\n \"enterprise_plan\": {\n \"enabled\": true\n },\n \"enable_nsfw_detection\": true,\n \"nsfw_detection_level\": 123\n },\n \"request\": {\n \"model_name\": \"&#x3C;string>\",\n \"image_base64\": \"&#x3C;string>\",\n \"scale_factor\": 123\n }\n}")	req, _ := http.NewRequest("POST", url, payload)	req.Header.Add("Content-Type", "&#x3C;content-type>")	req.Header.Add("Authorization", "&#x3C;authorization>")	res, _ := http.DefaultClient.Do(req)	defer res.Body.Close()	body, _ := io.ReadAll(res.Body)	fmt.Println(string(body))}
```

```
HttpResponse&#x3C;String> response = Unirest.post("https://api.novita.ai/v3/async/upscale") .header("Content-Type", "&#x3C;content-type>") .header("Authorization", "&#x3C;authorization>") .body("{\n \"extra\": {\n \"response_image_type\": \"&#x3C;string>\",\n \"webhook\": {\n \"url\": \"&#x3C;string>\",\n \"test_mode\": {\n \"enabled\": true,\n \"return_task_status\": \"&#x3C;string>\"\n }\n },\n \"custom_storage\": {\n \"aws_s3\": {\n \"region\": \"&#x3C;string>\",\n \"bucket\": \"&#x3C;string>\",\n \"path\": \"&#x3C;string>\",\n \"save_to_path_directly\": true\n }\n },\n \"enterprise_plan\": {\n \"enabled\": true\n },\n \"enable_nsfw_detection\": true,\n \"nsfw_detection_level\": 123\n },\n \"request\": {\n \"model_name\": \"&#x3C;string>\",\n \"image_base64\": \"&#x3C;string>\",\n \"scale_factor\": 123\n }\n}") .asString();
```

```
require 'uri'require 'net/http'url = URI("https://api.novita.ai/v3/async/upscale")http = Net::HTTP.new(url.host, url.port)http.use_ssl = truerequest = Net::HTTP::Post.new(url)request["Content-Type"] = '&#x3C;content-type>'request["Authorization"] = '&#x3C;authorization>'request.body = "{\n \"extra\": {\n \"response_image_type\": \"&#x3C;string>\",\n \"webhook\": {\n \"url\": \"&#x3C;string>\",\n \"test_mode\": {\n \"enabled\": true,\n \"return_task_status\": \"&#x3C;string>\"\n }\n },\n \"custom_storage\": {\n \"aws_s3\": {\n \"region\": \"&#x3C;string>\",\n \"bucket\": \"&#x3C;string>\",\n \"path\": \"&#x3C;string>\",\n \"save_to_path_directly\": true\n }\n },\n \"enterprise_plan\": {\n \"enabled\": true\n },\n \"enable_nsfw_detection\": true,\n \"nsfw_detection_level\": 123\n },\n \"request\": {\n \"model_name\": \"&#x3C;string>\",\n \"image_base64\": \"&#x3C;string>\",\n \"scale_factor\": 123\n }\n}"response = http.request(request)puts response.read_body
```

200

```
{
"task_id": "&#x3C;string>"
}
```

An indispensable tool for improving the quality of images generated by Stable Diffusion.

This is an asynchronous API; only the task_id will be returned. You should use the task_id to request the [Task Result API](/docs/api-reference/model-apis-task-result) to retrieve the image generation results.

##

[​](#request-headers)

Request Headers

[​](#param-content-type)

Content-Type

string

required

Enum: `application/json`

[​](#param-authorization)

Authorization

string

required

Bearer authentication format, for example: Bearer {{API Key}}.

##

[​](#request-body)

Request Body

[​](#param-extra)

extra

object

Optional extra parameters for the request.

Show properties

[​](#param-response-image-type)

response_image_type

string

The returned image type. Default is png.

Enum: `png`, `webp`, `jpeg`

[​](#param-webhook)

webhook

object

Webhook settings. More details can be found at [Webhook Documentation](/docs/api-reference/model-apis-webhook).

Show properties

[​](#param-url)

url

string

required

The URL of the webhook endpoint. Novita AI will send the task generated outputs to your specified webhook endpoint.

[​](#param-test-mode)

test_mode

object

By specifying Test Mode, a mock event will be sent to the webhook endpoint.

Show properties

[​](#param-enabled)

enabled

boolean

required

Set to true to enable Test Mode, or false to disable it. The default is false.

[​](#param-return-task-status)

return_task_status

string

required

Control the data content of the mock event. When set to TASK_STATUS_SUCCEED, you’ll receive a normal response; when set to TASK_STATUS_FAILED, you’ll receive an error response.

Enum: `TASK_STATUS_SUCCEED`, `TASK_STATUS_FAILED`

[​](#param-custom-storage)

custom_storage

object

Customer storage settings for saving the generated outputs.
By default, the generated outputs will be saved to Novita AI Storage temporarily and privately.

Show properties

[​](#param-aws-s3)

aws_s3

object

AWS S3 Bucket settings.

Show properties

[​](#param-region)

region

string

required

AWS S3 regions, [more details](https://docs.aws.amazon.com/general/latest/gr/rande.html).

[​](#param-bucket)

bucket

string

required

AWS S3 bucket name.

[​](#param-path)

path

string

required

AWS S3 bucket path for saving generated outputs.

[​](#param-save-to-path-directly)

save_to_path_directly

boolean

Set this option to True to save the generated outputs directly to the specified path without creating any additional directory hierarchy.
If set to False, Novita AI will create an additional directory in the path to save the generated outputs. The default is False.

[​](#param-enterprise-plan)

enterprise_plan

object

Dedicated Endpoints settings, which only take effect for users who have already subscribed to the [Dedicated Endpoints Documentation](/docs/guides/model-apis-dedicated-endpoints).

Show properties

[​](#param-enabled-1)

enabled

boolean

Set to true to schedule this task to use your Dedicated Endpoints’s dedicated resources. Default is false.

[​](#param-enable-nsfw-detection)

enable_nsfw_detection

boolean

When set to true, NSFW detection will be enabled, incurring an additional cost of $0.0015 for each generated image.

[​](#param-nsfw-detection-level)

nsfw_detection_level

integer

0: Explicit Nudity, Explicit Sexual Activity, Sex Toys; Hate Symbols.
1: Explicit Nudity, Explicit Sexual Activity, Sex Toys; Hate Symbols; Non-Explicit Nudity, Obstructed Intimate Parts, Kissing on the Lips.
2: Explicit Nudity, Explicit Sexual Activity, Sex Toys; Hate Symbols; Non-Explicit Nudity, Obstructed Intimate Parts, Kissing on the Lips; Female Swimwear or Underwear, Male Swimwear or Underwear.

Enum: `0`, `1`, `2`

[​](#param-request)

request

object

required

Hide properties

[​](#param-model-name)

model_name

string

required

AI upscalers are models trained on massive amounts of data.

Enum: `RealESRGAN_x4plus_anime_6B`, `RealESRNet_x4plus`, `4x-UltraSharp`

[​](#param-image-base64)

image_base64

string

required

The base64 of original image, with a maximum resolution of 2048x2048 and a maximum file size of 30 Mb.

[​](#param-scale-factor)

scale_factor

number

required

The scale_factor indicates the multiplier by which the original size will be upscaled. Valid range: (1, 4].

##

[​](#response)

Response

[​](#param-task-id)

task_id

string

Use the task_id to request the [Task Result API](/docs/api-reference/model-apis-task-result) to retrieve the generated outputs.

##

[​](#example)

Example

This is an indispensable tool for improving the quality of images generated by Stable Diffusion.
Try it in [playground](https://novita.ai/playground#upscale).
`Request:`

```
curl --location --request POST 'https://api.novita.ai/v3/async/upscale' \
--header 'Authorization: Bearer {{API Key}}' \
--header 'Content-Type: application/json' \
--data-raw '{
"extra": {
"response_image_type": "jpeg"
},
"request": {
"model_name": "RealESRGAN_x4plus_anime_6B",
"scale_factor": 2,
"image_base64": "{{base64 encoded image}}"
}
}'
```

HTTP status codes in the 2xx range indicate that the request has been successfully accepted; code 400 indicates a request parameter error, while status codes in the 5xx range indicate internal server errors.
`Response:`

```
{
"task_id": "71dd988e-632e-4339-b217-74bcbe6db0ee"
}
```

Use `task_id` to retrieve images
HTTP status codes in the 2xx range indicate that the request has been successfully accepted, while status codes in the 5xx range indicate internal server errors.
You can find the image URLs in the `imgs` field of the response.
`Request:`

```
curl --location 'https://api.novita.ai/v3/async/task-result?task_id=71dd988e-632e-4339-b217-74bcbe6db0ee' \
--header 'Authorization: Bearer {{API Key}}'
```

`Response:`

```
{
"extra": {
"enable_nsfw_detection": false
},
"task": {
"task_id": "71dd988e-632e-4339-b217-74bcbe6db0ee",
"task_type": "UPSCALE",
"status": "TASK_STATUS_SUCCEED",
"reason": "",
"eta": 0,
"progress_percent": 0
},
"images": [
{
"image_url": "https://faas-output-image.s3.ap-southeast-1.amazonaws.com/prod/71dd988e-632e-4339-b217-74bcbe6db0ee/949a5ba965c84bd99764ca9b2f51fc6a.jpeg?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIASVPYCN6LRCW3SOUV%2F20240321%2Fap-southeast-1%2Fs3%2Faws4_request&X-Amz-Date=20240321T093338Z&X-Amz-Expires=3600&X-Amz-SignedHeaders=host&x-id=GetObject&X-Amz-Signature=e7d4dab3a82555d10ded8ad82769122b75b6bda179c60f3bacb978d85d23252e",
"image_url_ttl": "3600",
"image_type": "jpeg",
"nsfw_detection_result": null
}
],
"videos": []
}
```

![](https://next-app-static.s3.ap-southeast-1.amazonaws.com/get-started/upscale01.png)

![](https://next-app-static.s3.ap-southeast-1.amazonaws.com/get-started/upscale02.png)

Last modified on December 26, 2024
