Create Images

The create_images endpoint allows you to generate custom-designed images by providing key content elements such as structured texts, free-from texts, logos, and images. This API simplifies the creation of visually appealing images for various use cases, such as marketing materials, announcements, and informational displays.

API Endpoint

To create an image, send a POST request to the following URL:

POST https://api.genaifactory.ai/v1/create_images

Headers

Ensure that your request includes the following header:

Name

Type

Required

Description

formacloud-api-key

string

Yes

API key required for authenticating your request.

Request Body

The request body should be sent as form-data and include the following fields.

Name

Type

Required

Description

structured_content

object (JSON in string format)

No

Structured content for the image, including detailed sections like primary information, secondary information, features, button text, and warnings or hints. This should be passed as a string in JSON format.

freeform_content

string

No

Unstructured text content for the image. If provided, this will be used along with structured_content. Both will be utilized; however, in case of any conflict, Primary Text will take precedence.

logo_image

file

No

The logo image file to be included on the image. This allows you to upload a file for branding the image with a company logo. While there are no specific size or dimension validations during upload, the logo image size will be restricted during usage. In the final rendered image, the logo image's size will not exceed 1/9 of the total image dimensions.

logo_url

string

No

The URL of a logo image to include in the image. Only either logo_image or logo_url should be provided.

main_images

file[]

No

One or more main image files that you want to include in the image. Multiple files can be uploaded, with a maximum limit of three main images. If both main_images and main_image_urls are provided, the uploaded main_images will take priority.

There are no specific size or dimension validations during upload. However, when used in the final rendered image, the size of each main_image will be adjusted to fit within the final output.

main_image_urls

array of strings (JSON in string format)

No

A list of URLs for the main images that should be included in the image. This can be used when image files are not uploaded directly. A maximum of three main images can be included.

There are no specific size or dimension validations for the images provided via URLs. However, when used in the final rendered image, the size of each main image will be adjusted to fit within the final output.

background_image

file

No

A background image file to be used for the image. Only either background_image or background_image_url should be provided.

background_image_url

string

No

The URL of a background image to include in the image. This will be used if no background_image is uploaded.

style

string

No

The style of the image. The options include: "REALISTIC",""CARTOON,"ANIME","OIL_PAINTING","WATERCOLOR","PENCIL_SKETCH","INK_WASH","CHARCOAL","UKIYO_E","POP_ART","PIXEL_ART","VINTAGE","THREE_D_RENDER","CLAY","SURREALISM","SCI_FI","RANDOM".

image_count

int

No

The number of images to generate. Default is 1.

export_svg

boolean

No

If set to true, the image will be exported as an SVG format. Default is false.

resolution

string

No

Specifies the resolution of the image. Cannot be used together with width and height. Acceptable values are: RESOLUTION_512_1536, RESOLUTION_576_1408, RESOLUTION_576_1472, RESOLUTION_576_1536, RESOLUTION_640_1024, RESOLUTION_640_1344, RESOLUTION_640_1408, RESOLUTION_640_1472, RESOLUTION_640_1536, RESOLUTION_704_1152, RESOLUTION_704_1216, RESOLUTION_704_1280, RESOLUTION_704_1344, RESOLUTION_704_1408, RESOLUTION_704_1472, RESOLUTION_720_1280, RESOLUTION_736_1312, RESOLUTION_768_1024, RESOLUTION_768_1088, RESOLUTION_768_1152, RESOLUTION_768_1216, RESOLUTION_768_1232, RESOLUTION_768_1280, RESOLUTION_768_1344, RESOLUTION_832_960, RESOLUTION_832_1024, RESOLUTION_832_1088, RESOLUTION_832_1152, RESOLUTION_832_1216, RESOLUTION_832_1248, RESOLUTION_864_1152, RESOLUTION_896_960, RESOLUTION_896_1024, RESOLUTION_896_1088, RESOLUTION_896_1120, RESOLUTION_896_1152, RESOLUTION_960_832, RESOLUTION_960_896, RESOLUTION_960_1024, RESOLUTION_960_1088, RESOLUTION_1024_640, RESOLUTION_1024_768, RESOLUTION_1024_832, RESOLUTION_1024_896, RESOLUTION_1024_960, RESOLUTION_1024_1024, RESOLUTION_1088_768, RESOLUTION_1088_832, RESOLUTION_1088_896, RESOLUTION_1088_960, RESOLUTION_1120_896, RESOLUTION_1152_704, RESOLUTION_1152_768, RESOLUTION_1152_832, RESOLUTION_1152_864, RESOLUTION_1152_896, RESOLUTION_1216_704, RESOLUTION_1216_768, RESOLUTION_1216_832, RESOLUTION_1232_768, RESOLUTION_1248_832, RESOLUTION_1280_704, RESOLUTION_1280_720, RESOLUTION_1280_768, RESOLUTION_1280_800, RESOLUTION_1312_736, RESOLUTION_1344_640, RESOLUTION_1344_704, RESOLUTION_1344_768, RESOLUTION_1408_576, RESOLUTION_1408_640, RESOLUTION_1408_704, RESOLUTION_1472_576, RESOLUTION_1472_640, RESOLUTION_1472_704, RESOLUTION_1536_512, RESOLUTION_1536_576, RESOLUTION_1536_640, and RESOLUTION_1248_702. If not provided, defaults to RESOLUTION_1248_702.

