InstantStyle
InstantStyle
POST https://api.novita.ai/v3/async/instant-style
The InstantStyle API effectively disentangles style and content from reference images.
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.
Example
Upload Your Image Assets and Get the Asset ID
Request:
curl -X PUT -T "{{image file path}}" 'https://assets.novitai.com/image'
Response:
{
"assets_id": "xxx"
}
Python Request:
import requests
# Replace the following variables with their respective values:
image_file_path = r"/home/local/test.png"
url = 'https://assets.novitai.com/image'
# Send a PUT request
with open(image_file_path, 'rb') as file:
response = requests.put(url, data=file)
# Print the response
print(response.text)
Response:
{
"assets_id": "xxx"
}
Request the InstantStyle API
Use the image asset IDs generated from the above step to request the API. Currently, only SDXL-based models are supported.
Request:
curl --location 'https://api.novita.ai/v3/async/instant-style' \
--header 'Authorization: Bearer {{API Key}}' \
--header 'Content-Type: application/json' \
--data '{
"extra": {
"response_image_type": "jpeg"
},
"model_name": "protovisionXLHighFidelity3D_release0620Bakedvae_131308.safetensors",
"ref_image_assets_id": "Y29zL2ZhYXMtYWktYXNzZXQtMTMxMjc2NzcyMS9pbWFnZS9Fa2JTMWd1Uzd4enlyMVFxU2d4aE5CaFoyRkN6S1lOZw",
"style_mode": 2,
"prompt": "a man, masterpiece, best quality, high quality",
"negative_prompt": "bad quality, bad anatomy, worst quality, low quality, lowres, extra fingers, blur, blurry, ugly, wrong proportions, watermark, image artifacts, bad eyes, bad hands, bad arms",
"width": 768,
"height": 1024,
"image_num": 1,
"steps": 25,
"seed": -1,
"guidance_scale": 4.5,
"sampler_name": "Euler a"
}'
Response:
{
"task_id": "67ad99e7-6cda-4874-9223-xxxx"
}
Use task_id
to Get 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 result in the images
field of the response.
Request:
curl --location --request GET 'https://api.novita.ai/v3/async/task-result?task_id=67ad99e7-6cda-4874-9223-xxxx' \
--header 'Authorization: Bearer {{API Key}}'
Response:
{
"extra": {
"seed": "1099016411",
"enable_nsfw_detection": false
},
"task": {
"task_id": "67ad99e7-6cda-4874-9223-xxxx",
"task_type": "INSTANT_STYLE",
"status": "TASK_STATUS_SUCCEED",
"reason": "",
"eta": 0,
"progress_percent": 0
},
"images": [
{
"image_url": "https://faas-output-image.s3.ap-southeast-1.amazonaws.com/prod/xxx",
"image_url_ttl": "3600",
"image_type": "jpeg",
"nsfw_detection_result": null
}
],
"videos": []
}