Image and text generation OpenAPI

更新时间:
复制 MD 格式

This topic describes the APIs for image and text generation, image and text retrieval, and more.

Version history

Version

Description

Time

v1.3

Updates:

  1. The contentRequirement field of the CreateTextTask API is now compatible with rewrite requirements.

  2. Added the ListAgents API to query the agent list.

  3. Upgraded the SDK version.

2025-03-13

v1.2

Updates:

1. The API for creating image creation tasks adds new parameters: imageUrls, stickerText

  1. Updated the SDK to version 2.10.0.

2025-01-20

v1.1

Added personalized copywriting APIs and updated the SDK version.

2024-12-18

v1.0

API updates: Added the errMsg field to the Text object for the GetTextTask and GetText APIs.

2024-11-14

v0.9

New API: InteractText for interactive copywriting.

2024-09-29

v0.8

New APIs: QueryTextStream, TransferPortraitStyle, CreateRealisticPortrait, and SelectImageTask.

API update: Added the streamApi parameter to the CreateTextTask API.

Updated the SDK version.

2024-09-10

v0.7

ListTexts now supports keyword search. Added statistics APIs.

2024-07-31

v0.6

Added an API to get styles for an industry and an API for updating copywriting callbacks.

2024-07-15

v0.5

Upgraded the SDK version.

2024-06-17

v0.4

Added Texts-related data to the response parameters of the GetTextTask API.

2024-06-05

v0.3

1. Added agent ID to the request parameters of CreateTextTask.

2. Added agent ID and agent name to the response parameters of CreateTextTask, GetTextTask, GetText, and ListTexts.

2024-06-03

v0.2

  1. Added the ListTexts API.

  2. Changed the CreateTextTask API:

    1. Added the themes request parameter, which supports multiple selections.

  3. Changed the ListTextThemes API:

    1. Added the industry request parameter.

2024-05-27

v0.1

Feature release.

2024-03-20

Overview

This product includes the following basic concepts:

Concept

Description

Copywriting task

A task to generate one or more copies.

Copy

A specific piece of generated copy.

Illustration task

A task to generate one or more illustrations.

An illustration task must be initiated for a specific copy.

Illustration

A generated illustration.

Access authentication

Prerequisites

  1. Prepare an Alibaba Cloud account and use a RAM user to generate an AccessKey ID and AccessKey secret.

  2. Use the Alibaba Cloud account to grant RAM authorization to the RAM user that generated the AccessKey pair.

  3. Log on to the platform with the Alibaba Cloud account and sign the relevant legal agreements.

Product specifications

Description

Specification

Maximum number of copies that can be generated in a single copywriting task

10

Maximum number of illustration tasks that can be attached to a single copy

5

API overview

This section lists all available APIs for this product, categorized by feature.

Common APIs

API

Description

GetOssUploadToken

Obtain an OSS upload signature.

Copywriting APIs

API

Description

InteractText

Create interactive marketing copy.

QueryTextStream

Stream output content from the text API.

CreateTextTask

Create a copywriting task.

GetTextTask

Get a copywriting task.

GetText

Get a copy.

ListTexts

List copies.

ListTextThemes

List copywriting themes.

GetTextTemplate

Get styles corresponding to an industry.

AddTextFeedback

Add copywriting feedback.

CountText

Count the number of copies.

ListAgents

Query the agent list.

Illustration APIs

API

Description

CreateIllustrationTask

Create an illustration task.

GetIllustrationTask

Get an illustration task.

GetIllustration

Get an illustration.

Personalized copywriting APIs

API

Description

CreateIndividuationProject

Create a project.

DeleteIndividuationProject

Delete a project.

CreateIndividuationTextTask

Create a copywriting task.

QueryIndividuationTextTask

Query a copywriting task.

BathQueryIndividuationText

Batch query copywriting content.

DeleteIndividuationText

Delete a copy.

Copywriting API details

InteractText

API description: Creates interactive marketing copy.

Request parameters

Parameter Name

Type

Required

Description

Example

agentId

String

No. Specify either this parameter or sessionId.

The agent ID. If you provide an agentId but not a sessionId, a new session is created.

11

sessionId

String

No. Specify either this parameter or agentId.

The session ID. If you provide a sessionId, the Q&A is based on the context of the current session.

11

content

String

Yes

The conversation content.

Tell me about the travel guide.

Response parameters

Parameter name

Type

Required

Description

Example

type

Int

Yes

The message type.

2: Copywriting content.

3: Error message.

2

message

String

No

The message content.

Hello

sessionId

String

No

The session ID.

111

relatedImages

List<String>

No

Related Image URL

relatedVideos

List<String>

No

The URLs of related videos.

end

Boolean

No

Indicates whether the output is complete.

true

Streaming APIs require the asynchronous Java SDK.

InteractTextRequest request = InteractTextRequest.builder()
                .agentId("1")
