tencent cloud

LLM Service TokenHub

AI Image Outpainting 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 Outpainting is built on WAND-Vega-Image. It uses the original image as a reference to understand the content and style of the image, generates extended regions that naturally blend with the original image, and maintains pixel-level restoration of details and textures, outputting high-definition results according to the specified aspect ratio or output size. It supports common aspect ratios such as 1:1, 3:2, 4:3, 16:9, and 21:9, flexibly adapting to the size requirements of different platforms. It is suitable for scenarios such as e-commerce hero images, advertising posters, and social media covers.
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 Outpainting 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 Image Outpainting Task

1. API Description

Expand the input image outward and complete its edges according to the target aspect ratio and size.
API: POST https://tokenhub-intl.tencentcloudmaas.com/v1/wand/tool/image-outpainting

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
aspect_ratio
No
string
Target aspect ratio: 1:1, 3:2, 2:3, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9.
width
No
integer
Output width in pixels. Use either this parameter or height, or both.
height
No
integer
Output height in pixels.

3. Sample Request

3.1 Specifying Only aspect_ratio (Adaptive Mode)

Effect: The system adaptively adjusts the output size based on the original image size and the specified aspect ratio.
Applicable scenarios: when the specific size is uncertain and only a specific aspect ratio is required.
curl -X POST 'https://tokenhub-intl.tencentcloudmaas.com/v1/wand/tool/image-outpainting' \\
-H 'Authorization: Bearer YOUR_API_KEY' \\
-H 'Content-Type: application/json' \\
-d '{
"image_url": "https://example.com/a.png",
"aspect_ratio": "16:9"
}'

3.2 Specifying aspect_ratio + width (Height Calculated Automatically)

curl -X POST 'https://tokenhub-intl.tencentcloudmaas.com/v1/wand/tool/image-outpainting' \\
-H 'Authorization: Bearer YOUR_API_KEY' \\
-H 'Content-Type: application/json' \\
-d '{
"image_url": "https://example.com/a.png",
"aspect_ratio": "16:9",
"width": 1920
}'

3.3 Specifying aspect_ratio + height (Width Calculated Automatically)

curl -X POST 'https://tokenhub-intl.tencentcloudmaas.com/v1/wand/tool/image-outpainting' \\
-H 'Authorization: Bearer YOUR_API_KEY' \\
-H 'Content-Type: application/json' \\
-d '{
"image_url": "https://example.com/a.png",
"aspect_ratio": "16:9",
"height": 1080
}'

3.4 Specifying image_width + height (Fixed Size)

curl -X POST 'https://tokenhub-intl.tencentcloudmaas.com/v1/wand/tool/image-outpainting' \\
-H 'Authorization: Bearer YOUR_API_KEY' \\
-H 'Content-Type: application/json' \\
-d '{
"image_url": "https://example.com/a.png",
"image_width": 1920,
"height": 1080
}'

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 outpainting task. After submission, poll this API until the status is completed or failed.
API: GET https://tokenhub.tencentmaas.com/v1/wand/tool/image-outpainting/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-outpainting/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, aspect_ratio or width/height is 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. 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 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.

2. What Values Are Supported for aspect_ratio?

1:1, 3:2, 2:3, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9. Passing any other value returns 400.

3. Must width and height Be Passed Together?

Not necessary. You can pass either one or both. If neither is passed, the output size is calculated based on the aspect_ratio.

4. Will Outpainting Crop the Original Image?

No. Outpainting only extends the edges outward, and the original image content is preserved.

5. Will the Generated Image URL 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.

6. 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