tencent cloud

文档反馈

ImageToImage

最后更新时间:2024-10-30 10:48:14

1. API Description

Domain name for API request: aiart.tencentcloudapi.com.

This API is used to transfer the image style based on the image to image technology. Images with small figures, complex gestures or too many figures are not recommended.
It supports 3 concurrency by default, which means that up to 3 submitted tasks can be processed simultaneously. Subsequent tasks can be processed only after ongoing ones are completed.

We recommend you to use API Explorer
Try it
API Explorer provides a range of capabilities, including online call, signature authentication, SDK code generation, and API quick search. It enables you to view the request, response, and auto-generated examples.

2. Input Parameters

The following request parameter list only provides API request parameters and some common parameters. For the complete common parameter list, see Common Request Parameters.

Parameter Name Required Type Description
Action Yes String Common Params. The value used for this API: ImageToImage.
Version Yes String Common Params. The value used for this API: 2022-12-29.
Region Yes String Common Params. For more information, please see the list of regions supported by the product. This API only supports: ap-singapore.
InputImage No String Base64 code of the input mage.
Either the Base64 code or URL must be provided. If both are provided, URL prevails.
Image restrictions: The single-edge resolution must be less than 5,000 and greater than 50, and the size after Base64 encoding must be less than 8 MB. Supported formats include JPG, JPEG, PNG, BMP, TIFF and WEBP.
InputUrl No String URL of the input mage.
Either the Base64 code or URL must be provided. If both are provided, URL prevails.
Image restrictions: The single-edge resolution must be less than 5,000 and greater than 50, and the size after Base64 encoding must be less than 8 MB. Supported formats include JPG, JPEG, PNG, BMP, TIFF and WEBP.
Prompt No String Text description.
It is used to increase the possibility that the generation result contains the described content.
A maximum of 256 UTF-8 characters are supported.
NegativePrompt No String Negative text description.
It is used to reduce the possibility that the generation result contains the described content, but such content cannot be completely avoided.
English is recommended. A maximum of 256 UTF-8 characters are supported.
Styles.N No Array of String Image style.
Select the desired style from the Image Style List and enter the style number.
It is recommended to use only one style. If no style is specified, 201 (anime style) is used by default.
ResultConfig No ResultConfig Configurations of the generated image, including the resolution.
Images with the following resolutions can be generated: origin (The resolution is the same as the input image resolution, with the edge resolution of up to 2000. The image will be zoomed out proportionally if the resolution is exceeded.), 768:768 (1:1), 768:1024 (3:4), and 1024:768 (4:3).
If the resolution is not specified, origin is used by default.
LogoAdd No Integer Switch indicating whether to add a logo to the generated image. Default value: 1.
1: add logo
0: do not add logo
Other values: add logo
It is recommended to use an obvious logo to indicate that the image result is generated by AI.
LogoParam No LogoParam Logo content settings.
By default, the text "Generated by AI" is added to the bottom right corner of the generated image. You can also use other logo.
Strength No Float Generation strength.
The smaller the strength value, the more the generated image resembles the original image. Value range: (0, 1]. If the strength is not specified, the default value of the model is used.
The recommended value range is 0.6 to 0.8.
RspImgType No String Image return method (base64 or url).
You can specify only one method. Default value: base64.
The URL is valid for 1 hour.
EnhanceImage No Integer Switch indicating whether to enhance image clarity. Default value: 0.
1: on
0: off
If the switch is turned on, the image clarity will be enhanced and the generation time will increase.
RestoreFace No Integer Maximum number of faces for detail restoration. Value range: 0 - 6. Default value: 0.
If the input value is greater than 0, the value will be used as the maximum number of faces with a small area can be restored in each image. The generation time will increase according to the actual number of faces restored.

3. Output Parameters

Parameter Name Type Description
ResultImage String Different content is returned depending on the input parameter RspImgType.
If the value is base64, the Base64 code of the generated image is returned.
If the value is url, the URL of the generated image is returned. The URL is valid for 1 hour. Save it in time.
RequestId String The unique request ID, generated by the server, will be returned for every request (if the request fails to reach the server for other reasons, the request will not obtain a RequestId). RequestId is required for locating a problem.

4. Example

Example1 Calling the API

This example shows you how to call this API.

Input Example

POST / HTTP/1.1
Host: aiart.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: ImageToImage
<Common request parameters>



{
    "InputImage": "/asoaisjdio",
    "Prompt": "Girl",
    "Styles": [
        "201"
    ],
    "ResultConfig": {
        "Resolution": "768:768"
    },
    "Strength": 0.5
}

Output Example

{
    "Response": {
        "ResultImage": "/asjdioajsoi",
        "RequestId": "301bfc25-61ca-4ece-b03e-f6aefb547969"
    }
}

5. Developer Resources

SDK

TencentCloud API 3.0 integrates SDKs that support various programming languages to make it easier for you to call APIs.

Command Line Interface

6. Error Code

The following only lists the error codes related to the API business logic. For other error codes, see Common Error Codes.

Error Code Description
AuthFailure.UnauthorizedOperation You have no permission to perform this operation. check your CAM policies to make sure that you have the corresponding CAM permissions.
FailedOperation.GenerateImageFailed The generated image failed the review. Please try again.
FailedOperation.ImageDecodeFailed Image decoding failed.
FailedOperation.ImageDownloadError Image download error.
FailedOperation.ImageResolutionExceed The image resolution is too high, which exceeds 2000×2000.
FailedOperation.ImageSizeExceed The size of the image after base64 encoding cannot exceed 10 MB.
FailedOperation.InnerError Internal service error. Please try again.
FailedOperation.RequestEntityTooLarge The entire request body (usually images) is too large .
FailedOperation.RequestTimeout The backend service timed out.
FailedOperation.RpcFail RPC request failed, typically due to algorithm service malfunction.
FailedOperation.ServerError Internal service error.
FailedOperation.Unknown Unknown error.
InvalidParameter.InvalidParameter Invalid parameters.
InvalidParameterValue.ImageEmpty No image is input.
InvalidParameterValue.ParameterValueError Parameter or value is invalid.
InvalidParameterValue.StyleConflict 1xx styles cannot be used together with other styles.
InvalidParameterValue.TextLengthExceed The input text is too long. Use a shorter one and try again.
InvalidParameterValue.UrlIllegal The URL format is invalid.
OperationDenied.ImageIllegalDetected The image failed the review because it contains illegal information.
OperationDenied.TextIllegalDetected The text failed the review because it contains illegal information.
RequestLimitExceeded Too frequent requests
RequestLimitExceeded.JobNumExceed Too many tasks are being processed simultaneously. Please try again later.
ResourceUnavailable.Delivering The resource is being delivered.
ResourceUnavailable.InArrears The account is in arrears.
ResourceUnavailable.LowBalance Insufficient balance.
ResourceUnavailable.NotExist The billing status is unknown. Check whether the service has been activated in the console.
ResourceUnavailable.StopUsing Services for the account has been stopped.
ResourcesSoldOut.ChargeStatusException The billing status is abnormal.
联系我们

联系我们,为您的业务提供专属服务。

技术支持

如果你想寻求进一步的帮助,通过工单与我们进行联络。我们提供7x24的工单服务。

7x24 电话支持