Upscale
curl --request POST \
--url https://api.novita.ai/v3/async/upscale \
--header 'Authorization: <authorization>' \
--header 'Content-Type: <content-type>' \
--data '
{
"extra": {
"response_image_type": "<string>",
"webhook": {
"url": "<string>",
"test_mode": {
"enabled": true,
"return_task_status": "<string>"
}
},
"custom_storage": {
"aws_s3": {
"region": "<string>",
"bucket": "<string>",
"path": "<string>",
"save_to_path_directly": true
}
},
"enterprise_plan": {
"enabled": true
},
"enable_nsfw_detection": true,
"nsfw_detection_level": 123
},
"request": {
"model_name": "<string>",
"image_base64": "<string>",
"scale_factor": 123
}
}
'import requests
url = "https://api.novita.ai/v3/async/upscale"
payload = {
"extra": {
"response_image_type": "<string>",
"webhook": {
"url": "<string>",
"test_mode": {
"enabled": True,
"return_task_status": "<string>"
}
},
"custom_storage": { "aws_s3": {
"region": "<string>",
"bucket": "<string>",
"path": "<string>",
"save_to_path_directly": True
} },
"enterprise_plan": { "enabled": True },
"enable_nsfw_detection": True,
"nsfw_detection_level": 123
},
"request": {
"model_name": "<string>",
"image_base64": "<string>",
"scale_factor": 123
}
}
headers = {
"Content-Type": "<content-type>",
"Authorization": "<authorization>"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': '<content-type>', Authorization: '<authorization>'},
body: JSON.stringify({
extra: {
response_image_type: '<string>',
webhook: {url: '<string>', test_mode: {enabled: true, return_task_status: '<string>'}},
custom_storage: {
aws_s3: {
region: '<string>',
bucket: '<string>',
path: '<string>',
save_to_path_directly: true
}
},
enterprise_plan: {enabled: true},
enable_nsfw_detection: true,
nsfw_detection_level: 123
},
request: {model_name: '<string>', image_base64: '<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));<?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' => '<string>',
'webhook' => [
'url' => '<string>',
'test_mode' => [
'enabled' => true,
'return_task_status' => '<string>'
]
],
'custom_storage' => [
'aws_s3' => [
'region' => '<string>',
'bucket' => '<string>',
'path' => '<string>',
'save_to_path_directly' => true
]
],
'enterprise_plan' => [
'enabled' => true
],
'enable_nsfw_detection' => true,
'nsfw_detection_level' => 123
],
'request' => [
'model_name' => '<string>',
'image_base64' => '<string>',
'scale_factor' => 123
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"Content-Type: <content-type>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.novita.ai/v3/async/upscale"
payload := strings.NewReader("{\n \"extra\": {\n \"response_image_type\": \"<string>\",\n \"webhook\": {\n \"url\": \"<string>\",\n \"test_mode\": {\n \"enabled\": true,\n \"return_task_status\": \"<string>\"\n }\n },\n \"custom_storage\": {\n \"aws_s3\": {\n \"region\": \"<string>\",\n \"bucket\": \"<string>\",\n \"path\": \"<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\": \"<string>\",\n \"image_base64\": \"<string>\",\n \"scale_factor\": 123\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "<content-type>")
req.Header.Add("Authorization", "<authorization>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.novita.ai/v3/async/upscale")
.header("Content-Type", "<content-type>")
.header("Authorization", "<authorization>")
.body("{\n \"extra\": {\n \"response_image_type\": \"<string>\",\n \"webhook\": {\n \"url\": \"<string>\",\n \"test_mode\": {\n \"enabled\": true,\n \"return_task_status\": \"<string>\"\n }\n },\n \"custom_storage\": {\n \"aws_s3\": {\n \"region\": \"<string>\",\n \"bucket\": \"<string>\",\n \"path\": \"<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\": \"<string>\",\n \"image_base64\": \"<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 = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = '<content-type>'
request["Authorization"] = '<authorization>'
request.body = "{\n \"extra\": {\n \"response_image_type\": \"<string>\",\n \"webhook\": {\n \"url\": \"<string>\",\n \"test_mode\": {\n \"enabled\": true,\n \"return_task_status\": \"<string>\"\n }\n },\n \"custom_storage\": {\n \"aws_s3\": {\n \"region\": \"<string>\",\n \"bucket\": \"<string>\",\n \"path\": \"<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\": \"<string>\",\n \"image_base64\": \"<string>\",\n \"scale_factor\": 123\n }\n}"
response = http.request(request)
puts response.read_body{
"task_id": "<string>"
}Image Editor
Upscale
POST
/
v3
/
async
/
upscale
Upscale
curl --request POST \
--url https://api.novita.ai/v3/async/upscale \
--header 'Authorization: <authorization>' \
--header 'Content-Type: <content-type>' \
--data '
{
"extra": {
"response_image_type": "<string>",
"webhook": {
"url": "<string>",
"test_mode": {
"enabled": true,
"return_task_status": "<string>"
}
},
"custom_storage": {
"aws_s3": {
"region": "<string>",
"bucket": "<string>",
"path": "<string>",
"save_to_path_directly": true
}
},
"enterprise_plan": {
"enabled": true
},
"enable_nsfw_detection": true,
"nsfw_detection_level": 123
},
"request": {
"model_name": "<string>",
"image_base64": "<string>",
"scale_factor": 123
}
}
'import requests
url = "https://api.novita.ai/v3/async/upscale"
payload = {
"extra": {
"response_image_type": "<string>",
"webhook": {
"url": "<string>",
"test_mode": {
"enabled": True,
"return_task_status": "<string>"
}
},
"custom_storage": { "aws_s3": {
"region": "<string>",
"bucket": "<string>",
"path": "<string>",
"save_to_path_directly": True
} },
"enterprise_plan": { "enabled": True },
"enable_nsfw_detection": True,
"nsfw_detection_level": 123
},
"request": {
"model_name": "<string>",
"image_base64": "<string>",
"scale_factor": 123
}
}
headers = {
"Content-Type": "<content-type>",
"Authorization": "<authorization>"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': '<content-type>', Authorization: '<authorization>'},
body: JSON.stringify({
extra: {
response_image_type: '<string>',
webhook: {url: '<string>', test_mode: {enabled: true, return_task_status: '<string>'}},
custom_storage: {
aws_s3: {
region: '<string>',
bucket: '<string>',
path: '<string>',
save_to_path_directly: true
}
},
enterprise_plan: {enabled: true},
enable_nsfw_detection: true,
nsfw_detection_level: 123
},
request: {model_name: '<string>', image_base64: '<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));<?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' => '<string>',
'webhook' => [
'url' => '<string>',
'test_mode' => [
'enabled' => true,
'return_task_status' => '<string>'
]
],
'custom_storage' => [
'aws_s3' => [
'region' => '<string>',
'bucket' => '<string>',
'path' => '<string>',
'save_to_path_directly' => true
]
],
'enterprise_plan' => [
'enabled' => true
],
'enable_nsfw_detection' => true,
'nsfw_detection_level' => 123
],
'request' => [
'model_name' => '<string>',
'image_base64' => '<string>',
'scale_factor' => 123
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"Content-Type: <content-type>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.novita.ai/v3/async/upscale"
payload := strings.NewReader("{\n \"extra\": {\n \"response_image_type\": \"<string>\",\n \"webhook\": {\n \"url\": \"<string>\",\n \"test_mode\": {\n \"enabled\": true,\n \"return_task_status\": \"<string>\"\n }\n },\n \"custom_storage\": {\n \"aws_s3\": {\n \"region\": \"<string>\",\n \"bucket\": \"<string>\",\n \"path\": \"<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\": \"<string>\",\n \"image_base64\": \"<string>\",\n \"scale_factor\": 123\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "<content-type>")
req.Header.Add("Authorization", "<authorization>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.novita.ai/v3/async/upscale")
.header("Content-Type", "<content-type>")
.header("Authorization", "<authorization>")
.body("{\n \"extra\": {\n \"response_image_type\": \"<string>\",\n \"webhook\": {\n \"url\": \"<string>\",\n \"test_mode\": {\n \"enabled\": true,\n \"return_task_status\": \"<string>\"\n }\n },\n \"custom_storage\": {\n \"aws_s3\": {\n \"region\": \"<string>\",\n \"bucket\": \"<string>\",\n \"path\": \"<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\": \"<string>\",\n \"image_base64\": \"<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 = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = '<content-type>'
request["Authorization"] = '<authorization>'
request.body = "{\n \"extra\": {\n \"response_image_type\": \"<string>\",\n \"webhook\": {\n \"url\": \"<string>\",\n \"test_mode\": {\n \"enabled\": true,\n \"return_task_status\": \"<string>\"\n }\n },\n \"custom_storage\": {\n \"aws_s3\": {\n \"region\": \"<string>\",\n \"bucket\": \"<string>\",\n \"path\": \"<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\": \"<string>\",\n \"image_base64\": \"<string>\",\n \"scale_factor\": 123\n }\n}"
response = http.request(request)
puts response.read_body{
"task_id": "<string>"
}An indispensable tool for improving the quality of images generated by Stable Diffusion.
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.
Use

This is an asynchronous API; only the task_id will be returned. You should use the task_id to request the Task Result API to retrieve the image generation results.
Request Headers
Enum:
application/jsonBearer authentication format, for example: Bearer {{API Key}}.
Request Body
Optional extra parameters for the request.
Show properties
Show properties
The returned image type. Default is png.
Enum:
Enum:
png, webp, jpegWebhook settings. More details can be found at Webhook Documentation.
Show properties
Show properties
The URL of the webhook endpoint. Novita AI will send the task generated outputs to your specified webhook endpoint.
By specifying Test Mode, a mock event will be sent to the webhook endpoint.
Show properties
Show properties
Set to true to enable Test Mode, or false to disable it. The default is false.
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:
Enum:
TASK_STATUS_SUCCEED, TASK_STATUS_FAILEDCustomer storage settings for saving the generated outputs.
By default, the generated outputs will be saved to Novita AI Storage temporarily and privately.
By default, the generated outputs will be saved to Novita AI Storage temporarily and privately.
Show properties
Show properties
AWS S3 Bucket settings.
Show properties
Show properties
AWS S3 regions, more details.
AWS S3 bucket name.
AWS S3 bucket path for saving generated outputs.
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.
If set to False, Novita AI will create an additional directory in the path to save the generated outputs. The default is False.
Dedicated Endpoints settings, which only take effect for users who have already subscribed to the Dedicated Endpoints Documentation.
Show properties
Show properties
Set to true to schedule this task to use your Dedicated Endpoints’s dedicated resources. Default is false.
When set to true, NSFW detection will be enabled, incurring an additional cost of $0.0015 for each generated image.
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:
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, 2Hide properties
Hide properties
AI upscalers are models trained on massive amounts of data.
Enum:
Enum:
RealESRGAN_x4plus_anime_6B, RealESRNet_x4plus, 4x-UltraSharpThe base64 of original image, with a maximum resolution of 2048x2048 and a maximum file size of 30 Mb.
The scale_factor indicates the multiplier by which the original size will be upscaled. Valid range: (1, 4].
Response
Use the task_id to request the Task Result API to retrieve the generated outputs.
Example
This is an indispensable tool for improving the quality of images generated by Stable Diffusion. Try it in playground.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}}"
}
}'
Response:
{
"task_id": "71dd988e-632e-4339-b217-74bcbe6db0ee"
}
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": []
}


Last modified on December 26, 2024
Was this page helpful?
⌘I