//                .sessionId("1")
                .content("Test").build();
        ResponseIterable<InteractTextResponseBody> responseBodies = client.interactTextWithResponseIterable(request);
        Gson gson = new Gson();
        System.out.println("------------");
        System.out.println(gson.toJson(request));
        System.out.println();
        for (InteractTextResponseBody responseBody : responseBodies) {
            System.out.print(responseBody.getMessage());
            if (responseBody.getEnd()) {
                System.out.println("\n\nRequest ended: sessionId=" + responseBody.getSessionId());
                if (responseBody.getRelatedImages() != null && !responseBody.getRelatedImages().isEmpty()) {
                    System.out.println("Related images: " + responseBody.getRelatedImages());
                }
                if (responseBody.getRelatedVideos() != null && !responseBody.getRelatedVideos().isEmpty()) {
                    System.out.println("Related videos: " + responseBody.getRelatedVideos());
                }
                break;
            }
        }
        System.out.println();
        System.out.println();
        System.out.println();
        System.out.println("-------------");
        System.out.println(responseBodies.getHeaders());

QueryTextStream

API description: Streams the output content from the text API.

Request parameters

Parameter name

Type

Required

Description

Example

textId

Long

Yes

Copy ID

329

Response parameters

Parameter name

Type

Required

Description

Example

type

Int

Yes

The message type.

0: Heartbeat.

1: Copy title.

2: Copywriting content.

3: Error message.

1

message

String

No

The message content.

Hello

index

Int

No

The text sequence.

1

end

Boolean

No

Indicates whether the output is complete.

true

Streaming APIs require the asynchronous Java SDK.

public static void main(String[] args) {
        StaticCredentialProvider provider = StaticCredentialProvider.create(
                Credential.builder()
                        .accessKeyId(ak)
                        .accessKeySecret(sk)
                        .build()
        );

        AsyncClient client = AsyncClient.builder()
                .region("cn-hangzhou")
                .credentialsProvider(provider)
                .serviceConfiguration(Configuration.create()
                        .setSignatureVersion(SignatureVersion.V3)
                )
                .overrideConfiguration(
                        ClientOverrideConfiguration.create()
                                .setProtocol("HTTPS")
                                .setEndpointOverride(url)
                )
                .build();

        QueryTextStreamRequest request = QueryTextStreamRequest.builder().textId(329L).build();
        ResponseIterable<QueryTextStreamResponseBody> responseBodies = client.queryTextStreamWithResponseIterable(request);
        for (QueryTextStreamResponseBody responseBody : responseBodies) {
             if (responseBody.getType().equals(0)) {
                 // No output is required for heartbeat detection.
                continue;
            }
            if (responseBody.getType().equals(3)) {
                 // Abnormal information. Trigger an alert.
                break;
            }
            System.out.print(responseBody.getMessage());

            if (responseBody.getEnd()) {
                System.out.println("\n\nRequest ended: " + responseBody.getType() + "  -- " + responseBody.getIndex());
            }
        }
        System.out.println();
        System.out.println();
        System.out.println();
        System.out.println(responseBodies.getHeaders());


    }

CreateTextTask

API description: Creates a copywriting task.

Request parameters: TextTaskCreateCmd

Parameter

Type

Required

Description

Example

style

String

Yes

The copywriting style.

  • RED_BOOK: Little Red Book

  • WECHAT_MOMENT: Moments

WECHAT_MOMENT

textModeType

String

Yes

The mode.

  • Generate

  • Rewrite

Generate

number

Integer

Yes

The number of copies to generate.

4

industry

String

Required for Xiaohongshu templates

The Moments template is mandatory.

The industry property.

Used in Generate mode.

Garment

themes

array

Required for Xiaohongshu templates

The Moments template is a requirement.

Multiple content themes.

Used in Generate mode.

[TOUR_ROUTE]

contentRequirement

String

Required for the RED_BOOK template.

Content requirements or rewrite requirements.

xxx

introduction

String

Required for Xiaohongshu templates

A Moments template is required.

The product introduction.

Used in Generate mode.

xxx

point

String

Optional for the RED_BOOK template.

The product selling points.

Used in Generate mode.

Super long battery life

target

String

Required for the RED_BOOK template.

The copywriting perspective.

Used in Generate mode.

  • Seller

  • Buyer

User

referenceTag

obj

Required for Rewrite mode.

Emulate

Used in Rewrite mode.

relatedRagIds

array

No

The associated retrieval-augmented generation (RAG) knowledge base.

[1]

agentId

String

No

The agent ID.

123

streamApi

Boolean

No

Indicates whether to use streaming output.

true

ReferenceTag:

Parameter name

Type

Required

Description

Example

referenceTitle

String

Required for the RED_BOOK template.

The rewrite title.

xxx

referenceContent

String

Required for Xiaohongshu templates

A Moments template is required.

The rewrite content.

xxx

Response parameters: TextTaskResult

