tencent cloud

LLM Service TokenHub

AI Cutout API Guide

Baixar
Modo Foco
Tamanho da Fonte
Última atualização: 2026-11-30 19:32:34
Traduzido por IA

Overview

Tencent Cloud WAND is Tencent Cloud's audio and video AI brand. Its model foundation integrates self-developed vertical AI models and mainstream SOTA models, with deep engineering optimization, and has accumulated over 100+ AI applications and industry solutions, covering capabilities such as multimodal generation, understanding, audio, codecs, image quality enhancement, and erasure. AI Cutout is built on WAND-Vega-Image. It understands the relationship between subjects and backgrounds in images, accurately separates subjects, and maintains pixel-level restoration at subject edges and details, outputting transparent background images with natural edge transitions. This eliminates the tedious process of manual outlining and allows you to quickly obtain reusable subject assets. Two tiers are available: Basic and Standard. The Basic tier is the fastest, while the Standard tier balances quality and speed and can also be used for pattern extraction. It is suitable for scenarios such as e-commerce product images, poster design, and ID photo background replacement.
Note:
This API uses asynchronous calls: a task_id is returned immediately after a task is submitted, and you need to poll the query API to obtain the processing result.

Prerequisites

You have registered a Tencent Cloud account and activated the TokenHub service.
You have obtained the API Key in the TokenHub console.
Note:
In all examples below, YOUR_API_KEY must be replaced with your own API Key. The authentication method is the request header Authorization: Bearer YOUR_API_KEY.

Call Process

1. To submit a task: call the "Initiate AI Cutout Task" API, which returns a task_id upon success.
2. To query the result: call the "Query Task Result" API with the task_id until the status is completed, and obtain the result image URL from output.file_url.

Initiating an AI Cutout Task

1. API Description

Performs general foreground cutout and outputs a foreground image with a transparent background. version is required.
API: POST https://tokenhub-intl.tencentcloudmaas.com/v1/wand/tool/image-cutout

2. Input Parameters

Parameter Name
Required
Type
Description
image_url
Yes
string
Enter the image URL. http(s) public network URLs or data:image/...;base64,... format are supported. Example: https://example.com/a.png
version
Yes
string
Tier. 1.0-lite: basic edition, fastest speed; 1.0-flash: standard edition, quality-speed balance.

3. Sample Request

curl -X POST 'https://tokenhub-intl.tencentcloudmaas.com/v1/wand/tool/image-cutout' \\
-H 'Authorization: Bearer YOUR_API_KEY' \\
-H 'Content-Type: application/json' \\
-d '{
"image_url": "https://example.com/a.png",
"version": "1.0-flash"
}'

4. Output Parameters

Parameter Name
Type
Description
task_id
string
Unique task identifier, used to poll the query API.
status
string
Task status.
request_id
string
Unique request identifier. Include it when troubleshooting issues.

5. Sample Response

{
"task_id": "1400000001-ProcessImageAsync-xxxxxxxx",
"status": "queued",
"request_id": "9f1c0b7e-e024-426a-bb00-839553cb58c9"
}

Querying the Task Result

1. API Description

Query the execution status and output of an AI cutout task. After submission, poll this API until the status is completed or failed.
API: GET https://tokenhub.tencentmaas.com/v1/wand/tool/image-cutout/tasks/{task_id}

2. Input Parameters

Parameter Name
Required
Type
Description
task_id
Yes
string
Path parameter. Task ID returned by the submission API, which must be passed in as is.

3. Sample Request

curl -X GET 'https://tokenhub-intl.tencentcloudmaas.com/v1/wand/tool/image-cutout/tasks/1400000001-ProcessImageAsync-xxxxxxxx' \\
-H 'Authorization: Bearer YOUR_API_KEY'

4. Output Parameters

Parameter Name
Type
Description
task_id
string
Unique task identifier.
status
string
Task status: queued / in_progress / completed / failed.
progress
integer
Processing progress, ranging from 0 to 100.
output
object
Result product, returned only when completed.
output.file_url
string
URL of the result image, which can be directly downloaded or accessed.
error
object
Failure details, returned only when failed.
error.code
string
Error code. See "Unified error codes".
error.message
string
Error description, used for troubleshooting and not recommended for program logic judgment.
request_id
string
Unique request identifier. Include it when troubleshooting issues.

5. Sample Response

Success:
{
"task_id": "1400000001-ProcessImageAsync-xxxxxxxx",
"status": "completed",
"progress": 100,
"output": {
"file_url": "https://XXXXXXX.png"
},
"request_id": "5c93e410-e024-426a-bb00-839553cb58c9"
}
Failed:
{
"task_id": "1400000001-ProcessImageAsync-xxxxxxxx",
"status": "failed",
"progress": 100,
"error": {
"code": "InternalError",
"message": "internal error"
},
"request_id": "5c93e410-e024-426a-bb00-839553cb58c9"
}

Appendix

Unified Error Codes

The error body is unified as follows:
{"request_id": "9f1c0b7e-e024-426a-bb00-839553cb58c9", "error": {"message": "...", "type": "..."}}
HTTP
type
Meaning
400
invalid_request_error
Parameter error: image_url is missing or has an invalid format, version is missing or invalid, JSON decoding failed, task_id has an invalid format, or the task does not exist. Correct the request based on message and retry.
401
invalid_api_key
The API Key is missing or invalid. Check the Authorization request header.
404
not_found
The request path does not exist. Check the path spelling.
405
method_not_allowed
The request method is not allowed. Use POST for submission and GET for query.
429
rate_limit_exceeded
QPS rate limiting has been triggered (20 QPS by default for submission and 100 QPS by default for query). Reduce the request frequency and retry.
429
quota_exceeded
The quota has been exhausted. Retry later or apply for a quota increase.
500
server_error
An internal server error has occurred. You can retry. If the issue persists, submit a ticket with the Request ID for troubleshooting.
When a task fails, the query API returns status: failed, and the values of error.code are as follows:
Error Code
Meaning
InvalidParameterValue
The parameter is invalid (for example, the value of version). Check the input parameters.
InternalError
An internal server error has occurred. You can retry. If the issue persists, submit a ticket with the Request ID for troubleshooting.

FAQs

1. Why Is a 400 Error Returned Indicating That the version Is Missing?

version is a required parameter. Pass 1.0-lite or 1.0-flash.

2. How Do I Choose Between 1.0-lite and 1.0-flash?

1.0-lite is the fastest and is suitable for batch and time-sensitive scenarios. 1.0-flash balances quality and speed and is suitable for scenarios that require higher edge precision.

3. Why Is a 400 Error Returned Indicating That image_url Is Missing?

image_url is a required field. Make sure the field name is spelled image_url and the value is a non-empty string.

4. Do Generated Image URLs Expire?

The links will expire. The result links are temporary addresses valid for 24 hours. Make sure to download or transfer the files within 24 hours after the task succeeds, or the links will become invalid.

5. Can I Use the Same task_id for Repeated Queries?

Yes. The query API has no side effects.


Ajuda e Suporte

Esta página foi útil?

comentários