Skip to main content

Replace object


Replace object

POST https://api.novita.ai/v3/async/replace-object

Replace unwanted objects, defects, people to target as your wish.

This is an asynchronous API, only the task_id will be returned. You should use the task_id to request the Task Result API at https://novita.ai/reference/task/task.htmlopen in new window to retrieve the image generation results.

Request header parameters

  • Content-TypestringRequired

    undefined

    Enum:
    application/json
  • AuthorizationstringRequired

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

Request Body parameters

  • extraobject

    Optional extra parameters for the request.

    Show properties
  • image_filestringRequired

    The base64 of original image, with a maximum resolution of 16 megapixels and a max file size of 30 Mb.

  • promptstringRequired

    Text input required to guide the image generation, divided by `,`, Range [1, 1024].

  • negative_promptstringRequired

    Negtive prompt word, length [0, 512], divided by ,

  • object_promptstringRequired

    The prompt of the object to be replaced, used to specify the object, length [1, 512], divided by ,

Responses

Example

This API helps to replace unwanted objects, defects, people to target as your wish.

Try it in playgroundopen in new window.

Request:

curl --location --request POST 'https://api.novita.ai/v3/async/replace-object' \
--header 'Authorization: Bearer {{key}}' \
--header 'Content-Type: application/json' \
--data-raw '{
    "negative_prompt": "ng_deepnegative_v1_75t, (badhandv4:1.2), (worst quality:2), (low quality:2), (normal quality:2), lowres, bad anatomy, bad hands, ((monochrome)), ((grayscale)) watermark, moles",
    "prompt": "a dog",
    "object_prompt": "1girl",
    "image_file": "{{Base64 encoded image}}"
}'

Response:

{
    "task_id": "d4b2b68f-fd45-41b7-a095-a563e9d3405f"
}

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 get images url in imgs.image_url of response.

Request:

curl --location --request GET 'https://api.novita.ai/v3/async/task-result?task_id=d4b2b68f-fd45-41b7-a095-a563e9d3405f' \
--header 'Authorization: Bearer {{key}}'

Response:

{
    "task": {
        "task_id": "d4b2b68f-fd45-41b7-a095-a563e9d3405f",
        "status": "TASK_STATUS_SUCCEED",
        "reason": ""
    },
    "images": [
        {
            "image_url": "https://faas-output-image.s3.*****",
            "image_url_ttl": "3600",
            "image_type": "jpeg"
        }
    ]
}
novita.ai API
novita.ai API