Parameter name

Type

Description

Example

textTask

obj

The text task object.

TextTask

TextTask:

Parameter

Type

Description

Example

textTaskId

Long

The task ID.

123

gmtCreate

String

The creation time.

gmtModified

String

The update time.

textTaskStatus

String

The copywriting task status.

SUCCESS

style

String

The copywriting style.

RED_BOOK

theme

String

Subject Name

TOUR_ROUTE

themeDesc

String

The copywriting theme description.

Tour route

contentRequirement

String

The content requirements.

Three-day tour guide for Jiuzhaigou

introduction

String

The product introduction.

xxx

point

String

The product selling points.

xxx

target

String

The copywriting perspective.

User

referenceTag

obj

The rewrite reference.

ReferenceTag

nums

Integer

The number to generate.

1

relatedRagIds

array

The associated knowledge base.

[1]

textModeType

String

The generation mode.

Generate

textIds

array

A list of copy IDs.

[123,456]

agentName

String

The agent name.

agentId

String

The agent ID.

ReferenceTag:

Parameter

Type

Description

Example

referenceTitle

String

The rewrite title.

referenceContent

String

The rewrite content.

Generate mode - WeChat Moments call template

{
    "number": 2,
    "textModeType": "Generate",
    "style": "WECHAT_MOMENT",
    "industry": "CulturalTour", 
    "introduction": "Jiuzhaigou has beautiful mountains and clear waters, and a beautiful environment." ,
    "themes": [
      "TOUR_ROUTE",
      "ATTRACTION_TICKET"
    ]
}

Generate mode - RED_BOOK call template

{
    "number": 2,
    "textModeType": "Generate",
    "style": "RED_BOOK",
    "industry": "CulturalTour",
    "contentRequirement": "4-day tour of Xiamen",
    "introduction": "Route arrangement Day 1: Zhongshan Road➡️Cat Street➡️Shapowei➡️Huangcuo Beach (sunrise)➡️Zengcuo'an Day 2: Xiamen Botanical Garden➡️Xiamen University (reservation required)➡️South Putuo Temple➡️Zhonggu Cableway➡️Yanwu Bridge (watch the sunset) Day 3: Gulangyu Island➡️8th Market Day 4: Sea subway➡️Haiti Road➡️Jimei School Village➡️Xiamen North",
    "point": "Attraction tour route",
    "target": "Seller",
    "themes": [
      "TOUR_ROUTE"
    ]
}

GetTextTask

API description: Retrieves a copywriting task.

Request parameters:

Parameter name

Type

Required

Description

textTaskId

Long

Yes

The ID of the copywriting task.

Response parameters: TextTaskResult

Parameter name

Type

Description

Example

textTask

obj

The copywriting task object.

TextTask

TextTask:

Parameter

Type

Description

Example

textTaskId

Long

The task ID.

123

gmtCreate

String

The creation time.

gmtModified

String

The update time.

textTaskStatus

String

The copywriting task status.

SUCCESS

style

String

The copywriting style.

RED_BOOK

theme

String

The content theme name.

TOUR_ROUTE

themeDesc

String

The copywriting theme description.

Tour route

contentRequirement

String

The content requirements.

Three-day tour guide for Jiuzhaigou

introduction

String

The product introduction.

xxx

point

String

The product selling points.

xxx

target

String

The copywriting perspective.

User

referenceTag

obj

The rewrite reference.

ReferenceTag

nums

Integer

The number to generate.

1

relatedRagIds

array

The associated knowledge base.

[1]

textModeType

String

The generation mode.

Generate

textIds

array

A list of copy IDs.

[123,456]

texts

obj

The copywriting information object.

For data results, see the Text object of the GetText API.

agentName

String

The agent name.

agentId

String

The agent ID.

GetText

Description: The text to be displayed.

Request parameters:

Parameter

Type

Required

Description

textId

Long

Yes

The copy ID.

Response parameters: TextResult

Parameter name

Type

Description

Example

text

obj

The copy object.

Text

requstId

String

The API request ID.

xxx

Text:

Parameter

Type

Description

Example

textId

Long

The copy ID.

123

gmtCreate

String

The creation time.

gmtModified

String

The update time.

textStatus

String

Copywriting Status

SUCCESS

Text Task ID

Long

The ID of the copywriting task associated with the copy.

123

userNameCreate

String

The name of the user who created the copy.

userNameModified

String

Change your username

title

String

The copy title.

desc

String

The description.

textContent

String

The copywriting content.

textModeType

String

The copy generation type.

Generate

textIllustrationTag

Boolean

Indicates whether the copy is used for an illustration task.

true

illustrationTaskIdList

array

A list of illustration task IDs.

[123,456]

textStyleType

String

The copywriting style.

WECHAT_MOMENT

publishStatus

String

The publish status.

PUBLISH

textThemes

array

A list of copywriting themes.

["xxx", "xxxx"]

