Product Background API Usage


Business Process

  • Description
  1. Use the API Image Remove Background to remove the background from product images.
  2. Use the API Product Background - submit task to submit a task to generate images.
  • Image Example
ImageExample_AnyShoot_Background

Usage Example

  • First, obtain Topview-Uid and Authorization as request header parameters. For details, see the documentation How To Get Topview Uid And Key. Assume Topview-Uid=NsDAaOPF4jLuAie4ewyg and Authorization=Bearer sk-vEsneECh1J5eKHUw4vxHI61e7FvXPnPE1625PmSt3HB【Note: Current account is unavailable ❌】.
Step1: Execute Common Task - Image Remove Background - Submit Task task to generate Product Image Without Background
curl --location --request POST 'https://api.topview.ai/v1/common_task/remove_background/submit' \
--header 'Topview-Uid: NsDAaOPF4jLuAie4ewyg' \
--header 'Authorization: Bearer sk-vEsneECh1J5eKHUw4vxHI61e7FvXPnPE1625PmSt3HB' \
--header 'Content-Type: application/json' \
--header 'Accept: */*' \
--header 'Host: api.topview.ai' \
--header 'Connection: keep-alive' \
--data-raw '{
    "productImageFileId":"5a85c359bff14c95889e4652f1ec467e",
    "noticeUrl":""
}'
  • response
{
    "code": "200",
    "message": "Success",
    "result": {
        "taskId": "56eac11a862143989e9cc63f8b213a2d",
        "status": "success",
        "errorMsg": null,
        "noticeUuid": null
    }
}
step2: Execute Common Task - Image Remove Background - Query Task
curl --location --request GET 'https://api.topview.ai/v1/common_task/remove_background/query?taskId=56eac11a862143989e9cc63f8b213a2d&needCloudFrontUrl=true' \
--header 'Topview-Uid: NsDAaOPF4jLuAie4ewyg' \
--header 'Authorization: Bearer sk-vEsneECh1J5eKHUw4vxHI61e7FvXPnPE1625PmSt3HB' \
--header 'Accept: */*' \
--header 'Host: api.topview.ai' \
--header 'Connection: keep-alive'
  • response
{
    "code": "200",
    "message": "Success",
    "result": {
        "taskId": "56eac11a862143989e9cc63f8b213a2d",
        "status": "success",
        "bgRemovedImageFileId": "e5ea811a6fb646ba9e0354232e8b97a4",
        "bgRemovedImagePath": "https://dr1coeak04nbk.cloudfront.net/analyzed_video%2Ftask%2Fbackground_removed%2F07b3e4088c2c4c7d9d7d62abc9d5f919%2Fcropped_image.png?Policy=eyJTdGF0ZW1lbnQiOiBbeyJSZXNvdXJjZSI6Imh0dHBzOi8vZHIxY29lYWswNG5iay5jbG91ZGZyb250Lm5ldC9hbmFseXplZF92aWRlbyUyRnRhc2slMkZiYWNrZ3JvdW5kX3JlbW92ZWQlMkYwN2IzZTQwODhjMmM0YzdkOWQ3ZDYyYWJjOWQ1ZjkxOSUyRmNyb3BwZWRfaW1hZ2UucG5nIiwiQ29uZGl0aW9uIjp7IkRhdGVMZXNzVGhhbiI6eyJBV1M6RXBvY2hUaW1lIjoxNzU2NjA5MjM4fX19XX0_&Signature=BM2jdXHLz2YesrpLBJZq2HCyUIpHchkKcpTVGSjnbhxWSM9hySRL9c9GcaUXdO74NjfiJIUB-FRNjqjBXbjo9fV4-wHLmBpix2Yb~FF~SZkcSG8uCQfnmkfmPJhGh18KNJ5QUMI0f7iWdGLg1Hg9OjiNhOp70ZakwpkPqfHGvV3gt9Garr3rMko3zd0ZStwT4n3LEbBFq30yYTlfaq8ErBTQ2033CYj6blkq4IwohRivLbq2pDcLnbQf9doHVoyuSKhe9mdrCK0Q7n9A4ze0mHGeP6jGtXO25llIz5Y9u5N3Segvw6Oc~zyrVgg8qJePOhMeKk4sLdhUmXqGB5W0sA__&Key-Pair-Id=K21X5TGS0ALJI4",
        "bgRemovedImageWidth": 528,
        "bgRemovedImageHeight": 720,
        "maskImageFileId": "235c776514fc42f089ab73a5ee92f391",
        "maskImagePath": "https://dr1coeak04nbk.cloudfront.net/analyzed_video%2Ftask%2Fbackground_removed%2F07b3e4088c2c4c7d9d7d62abc9d5f919%2Fmask.png?Policy=eyJTdGF0ZW1lbnQiOiBbeyJSZXNvdXJjZSI6Imh0dHBzOi8vZHIxY29lYWswNG5iay5jbG91ZGZyb250Lm5ldC9hbmFseXplZF92aWRlbyUyRnRhc2slMkZiYWNrZ3JvdW5kX3JlbW92ZWQlMkYwN2IzZTQwODhjMmM0YzdkOWQ3ZDYyYWJjOWQ1ZjkxOSUyRm1hc2sucG5nIiwiQ29uZGl0aW9uIjp7IkRhdGVMZXNzVGhhbiI6eyJBV1M6RXBvY2hUaW1lIjoxNzU2NjA5MjM4fX19XX0_&Signature=ga-4FsV5F70Ao7TY3OMcIhi7oL2ywbhP0xMnKTrbryeEKp5oKVB0O30ubGN6P7ZSeKd3tXt-EqotGVlH~0u4mf3JaOtH5JFZRfjexYX~OKx-ACqoB3MkGwh8kTL~6I9Ry4ngG9MZ03uF0fAvmVwmYRIcuMod4IBHlKFW5cuxNw7XQceJcaby~5e4Ok55Q~0KdF7XUZPoCfi3duixWaZVoXvEcVV9cOzYrBmJ1HZSYQ0VryQQPJDqGFFtL~dlAUGMXZRsMcSwphDuo355lwkjdY4RSvdHkJA~egrD0ltJ4DxvaJeGTz15dBilUWwvIYNXg-jWaPGnikXA-4pLej3kTw__&Key-Pair-Id=K21X5TGS0ALJI4",
        "maskImageWidth": 720,
        "maskImageHeight": 720
    }
}