width

int

No

Specifies the width of the image in pixels. Must be between 192 and 2000 if provided. Cannot be used together with resolution.

height

int

No

Specifies the height of the image in pixels. Must be between 192 and 2000 if provided. Cannot be used together with resolution.

create_image_without_text

boolean

No

When set to true, this parameter instructs the system to generate an image without any text. In this mode, freeform_content must still be provided, even though it won't appear on the image. structured_content and any other text-related parameters are optional and will be ignored if provided. However, other non-text-related parameters (like style, and resolution) will still be applied to influence the visual style and layout of the image.

Structured Content Object

There are no strict character limits for any of the fields listed below. However, it is recommended to keep the total character count within 300 characters for optimal clarity and readability.

Name

Type

Required

Description

primary_text

string

Yes

The main headline or key information for the image.

secondary_text

string

No

Additional details or supporting information related to the primary info.

features

array of strings

No

A list of features or key points to be highlighted on the image. There is no strict limit on the number of features; however, it is recommended to include three or fewer for optimal clarity and impact.

action_button

string

No

The text for the call-to-action button on the image.

corner_hints

array of strings

No

A list of small hints or warning messages to be displayed on the corners of the image.There is no strict limit on the number of corner_hints; however, it is recommended to include two or fewer for optimal clarity and impact.

Response Body

Asynchronous Response (Status Code 202)

Name

Type

Required

Description

task_id

string

Yes

The ID of the task that was created. You can use this ID to retrieve the image generation results at a later time.

tasks_ahead_count

int

Yes

The number of tasks ahead of it will be returned from the time a task is created until it is executed

estimate_image_time

int

Yes

The estimated time in seconds for the task to be executed based on recent task performance data.

Failure Response (Status Code 4XX or 5XX)

Name

Type

Required

Description

error

string

Yes

A descriptive error message indicating what went wrong with the request.

Example Structured_content Request

curl --location 'https://api.genaifactory.ai/v1/create_images' \
--header 'formacloud-api-key: [put the key here]' \
--form 'structured_content="{
        \"primary_text\": \"最高可贷(元)200,000.00\",
        \"secondary_text\": \"综合年化利率(单利)6.5%起\",
        \"features\": [\"无抵押\", \"一键申请\", \"三步到账\"],
        \"action_button\": \"查看我的额度\",
        \"corner_hints\": [\"贷款有风险,借款需谨慎,请根据个人能力合理贷款,理性消费,避免逾期\"]
    }"' \
--form 'logo_image=@"/Users/shuxuan/Pictures/hkdailynews.png"' \
--form 'main_images=@"/Users/shuxuan/Pictures/app.png"' \
--form 'layout="Side-by-side"' \
--form 'image_count="2"' \
--form 'user_font_preferences="我希望使用一些风格大胆的字体"' \

Example Freeform_content Request

curl --location 'https://api.genaifactory.ai/v1/create_images' \
--header 'formacloud-api-key:  [put the key here]' \
--form 'freeform_content="轻松借贷,畅享未来, 最高可借200,000元,日息费低至1毛8, 快速审批,3分钟放款,急需资金不再难, 息费透明,随借随还,灵活管理您的资金需求, 10秒加密注册,数据安全无忧,隐私保护全面到位, 立即申请,开启您的财务自由之旅!"' \
--form 'logo_image=@"/Users/shuxuan/Pictures/hkdailynews.png"' \
--form 'main_images=@"/Users/shuxuan/Pictures/app.png"' \
--form 'image_count="1"'

Example Create background image Request

curl --location 'https://api.genaifactory.ai/v1/create_images' \
--header 'formacloud-api-key:  [put the key here]' \
--form 'freeform_content="轻松借贷,畅享未来, 最高可借200,000元,日息费低至1毛8, 快速审批,3分钟放款,急需资金不再难, 息费透明,随借随还,灵活管理您的资金需求, 10秒加密注册,数据安全无忧,隐私保护全面到位, 立即申请,开启您的财务自由之旅!"' \
--form 'logo_image=@"/Users/shuxuan/Pictures/hkdailynews.png"' \
--form 'main_images=@"/Users/shuxuan/Pictures/app.png"' \
--form 'bg_image_req="一朵金黄色的小花"' \
--form 'image_count="1"'

Example Asynchronous Response

{
    "task_id": "task_1234567890abcdef",
    "tasks_ahead_count": 3
}

Example Failure Response

{
  "error": "Invalid input data"
}

Last updated