agentName

String

The agent name.

agentId

String

The agent ID.

errMsg

String

The error message.

The input information, such as content requirements, is insufficient to generate marketing copy. Please enter the information again.

ListTexts

API description: Lists copies.

Request parameters:

Parameter

Type

Required

Description

industry

String

No

The industry information.

textStyleType

String

No

The copywriting style.

textTheme

String

No

The copywriting theme.

publishStatus

String

No

The publish status.

  • PUBLISH

  • DRAFT

generationSource

String

No

The generation source.

  • PLATFORM

  • API

keyword

String

No

A keyword used to search for generated copies.

pageSize

Integer

Yes

The number of entries per page.

  • Value range: [0, 50].

pageNumber

Integer

Yes

The page number. The value starts from 1.

Response parameters:

Parameter

Type

Description

Example

requestId

String

The API request ID.

xxx

total

Integer

The total number of entries.

10

texts

array

A list of copies.

Text

ListTextThemes

API description: Queries a list of copywriting themes.

Request parameters:

Parameter

Type

Required

Description

industry

String

Yes

The industry information.

Response parameters: TextThemeListResult

Parameter

Type

Description

Example

textThemeList

array

The theme type.

TextTheme

requestId

String

API request ID

xxx

TextTheme:

Parameter Name

Type

Description

Example

name

String

The name.

TOUR_ROUTE

desc

String

The description.

Tour route

GetTextTemplate

API description: Queries a text template.

Request parameters:

Parameter

Type

Required

Description

Example

industry

String

Yes

The industry type.

Car

Response parameters: TextTemplateOpenResult

Parameter name

Type

Description

Example

requestId

String

API request

xxx

availableIndustry

obj

The available industry.

AvailableIndustryOpen:

Parameter

Type

Description

Example

name

String

The industry value.

Common

textModeTypes

List

The text enumeration type.

AvailableTextModeTypeOpen:

Parameter

Type

Description

Example

name

String

The copy generation type.

  • Generate

  • Rewrite

Generate

textStyles

List

The text style.

AvailableTextStyleOpen:

Parameter name

Type

Description

Example

name

String

The copywriting style name.

RED_BOOK

desc

String

The copywriting style description.

Xiaohongshu

{
        "requestId": "0987EED3-752A-150A-B78B-ABCDD4890507",
        "availableIndustry": {
            "textModeTypes": [
                {
                    "name": "Generate",
                    "textStyles": [
                        {
                            "name": "RED_BOOK",
                            "disabled": false,
                            "desc": "RED_BOOK"
                        },
                        {
                            "name": "WECHAT_MOMENT",
                            "disabled": false,
                            "desc": "WeChat Moments"
                        }
                    ]
                },
                {
                    "name": "Rewrite",
                    "textStyles": [
                        {
                            "name": "RED_BOOK",
                            "disabled": false,
                            "desc": "RED_BOOK"
                        },
                        {
                            "name": "WECHAT_MOMENT",
                            "disabled": false,
                            "desc": "WeChat Moments"
                        }
                    ]
                }
            ],
            "name": "Common"
        }
    }

AddTextFeedback

API description: Adds copywriting feedback.

Request parameters:

Parameter name

Type

Required

Description

Example

textId

Long

Yes

The copy ID.

123

content

String

No

The updated copywriting content.

123

quality

Integer

No

The feedback type.

1: Like.

0: Dislike.

1

Response parameters

Parameter name

Type

Description

Example

requestId

String

API Request

xxx

success

Boolean

The request result.

true

CountText

API description: Counts the number of copies.

Request parameters:

Parameter name

Type

Required

Description

Example

style

String

No

The copywriting style.

  • Xiaohongshu (RED_BOOK)

  • WECHAT_MOMENT: WeChat Moments

RED_BOOK

publishStatus

String

No

The publish status.

  • PUBLISH

  • DRAFT

DRAFT

generationSource

String

No

The generation source.

  • PLATFORM

  • API

API

industry

String

No

The industry.

Car

Response parameters

Parameter Name

Type

Description

Example

count

Long

The count.

11

theme

String

The theme name.

ATTRACTION_TICKET

ListAgents

API description: Queries the agent list.

Request parameters:

Parameter name

Type

Required

Description

status

Integer

No

The agent status.

0: Published, 1: Building, 2: To be published, 3: Build failed.

agentScene

String

Required if agentId is not specified.

The agent scenario.

text: Marketing copywriting, aiCoachPractice: Practice agent, digitalHuman: Digital human intelligent conversation.

owner

String

No

Agent owner:

SYSTEM: System, CUSTOMER: Customer (default).

agentId

String

No

The agent ID. This is for an exact query and makes other request parameters invalid.

pageNumber

Integer

Yes

The page number. Default is 1.

pageSize

Integer

Yes

The number of entries per page. Default is 10.

Response parameters:

Parameter

Type

Description