image mode

Step3: ExecuteProduct Background - Submit TaskTask
curl --location --request POST 'https://api.topview.ai/v2/product_anyShoot/product_background/task/submit' \
--header 'Topview-Uid: NsDAaOPF4jLuAie4ewyg' \
--header 'Authorization: Bearer sk-vEsneECh1J5eKHUw4vxHI61e7FvXPnPE1625PmSt3HB' \
--header 'Content-Type: application/json' \
--header 'Accept: */*' \
--header 'Host: api.topview.ai' \
--header 'Connection: keep-alive' \
--data-raw '{
    "mode": "image",
    "productImageWithoutBackgroundFileId": "e5ea811a6fb646ba9e0354232e8b97a4",
    "templateId": "",
    "templateImageFileId": "d10d0baf132b43c18893d252dc9a9fe1",
    "prompt": "",
    "aspectRatio": "1:1",
    "location": [
        [
            0.25666666666666665,
            0.16666666666666666
        ],
        [
            0.7418533333333334,
            0.16666666666666666
        ],
        [
            0.7418533333333334,
            0.8333333333333334
        ],
        [
            0.25666666666666665,
            0.8333333333333334
        ]
    ],
    "productSimilarity": "natural",
    "noticeUrl": ""
}'
  • response
{
    "code": "200",
    "message": "Success",
    "result": {
        "taskId": "b850ba027ce74821a99ba1f6d30b58d6",
        "status": "success",
        "errorMsg": null,
        "noticeUuid": null
    }
}
Step4: ExecuteProduct Background - Query Task
curl --location --request GET 'https://api.topview.ai/v2/product_anyShoot/product_background/task/query?taskId=b850ba027ce74821a99ba1f6d30b58d6&needCloudFrontUrl' \
--header 'Topview-Uid: NsDAaOPF4jLuAie4ewyg' \
--header 'Authorization: Bearer sk-vEsneECh1J5eKHUw4vxHI61e7FvXPnPE1625PmSt3HB' \
--header 'Accept: */*' \
--header 'Host: api.topview.ai' \
--header 'Connection: keep-alive'
  • response
{
    "code": "200",
    "message": "Success",
    "result": {
        "taskId": "b850ba027ce74821a99ba1f6d30b58d6",
        "status": "success",
        "anyfitImages": [
            {
                "url": "https://aigc.s3.amazonaws.com/analyzed_video/task/object_replace_llm/d04746107e844019834417b6526709a7/0_resized.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20250828T030151Z&X-Amz-SignedHeaders=host&X-Amz-Expires=86400&X-Amz-Credential=AKIARMCUIMKIOTHGVNFI%2F20250828%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Signature=aa045f41e279a81deba09a3a84a8a058a8b2d31c7f00429424fab51b06241eeb"
            }
        ]
    }
}

prompt mode

Step3: ExecuteProduct Background - Submit TaskTask
curl --location --request POST 'https://api.topview.ai/v2/product_anyShoot/product_background/task/submit' \
--header 'Topview-Uid: NsDAaOPF4jLuAie4ewyg' \
--header 'Authorization: Bearer sk-vEsneECh1J5eKHUw4vxHI61e7FvXPnPE1625PmSt3HB' \
--header 'Content-Type: application/json' \
--header 'Accept: */*' \
--header 'Host: api.topview.ai' \
--header 'Connection: keep-alive' \
--data-raw '{
    "mode": "prompt",
    "productImageWithoutBackgroundFileId": "e5ea811a6fb646ba9e0354232e8b97a4",
    "templateId": "",
    "templateImageFileId": "",
    "prompt": "Place a medium-sized, resealable stand-up pouch of herbal powder, with a matte finish, in a well-lit, clean scene with a softly blurred, light-colored background (such as off-white or pale pink gradient). The packaging design features a mystical illustration of a woman with long flowing hair, dressed in a pale pink robe, holding a glowing cup, with a magical aura rising from it. Behind her, there'\''s an enchanting landscape of lush greenery and a cascading waterfall bathed in a soft pink light, evoking a dreamy, serene mood. The front of the pouch displays bold black text indicating the product name '\''YERBA MAGIC'\'', with '\''STRAWBERRY MATCHA FLAVOR'\'' in red, and decorative, intricate icons in gold representing key benefits like brain focus, energy, healthy gut, and low sugar. Ensure that the pouch is centered in the composition, fully visible from the front, with all product text, graphics, and subtle brand elements clear and sharp. The overall aesthetic is fresh, inviting, and modern, emphasizing an air of wellness, energy, and natural magic, suitable for an e-commerce or wellness editorial setting. No additional props, people, or distracting elements in the image. The color palette should be harmonious with the packaging, using soft pink, cream, and green-tinted shadows to give a high-end, aspirational touch.",
    "aspectRatio": "1:1",
    "location": [
        [
            0.25666666666666665,
            0.16666666666666666
        ],
        [
            0.7418533333333334,
            0.16666666666666666
        ],
        [
            0.7418533333333334,
            0.8333333333333334
        ],
        [
            0.25666666666666665,
            0.8333333333333334
        ]
    ],
    "productSimilarity": "natural",
    "noticeUrl":""
}'
  • response
{
    "code": "200",
    "message": "Success",
    "result": {
        "taskId": "acba8bb8b0dc4358945b3f05e75c3723",
        "status": "success",
        "errorMsg": null,
        "noticeUuid": null
    }
}
Step4: ExecuteProduct Background - Query Task
curl --location --request GET 'https://api.topview.ai/v2/product_anyShoot/product_background/task/query?taskId=acba8bb8b0dc4358945b3f05e75c3723&needCloudFrontUrl' \
--header 'Topview-Uid: NsDAaOPF4jLuAie4ewyg' \
--header 'Authorization: Bearer sk-vEsneECh1J5eKHUw4vxHI61e7FvXPnPE1625PmSt3HB' \
--header 'Accept: */*' \
--header 'Host: api.topview.ai' \
--header 'Connection: keep-alive'
  • response
{
    "code": "200",
    "message": "Success",
    "result": {
        "taskId": "acba8bb8b0dc4358945b3f05e75c3723",
        "status": "success",
        "anyfitImages": [
            {
                "url": "https://aigc.s3.amazonaws.com/analyzed_video/task/object_replace_llm/d6167d97befc4333bc8bf87269616005/0_resized.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20250828T030912Z&X-Amz-SignedHeaders=host&X-Amz-Expires=86400&X-Amz-Credential=AKIARMCUIMKIOTHGVNFI%2F20250828%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Signature=ee8144a8ea930c0eb89d6949f5f34a6779bbadda878c6871f76d58acd8f892d9"
            }
        ]
    }
}