Example

list

Array

A list of agent information.

AgentResult

success

Boolean

Indicates whether the request was successful.

true

total

Integer

The total count.

100

requestId

String

The API request ID.

xxx

AgentResult description

Parameter name

Type

Description

Example

agentId

String

The agent ID.

111111

agentScene

String

The agent scenario.

text: Marketing copywriting, aiCoachPractice: Practice agent, digitalHuman: Digital human intelligent conversation.

text

agentName

String

The agent name.

Test agent

industry

String

The industry information. For more information, see the Appendix.

Car

textStyle

String

The copywriting style. For more information, see the Appendix.

RED_BOOK

enableInteraction

Integer

The interactive copy status: 1: Content text, 2: Interactive text, 3: Content and interactive.

1

viewer

String

The perspective: Seller: Seller, User: User.

User

onlineSearch

Boolean

The web search status. true: Enabled, false: Disabled.

true

status

Integer

The agent status.

0: Published, 1: Building, 2: To be published, 3: Build failed.

1

charactersDescription

String

The detailed description.

Test agent description

owner

String

The agent owner: Customer or System.

SYSTEM

referenceUrl

String

The link to the reference sample text.

Illustration API details

image

TransferPortraitStyle

API description: Transfers a portrait style.

Request parameters

Parameter Name

Type

Required

Description

Example

width

Integer

Yes

The image width. Maximum value: 2048.

11

height

Integer

Yes

The image height. Maximum value: 2048.

22

imageUrl

String

Yes

The address of the portrait image.

http

style

Integer

Yes

The style. 0: Cartoon, 1: Chinese style, 2: Watercolor.

1

numbers

Integer

Yes

The number of images to generate. Maximum value: 4.

4

redrawAmplitude

Integer

Yes

The redraw amplitude. Range: 0 to 50.

10

Response parameters

Parameter name

Type

Description

Example

taskId

String

The task ID.

11111

CreateRealisticPortrait

API description: Creates a realistic portrait.

Request parameters

Parameter name

Type

Required

Description

Example

ratio

String

Do not specify this parameter for realistic portrait generation from an image.

Required for realistic portrait creation from tags.

Aspect ratio: 1:1, 3:2, 2:3, 4:3, 3:4, 16:9, or 9:16

auto (free ratio).

auto

width

Integer

Yes

The image width. Maximum value: 2048.

11

height

Integer

Yes

The image height. Maximum value: 2048.

22

numbers

Integer

Yes

The number of images to generate. Maximum value: 4.

1

imageUrl

String

Required for realistic portrait generation from an image.

Do not specify this parameter for realistic portrait creation from tags.

The address of the reference image.

http

gender

Integer

Yes

The gender. 0: Male, 1: Female.

1

ages

List<Integer>

Yes

The age range. Minimum: 1, Maximum: 100. The age span cannot exceed 10.

[1,10]

figure

Integer

Yes

The body shape. 0: Slim, 1: Medium, 2: Heavy.

1

hairColor

Integer

Optional for realistic portrait creation from tags.

The hair color. 0: Black, 1: Brown, 2: Gold, 3: Red, 4: Pink, 5: Chestnut, 6: Gray, 7: White.

0

hairstyle

Integer

Optional for realistic portrait creation from tags.

The hairstyle. 1: Long hair, 2: Short hair.

2

color

Integer

No

The skin tone. 0: Yellow, 1: White, 2: Black.

2

face

List<Integer>

Optional for realistic portrait creation from tags.

The facial features. 0: Wearing glasses, 1: Smiling.

[0,1]

cloth

Integer

Optional for realistic portrait creation from tags.

The clothing. 1: Suit, 2: Dress, 3: Shirt, 4: Lab coat.

4

custom

String

No

Special requirements. Up to 100 characters are supported.

Bald

Response parameters

Parameter

Type

Description

Example

taskId

String

The task ID.

11111

SelectImageTask

API description: Queries the details of an image task.

Request parameters

Parameter name

Type

Required

Description

Example

taskId

String

Yes

The task ID.

11111

Response parameters

Parameter name

Type

Description

Example

gmtCreate

Stiring

The submission time in yyyy.MM.dd HH:mm:ss format.

scene

String

The task scenario.

RealisticPortraitWithImage: Realistic portrait creation from an image, RealisticPortraitWithTag: Realistic portrait creation from tags, TransferPortraitStyle: Portrait style transfer.

Character Style Variations

status

String

The task status.

Uncommit: Uncommitted, InProgress: In progress, Failed: Failed, Successed: Succeeded.

Uncommit

total

Integer

The total count.

3

failed

Integer

The number of failures.

1

success

Integer

The number of successes.

1

subtaskProcessing

Integer

The number of subtasks in progress.

1

errorMessage

String

The reason for the failure.

Abnormal

generationSource

String

Source: API, Platform

API

imageInfos

List<Object>

The image information.

Image information

Parameter name

Type

Description

Example

gmtCreate

Stiring

The generation time in yyyy.MM.dd HH:mm:ss format.

customImageUrl

String

The image link.

http

imageW

Integer

The image width.

111

imageH

Integer

The image height.

222

GetOssUploadToken

API description: Retrieves an OSS upload signature.

Request parameters: GetOssUploadRequest

Parameter

Type

Required

Description

Example

fileName

String

Yes

The file name.

xxx.png

fileType

String

Yes

File Type: ProductImage

ProductImage

Response parameters: UploadInfo

Parameter

Type

Description

Example

host

String

The OSS host for the upload.

yic-pre.oss-cn-hangzhou.aliyuncs.com

key

String

The allowed upload key.

1234/temp-novels/xxxx-xxx-xx.txt

policy

String

The upload policy (Base64 encoded).

xxxxxxxx

policySignature

String

The result of the upload policy signature.

xxxxxxxx

accessId

String

The AccessKey ID used for the upload.

xxxxxx

url

String

The file URL.

http://oss.xxxxx

CreateIllustrationTask

API description: Creates an illustration task.

Request parameters:

Parameter name

Type

Required

Description

textId

Long

Yes

The file name.

body

obj

Yes

IllustrationTaskCreateCmd

IllustrationTaskCreateCmd:

Parameter name

Type

Required

Description

ossPaths

array

No. Specify either this parameter or imageUrls.

OSS keys (file paths): ["1235/xxx.text", "1235/xxxx2113.text"]

imageUrls

array

No. Specify either this parameter or ossPaths.

The HTTP image address.

["http://image.com"]

nums

Integer

Yes

Generation Count

stickerText

String

Yes

The sticker text in JSON format. Example: {"title":"Title","subTitle":"Subtitle","point":"Highlights, separated by \n"}.

backgroundType

Integer

Yes

0: Do not change the background. 1: Change the background.

dstWidth

Integer

Yes

The width of the generated image. Range: [1, 1920].

dstHeight

Integer

Yes

The height of the generated image. Range: [1, 1920].

Response parameters: IllustrationTaskResult

Parameter

Type

Description

Example

illustrationTask

obj

The illustration task.

IllustrationTask

IllustrationTask:

Parameter name

Type

Description

Example

illustrationTaskId

Long

The illustration task ID.

123

gmtCreate

Date

The creation time.

gmtModified

Date

The update time.

textId

Long

The associated copy ID.

taskStatus

String

The task status.

Success

illustrationIds

array

The illustration ID information.

[123,456]

GetIllustrationTask

API description: Queries an illustration task.

Request parameters:

Parameter Name

Type

Required

Description

Example

textId

Long

Yes

The copy ID.

123

illustrationTaskId

Long

Yes

The illustration task ID.

123

Response parameters: IllustrationTaskResult

Parameter

Type

Description

Example

illustrationTask

obj

The illustration task.

IllustrationTask

requestId

String

API request ID

xxx

GetIllustration

API description: Queries an illustration.

Request parameters:

Parameter name

Type

Required

Description

Example

textId

Long

Yes

The copy ID.

123

illustrationId

Long

Yes

The illustration task ID.

123

Response parameters: IllustrationResult

Parameter

Type

Description

Example

requestId

String

API requests

xxx

illustration

obj

The illustration information.

Illustration

Illustration:

Parameter name

Type

Description

Example

illustrationId

Long

The illustration ID.

123

oss

String

The signed OSS address.

http://ossxxxxxx

Personalized copywriting API details

1. Create a project

API: CreateIndividuationProject

1.1. Request parameters

Parameter

Type

Required

Description

Example

projectName

String

Yes

The project name. The name must be unique.

Test project

purpose

String

Yes

The project purpose.

Invitation for users with birthdays in October

projectInfo

String

Yes

The project information in JSON format (knowledge data).

[]

sceneId

String

Yes

The scenario ID.

1001

1.2. Response parameters

Parameter

Type

Description

Example

projectId

String

The project ID.

11

2. Delete a project

API: DeleteIndividuationProject

2.1. Request parameters

Parameter name

Type

Required

Description

Example

projectId

String

Yes

The project ID.

11

2.2. Response parameters

Parameter name

Type

Description

Example

status

String

The deletion result. SUCCESS: Success, FAIL: Failed.

SUCCESS

desc

String

The result description. This provides the reason for the deletion failure.

Cannot be deleted while a task is in progress.

3. Create a copywriting task

API: CreateIndividuationTextTask

3.1. Request parameters

A maximum of five tasks can be in progress at the same time.

Parameter

Type

Required

Description

Example

projectId

String

Yes

The project ID.

11

taskName

String

Yes

The task name. The name must be unique.

Test crowd package-1

crowdPack

Array

Yes

The crowd information in JSON format. A maximum of 2,000 crowd profiles are supported.

See the crowd information example.

3.1.1. Crowd information example

[
    [
        "user_id",
        "username",
        "gender",
        "city",
        "birthday",
        "height",
        "age",
        "consumer_behavior",
        "purchase_time"
    ],
    [
        "123456",
        "Wang**",
        "Male",
        "Hangzhou",
        "1989/10",
        "180",
        "30",
        "Prefers apparel category",
        "2024/12/20"
    ]
]

3.2. Response parameters

Parameter

Type

Description

Example

taskId

String

The task ID.

11

4. Query a copywriting task

API: QueryIndividuationTextTask

4.1. Request parameters

Parameter

Type

Required

Description

Example

taskId

String

Yes

The task ID.

11

4.2. Response parameters

Parameter

Type

Description

Example

createTime

String

The creation time (yyyy-MM-dd HH:mm:ss).

updateTime

String

The update time (yyyy-MM-dd HH:mm:ss).

status

Integer

The task status.

0: In progress, 1: Completed.

0

textList

Array

The copy information. This is returned only for completed tasks.

Text

Parameter name

Type

Description

Example

textId

String

The copy ID.

11

userId

String

The user ID corresponding to the user tag.

11

status

Integer

The copy status: 0: Generating, 1: Success, 2: Failed.

0

5. Batch query copywriting content

API: BatchQueryIndividuationText

5.1. Request parameters

Parameter

Type

Required

Description

Example

textIdList

Array

Yes

A collection of copy IDs. A maximum of 50 IDs are supported.

["11","22"]

5.2. Response parameters

Parameter name

Type

Description

Example

textList

Array

A list of copies.

Text object

Parameter Name

Type

Description

Example

content

String

The copywriting content.

Test copy

userId

String

The user ID.

itemId

String

The item ID.

0

taskId

String

The task ID.

projectId

String

The project ID.

createTime

String

The creation time (yyyy-MM-dd HH:mm:ss).

updateTime

String

The update time (yyyy-MM-dd HH:mm:ss).

status

Integer

The copy status: 0: Generating, 1: Success, 2: Failed.

0

errorMsg

String

The error message.

Account information mismatch.

6. Delete a copy

API: DeleteIndividuationText

6.1. Request parameters

Parameter Name

Type

Required

Description

Example

textIdList

Array

Yes

A collection of copy IDs.

6.2. Response parameters

Parameter name

Type

Description

Example

status

String

The deletion result. SUCCESS: Success, FAIL: Failed.

SUCCESS

desc

String

The result description. This provides the reason for the deletion failure.

Cannot be deleted while a task is in progress.

Appendix

Industry information enumeration

Car: Car industry
Common: Common industry
CulturalTour: Cultural and tourism industry
Garment: Sports and outdoor industry
Internet: Internet tools industry
RED_BOOK: RED_BOOK
WECHAT_MOMENT: WeChat Moments
TIKTOK: TikTok
ZHIHU: Zhihu
QIWEI_TEXT: WeCom script

SDK downloads and updates

PHP

Integration reference

require 'vendor/autoload.php';
use AlibabaCloud\SDK\Imarketing\V20220704\Models\GetOssUploadSignatureRequest;
use AlibabaCloud\SDK\IntelligentCreation\V20240313\IntelligentCreation;
use Darabonba\OpenApi\Models\Config as AlibabaConfig;

$config = new AlibabaConfig();
$config->accessKeyId = '****';
$config->accessKeySecret = '****';
$config->endpoint = "intelligentcreation.cn-zhangjiakou.aliyuncs.com";

$intelligentCreationClient = new IntelligentCreation($config);

// GetOssUploadToken API example
$request = new GetOssUploadSignatureRequest();
$request->fileName = 'xxx.png';
$request->fileType = "ProductImage";
try {
    $response = $intelligentCreationClient->getOssUploadToken($request);
    var_dump($response->toMap());
} catch (TeaError $e) {
    Log::error($e);
}

2.12.0

composer require alibabacloud/intelligentcreation-20240313 2.12.0

Java

Integration reference

package com.aliyun;

import com.aliyun.intelligentcreation20240313.Client;
import com.aliyun.intelligentcreation20240313.models.GetOssUploadTokenRequest;
import com.aliyun.intelligentcreation20240313.models.GetOssUploadTokenResponse;
import com.aliyun.intelligentcreation20240313.models.UploadInfo;
import com.aliyun.teaopenapi.models.Config;

import java.util.HashMap;
import java.util.Map;

public class Test {

    public static void main(String[] args) throws Exception {
  // Initialize the configuration.
        Config config = new Config().setAccessKeyId("test").setAccessKeySecret("test").setEndpoint("intelligentcreation.cn-zhangjiakou.aliyuncs.com");
// Create a client.
        Client client = new Client(config);

        Map<String, Object> map = new HashMap<>();
        map.put("fileName","xxx.png");
        map.put("fileType","ProductImage");
        GetOssUploadTokenRequest request = GetOssUploadTokenRequest.build(map);
// Call the API.
        GetOssUploadTokenResponse response = client.getOssUploadToken(request);
        if (response.getStatusCode().equals(200)) {
            System.out.println("Request successful");
            UploadInfo uploadInfo = response.getBody().getUploadInfo();
            System.out.println("Response parameters: " + uploadInfo);
        }

    }
}

2.12.0

<dependency>
  <groupId>com.aliyun</groupId>
  <artifactId>intelligentcreation20240313</artifactId>
  <version>2.12.0</version>
</dependency>

Asynchronous Java

Integration reference

public static void main(String[] args) {
        StaticCredentialProvider provider = StaticCredentialProvider.create(
                Credential.builder()
                        .accessKeyId(ak)
                        .accessKeySecret(sk)
                        .build()
        );

        AsyncClient client = AsyncClient.builder()
                .region("cn-zhangjiakou")
                .credentialsProvider(provider)
                .serviceConfiguration(Configuration.create()
                        .setSignatureVersion(SignatureVersion.V3)
                )
                .overrideConfiguration(
                        ClientOverrideConfiguration.create()
                                .setProtocol("HTTPS")
                                .setEndpointOverride(url)
                )
                .build();

        QueryTextStreamRequest request = QueryTextStreamRequest.builder().textId(329L).build();
        ResponseIterable<QueryTextStreamResponseBody> responseBodies = client.queryTextStreamWithResponseIterable(request);
        for (QueryTextStreamResponseBody responseBody : responseBodies) {
             if (responseBody.getType().equals(0)) {
                 // No output is required for heartbeat detection.
                continue;
            }
            if (responseBody.getType().equals(3)) {
                 // Abnormal information. Trigger an alert.
                break;
            }
            System.out.print(responseBody.getMessage());

            if (responseBody.getEnd()) {
                System.out.println("\n\nRequest ended: " + responseBody.getType() + "  -- " + responseBody.getIndex());
            }
        }
        System.out.println(responseBodies.getHeaders());

    }

2.0.7

<dependency>
  <groupId>com.aliyun</groupId>
  <artifactId>alibabacloud-intelligentcreation20240313</artifactId>
  <version>2.0.7</version>
</dependency>

Go

Integration reference

package main

import (
	"fmt"

	openapi "github.com/alibabacloud-go/darabonba-openapi/v2/client"
	intelligentcreation20240313 "github.com/alibabacloud-go/intelligentcreation-20240313/v2"
	util "github.com/alibabacloud-go/tea-utils/v2/service"
	"github.com/alibabacloud-go/tea/tea"
	
)

func CreateClient() (_result *intelligentcreation20240313.Client, _err error) {
	config := &openapi.Config{
		 // Required. Make sure the ALIBABA_CLOUD_ACCESS_KEY_ID environment variable is set.
		 AccessKeyId: tea.String(os.Getenv("ALIBABA_CLOUD_ACCESS_KEY_ID")),
		 // Required. Make sure the ALIBABA_CLOUD_ACCESS_KEY_SECRET environment variable is set.
		 AccessKeySecret: tea.String(os.Getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET")),
	}
	config.Endpoint = tea.String("intelligentcreation.cn-zhangjiakou.aliyuncs.com")
	_result = &intelligentcreation20240313.Client{}
	_result, _err = intelligentcreation20240313.NewClient(config)
	return _result, _err
}

func main() {
	client, _err := CreateClient()
	if _err != nil {
		panic(_err)
	}
	queryIndividuationTextTaskRequest := &intelligentcreation20240313.QueryIndividuationTextTaskRequest{
	// The ID of the copywriting task.
		 TaskId: tea.String("1111"),
	}
	resp, tryErr := func() (response *intelligentcreation20240313.QueryIndividuationTextTaskResponse, _e error) {
		defer func() {
			if r := tea.Recover(recover()); r != nil {
				_e = r
			}
		}()
		// If you copy the code to run, print the API's return value.
		response, _err = client.QueryIndividuationTextTask(queryIndividuationTextTaskRequest)
		if _err != nil {
			return response, _err
		}
		return response, nil
	}()

	if tryErr != nil {
		if sdkError, ok := tryErr.(*tea.SDKError); ok {
			// This is for printing and demonstration purposes only. Handle exceptions with care and do not ignore them in your projects.
			fmt.Println(tea.StringValue(sdkError.Message))
			fmt.Println(tea.StringValue(sdkError.Code))
			fmt.Println(tea.StringValue(sdkError.Data))
		} else {
			// This is for printing and demonstration purposes only. Handle exceptions with care and do not ignore them in your projects.
			fmt.Println(tea.String(tryErr.Error()))
		}
	} else {
		fmt.Println("Response:", resp) // Print the response.
	}
}

SDK

go get github.com/alibabacloud-go/intelligentcreation-20240313/v2