All pages
Powered by GitBook
1 of 12

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Moonveil Image Creation API

Moonveil redefines text-to-image generation with its proprietary model, offering unparalleled 100% text accuracy in outputs. Our platform caters to all users: casual creators can export PNGs, while professionals enjoy SVG options for easy editing. With a powerful API for enterprise integration and AI-driven free-form input alongside customizable parameters, Moonveil combines precision with user-friendliness. Whether you're a hobbyist or a business professional, Moonveil is your go-to solution for turning text into stunning, accurate visuals.

2024-01-08

  • Added the task_types parameter to retrieve image history API.

2024-12-31

  • Added the time related fields info to get image generation API.

  • Fixed error header in image to prompt doc.

  • v1/image_history

2024-12-20

  • Added the Redraw Image API to allow redrawing original image.

2024-12-16

  • Added the Export Image as SVG API to allow exporting a task's output image as an SVG.

2024-12-11

  • Added the estimate_image_time parameter to the response schema. This parameter provides an estimated execution time (in seconds) for the task based on recent task performance data.

  • Added a note to the "Image to Prompt" API documentation indicating that this API typically requires approximately 15 seconds to return a response.

2024-12-02

  • Added width and height parameters for Create Images API.

2024-11-22

  • Added Retrieve Recharge History API.

2024-11-18

  • Supported 16 image sytles. https://moonveil.ai/app/styles

  • Enabled the "Create Image without Text" feature in the Create Images API.

Redraw Image

The redraw_image endpoint allows users to modify or recreate a given image using a specified mask and text prompt. This API is ideal for use cases such as creating customized visuals, refining designs, or replacing specific parts of an image while retaining its original structure.

API Endpoint

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

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

Headers

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

user_input

string

No

A brief textual description (max 200 characters) for guiding the image redrawing process.

original_image

file

No

The original image file to be redrawn. Must not be provided with original_image_url.

original_image_url

string

No

URL of the original image to be redrawn. Must not be provided with original_image.

mask_image

file

No

Mask file specifying areas to be redrawn. Must not be provided with mask_image_url.

mask_image_url

string

No

URL of the mask file specifying areas to be redrawn. Must not be provided with mask_image.

Note: Either the file or the url must be provided for both the original image and the mask but not both simultaneously.

Response Body

Asynchronous Response (Status Code 202)

Name
Type
Required
Description

task_id

string

Yes

The ID of the task created for redrawing the image.

tasks_ahead_count

int

Yes

Number of tasks ahead in the queue when this task is created.

estimate_image_time

int

Yes

Estimated time (in seconds) to complete the task based on recent 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 Request

Using curl Command

curl --location 'https://api.genaifactory.ai/v1/redraw_image' \
--header 'formacloud-api-key: abc' \
--form 'user_input="movie poster says \"FORMA CLOUD\""' \
--form 'original_image_url="https://replicate.delivery/pbxt/M0gpKVE9wmEtOQFNDOpwz1uGs0u6nK2NcE85IihwlN0ZEnMF/kill-bill-poster.jpg"' \
--form 'mask_image_url="https://replicate.delivery/pbxt/M0gpLCYdCLbnhcz95Poy66q30XW9VSCN65DoDQ8IzdzlQonw/kill-bill-mask.png"'

Example Response

Asynchronous Response

{
  "task_id": "task_1234567890abcdef",
  "tasks_ahead_count": 2,
  "estimate_image_time": 120
}

Failure Response

{
  "error": "user_input must be less than 200 characters"
}

Expand Prompt

This API expands a given user input into a detailed prompt description suitable for creative tasks such as designing posters, creating advertisements, and more.

API Endpoint

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

Headers

Name
Type
Required
Description

formacloud-api-key

string

Yes

API key for authentication

Content-Type

string

Yes

Set to application/json

Request Body

Name
Type
Required
Description

user_input

string

Yes

The user’s input text that needs to be expanded

Example Request

curl --location 'http://localhost:3300/v1/expand_prompt' \
--header 'formacloud-api-key: abc123' \
--header 'Content-Type: application/json' \
--data '{
    "user_input": "Help me create a poster of shoes"
}'

Response

A JSON object containing the expanded prompt description.

Field
Type
Description

expanded_prompt

string

Detailed prompt text generated by the API

Example Response

{
    "expanded_prompt": "Create a poster that showcases a vibrant collection of shoes displayed in a dynamic arrangement, drawing the viewer's eye across the design. The layout features a central focus on various styles, such as sneakers, sandals, and boots, placed at different angles to create depth and visual interest. \n\nThe poster should feature stunning photography of the shoes, accentuated by texture close-ups and playful backgrounds that highlight their unique designs. \n\nThe color scheme consists of bright, energetic hues like electric blue, neon green, and fiery orange, complemented by contrasting soft pastels for a modern, youthful vibe. \n\nText elements include a bold title at the top, reading \"Step into Style!\" in an eye-catching sans-serif font, followed by catchy taglines beneath each shoe style, conveying their distinct appeal. \n\nSupporting graphics include playful geometric patterns and subtle shoe footprints weaving around the footwear, adding a sense of movement and energy. \n\nThe mood and atmosphere evoke excitement and a sense of adventure, inviting viewers to explore new fashion possibilities. A prominent call to action at the bottom urges, \"Find Your Perfect Pair Today!\" encouraging immediate engagement."
}

Image to Prompt

This API extracts information from a given image and user input to generate a detailed prompt description for creating a poster. Note: This API typically requires approximately 15 seconds to process and return a response.

API Endpoint

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

Headers

Name
Type
Required
Description

formacloud-api-key

string

Yes

API key for authentication

Request Body

Name
Type
Required
Description

user_input

string

No

The user’s input text describing requirements (max 200 characters)

referring_image

file

No

The image file to be used for inspiration

referring_image_url

string

No

URL of the image to be used for inspiration

Note: referring_image and referring_image_url cannot be provided together.

Example Request

curl --location 'https://api.genaifactory.ai/v1/image_to_prompt' \
--header 'formacloud-api-key: abc123' \
--form  'user_input="Help me extract the contents of the entire image"'\
--form  'referring_image_url="https://example.com/inspiration_image.jpg"'

Response

Returns a JSON object containing the generated detailed prompt description.

Field
Type
Description

image_to_prompt

string

Detailed prompt text generated by the API

Example Response

{
  "image_to_prompt": "In this picture, you can see a winding \"river\" made of white rice grains, with a black background forming the outline of the river. In the center of the river, there is a lonely black figure walking on the river, giving people a feeling of walking alone, thinking or reminiscing. At the bottom right of the picture, there are Chinese words: \"The long river of time always has some people worth remembering\", and the English translation: "THERE ARE ALWAYS SOME PEOPLE WORTH REMEMBERING". \n\nThe content of this picture conveys a feeling of time passing, nostalgia and gratitude. The overall color tone is mainly white and black, simple but meaningful. The whole picture indicates that people move forward in the long river of time. Although the years are ruthless, there are always some people who are worth remembering and remembering."
}

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. If create_image_without_text is set to True, the field is mandatory.

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_background

boolean

No

A flag indicating whether to generate a background image. Must be a boolean value (true or false). If set to true, background_image or background_image_url must not be provided, as this will cause a conflict.

create_main_image

boolean

No

A flag indicating whether to generate a main image. Must be a boolean value (true or false). This parameter controls the inclusion of a main image in the design process.

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: id9dqCjvEPNopJLhpu4VvoDAcBtPbTv3wkE2R5va4d0' \
--form 'poster_count="1"' \
--form 'create_background="true"' \
--form 'structured_content="{
            \"features\": [
                \"Make brand-perfect ads instantly\",
                \"Test different ad versions while keeping your brand look\",
                \"Reach global markets with accurate translations\"
            ],
            \"corner_hints\": [\"\"],
            \"primary_text\": \"Marketing and Advertising\",
            \"action_button\": \"\",
            \"secondary_text\": \"Empowered by Moonveil\"
        }"' \
--form 'style="random"' \
--form 'create_main_image="true"' \
--form 'resolution="RESOLUTION_896_1120"'

Example Freeform_content Request

curl --location 'https://api.genaifactory.ai/v1/create_images' \
--header 'formacloud-api-key:  [put the key here]' \
--form 'freeform_content="A watercolor Christmas poster design featuring a robin perched on a branch with holly leaves and berries. The robin is singing. Below the bird, the text "Season\'s Greetings" is written in a cursive script. The background is a warm, golden hue. The overall design has a hand-painted feel."' \
--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="A watercolor Christmas poster design featuring a robin perched on a branch with holly leaves and berries. The robin is singing. Below the bird, the text "Season\'s Greetings" is written in a cursive script. The background is a warm, golden hue. The overall design has a hand-painted feel."' \
--form 'logo_image=@"/Users/shuxuan/Pictures/hkdailynews.png"' \
--form 'main_images=@"/Users/shuxuan/Pictures/app.png"' \
--form 'image_count="1"'

Example Asynchronous Response

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

Example Failure Response

{
  "error": "Invalid input data"
}

Retrieve Image Metrics

The image_metrics endpoint allows you to query the performance, costs, and other metrics related to the creation of images within a specified period. This information can help you evaluate the effectiveness and resource usage of the image creation process over time.

API Endpoint

To retrieve the metrics, send a GET request to the following URL:

GET https://api.genaifactory.ai/v1/image_metrics

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.

Query Parameters

You can use the following query parameters to specify the time period for which you want to retrieve metrics:

Name

Type

Required

Description

start

string

No

The start date of the metrics collection period in UTC (e.g., 2023-01-01T00:00:00Z).

end

string

No

The end date of the metrics collection period in UTC (e.g., 2023-01-31T23:59:59Z).

Response Body

The response will include the following metrics related to image creation within the specified period:

Name

Type

Required

Description

total_images

int

Yes

The total number of images created within the specified period.

total_cost

number

Yes

The total cost associated with creating the images within the specified period.

average_time

number

Yes

The average time taken to create each image within the specified period, in seconds.

Example Request

curl -G 'https://api.genaifactory.ai/v1/image_metrics' \
-H 'formacloud-api-key: abc123' \
--data-urlencode "start=2023-01-01T04:16:39Z&end=2023-01-31T12:25:47Z"

Example Response

Success Response (Status Code 200)

{
    "total_images": 45,
    "total_cost": 12.50,
    "average_time": 3.5
}

Failure Response (Status Code 4XX)

{
    "error": "Invalid date range",
}

Export Image as SVG

This API retrieves or generates an SVG version of the output image for a specific task ID. The response includes the SVG URL of the requested image.

API Endpoint

GET https://api.genaifactory.ai/v1/export_svg/<task_id>

Headers

Name
Type
Required
Description

formacloud-api-key

string

Yes

API key for authentication.

Query Parameters

Name
Type
Required
Description

seq

integer

No

Sequence number of the output image (default is 0).

Path Parameters

Name
Type
Required
Description

task_id

string

Yes

The unique ID of the task to export the SVG for.

Example Request

curl --location 'https://api.genaifactory.ai/v1/export_svg/12345' \
--header 'formacloud-api-key: abc123' \
--header 'Content-Type: application/json' \
--request GET \
--data-urlencode "seq=0"

Response

Returns a JSON object containing the SVG URL of the requested image.

Response Fields

Field
Type
Description

svg_url

string

URL of the exported SVG image.

Example Response

{
  "svg_url": "https://cdn.genaifactory.ai/gen_ai_factory/temp/image/2024/12/16/7439a85e8339405b9ae680dc454f75f2.svg"
}

Error Responses

HTTP Code
Error
Description

404

TaskNotFoundError

The specified task ID does not exist.

400

InvalidInputError

The input is invalid (e.g., seq out of range).

400

InvalidInputError

Task is not a valid POSTER type.

Retrieve Credit

The Retrieve credit endpoint allows you to check the total amount of credit available and how much has been used. This is useful for monitoring your API usage and ensuring you have sufficient credit for future tasks.

API Endpoint

To retrieve your credit information, send a GET request to the following URL:

GET https://api.genaifactory.ai/v1/credit

Headers

Ensure that your request includes the following header:

Response Body

The response will provide details about your credit usage:

Example Request

Example Response

Success Response (Status Code 200)

Failure Response (Status Code 4XX)

Name

Type

Required

Description

formacloud-api-key

string

Yes

API key required for authenticating your request.

Name

Type

Required

Description

total_credit

number

Yes

The total amount of credit allocated for tasks.

used_credit

number

Yes

The amount of credit used by tasks.

curl -G 'https://api.genaifactory.ai/v1/credit' \
-H 'formacloud-api-key: abc123'
{
    "total_credit": "1.00",
    "used_credit": "0.11"
}
{
    "error": "Invalid API key",
}

Retrieve Image Costs

The image_costs endpoint allows you to retrieve a breakdown of the costs associated with image generation tasks, including cloud compute costs, LLM token costs, image generation costs, and more. This endpoint supports pagination for navigating large sets of historical task data.

API Endpoint

To retrieve image generation costs, send a GET request to the following URL:

GET https://api.genaifactory.ai/v1/image_costs

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.

Query Parameters

You can use the following query parameters to specify pagination details for retrieving image cost history:

Name

Type

Required

Description

start

string

No

The start date of the history retrieval period in UTC (e.g., 2023-01-01T00:00:00Z).

end

string

No

The end date of the history retrieval period in UTC (e.g., 2023-01-31T23:59:59Z).

page_size

int

No

The maximum number of records to retrieve per page (default: 10).

page

int

No

The page number to retrieve (default: 1).

Response Body

The response will include a list of image generation cost records, each containing the following details:

Name
Type
Required
Description

task_id

int

Yes

Unique identifier of the image generation task.

poster_count

int

No

The number of posters created in the task.

task_status

string

Yes

Status of the task (e.g., SUCCESS, FAILED).

creation_time

string

Yes

The time when the image generation task was created (in UTC).

end_time

string

No

The time when the image generation task was completed (in UTC), if applicable.

total_cost

float

Yes

The total cost of the task.

error_msg

string

No

Error message associated with the task, if it failed.

Example Request

curl -G 'https://api.genaifactory.ai/v1/image_costs' \
-H 'formacloud-api-key: abc123' \
--data-urlencode "start=2023-01-01T00:00:00Z&end=2023-01-31T23:59:59Z&page_size=10&page=1"

Example Response

Success Response (Status Code 200):

{
    "image_costs": [
        {
            "creation_time": "2024-10-28T19:24:30.327236+00:00",
            "end_time": "2024-10-28T19:27:25.818746+00:00",
            "poster_count": 3,
            "task_id": 1900,
            "task_status": "SUCCESS",
            "total_cost": "1.4100"
        },
        {
            "ai_image_generation_cost": "1.2060",
            "creation_time": "2024-10-28T19:24:26.066261+00:00",
            "end_time": "2024-10-28T19:27:14.994364+00:00",
            "poster_count": 4,
            "task_id": 1899,
            "task_status": "SUCCESS",
            "total_cost": "1.8800",
        }
    ],
    "pagination": {
        "current_page": 1,
        "total_pages": 902,
        "total_records": 1803
    }
}

Failure Response (Status Code 4XX):

{
    "error": "Invalid page number."
}

Retrieve Recharge History

The recharge_history endpoint allows you to query the history of recharge transactions for an organization. It includes details such as the recharge amount, bonus amount, payment method, transaction ID, and creation time. This endpoint supports pagination to efficiently navigate through historical records.

API Endpoint

To retrieve recharge history, send a GET request to the following URL:

GET https://api.genaifactory.ai/v1/recharge_history

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.

Query Parameters

You can use the following query parameters to specify the time period, pagination, and other details for retrieving the recharge history:

Name

Type

Required

Description

start

string

No

The start date of the history retrieval period in UTC (e.g., 2023-01-01T00:00:00Z).

end

string

No

The end date of the history retrieval period in UTC (e.g., 2023-01-31T23:59:59Z).

page_size

int

No

The maximum number of records to retrieve per page (default: 10).

page

int

No

The page number to retrieve (default: 0).

Response Body

The response will include a list of recharge records and pagination details. Each recharge record contains the following information:

Name

Type

Required

Description

recharge_id

int

Yes

The unique identifier of the recharge record.

recharge_amount

decimal

Yes

The amount of money recharged.

bonus_amount

decimal

No

The bonus amount received during the recharge.

payment_method

string

No

The payment method used for the recharge (e.g., Credit Card).

transaction_id

string

Yes

The unique transaction ID for the recharge.

note

string

No

Additional notes about the recharge.

recharge_time

string

Yes

The time when the recharge occurred, in UTC.

Example Request

curl -G 'https://api.genaifactory.ai/v1/recharge_history' \
-H 'formacloud-api-key: abc123' \
--data-urlencode "start=2023-01-01T00:00:00Z&end=2023-01-31T23:59:59Z&page_size=10&page=1"

Example Response

Success Response (Status Code 200)

{
    "history": [
        {
            "recharge_id": 1,
            "recharge_amount": 100.00,
            "bonus_amount": 10.00,
            "payment_method": "Credit Card",
            "transaction_id": "TXN123456789",
            "note": "Spring Promo",
            "recharge_time": "2023-01-10T14:35:29Z"
        },
        {
            "recharge_id": 2,
            "recharge_amount": 200.00,
            "bonus_amount": 0.00,
            "payment_method": "PayPal",
            "transaction_id": "TXN987654321",
            "note": "",
            "recharge_time": "2023-01-15T09:22:10Z"
        }
    ],
    "pagination": {
        "current_page": 1,
        "total_pages": 5,
        "total_records": 50
    }
}

Failure Response (Status Code 4XX)

{
    "error": "Invalid date range"
}

Get Image Generation Result

The get_image_result endpoint allows you to retrieve the final result of a image generation task that was processed asynchronously. By providing the task ID returned from the create_images endpoint when async was set to true, you can check the status of the task and obtain the generated images once the task is complete.

API Endpoint

To retrieve the image generation result, send a GET request to the following URL:

GET https://api.genaifactory.ai/v1/get_image_result/{task_id}

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.

Path Parameters

Name

Type

Required

Description

task_id

string

Yes

The ID of the task you received when you initially made the asynchronous request.

Response Body

Pending Response (Status Code 201)

If the task is still in queue, the response will indicate that the task does not start:

Name

Type

Required

Description

status

string

Yes

A message indicating that the task is still processing, this field will be CREATED.

created_at

string

Yes

The timestamp indicating when the task was created.

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

Running Response (Status Code 202)

If the task is still in progress, the response will indicate that the task is not yet complete:

Name

Type

Required

Description

status

string

Yes

A message indicating that the task is still processing, this field will be RUNNING.

created_at

string

Yes

The timestamp indicating when the task was created.

started_at

string

Yes

The timestamp indicating when the task began processing.

Success Response (Status Code 200)

If the task has completed successfully, the response will include the generated images:

Name

Type

Required

Description

status

string

Yes

The status of the task. For successful completion, this field will be SUCCESS.

created_at

string

Yes

The timestamp indicating when the task was created.

started_at

string

Yes

The timestamp indicating when the task began processing.

finished_at

string

Yes

The timestamp indicating when the task finished processing.

images

array of strings

No

A list of URLs pointing to the generated images in PNG format. Each URL corresponds to a generated image. The images are retained for a maximum duration of one month.

images_model_names

array of arrays

No

A list of arrays indicating the model names used to generate each image. Each inner array corresponds to one image.

svg_images

array of strings

No

A list of URLs pointing to the generated images in SVG format. Each URL corresponds to a generated image. The images are retained for a maximum duration of one month.

total_cost

string

Yes

The total cost of the task in currency units.

input_parameters

object

Yes

An object containing the parameters used to generate the task, such as image dimensions, style, content details, etc. Refer to the Input Parameters section below for details.

Failure Response (Status Code 4XX)

If there is an issue with the request, such as an invalid task ID, the response will include an error message:

Name

Type

Required

Description

error

string

Yes

A descriptive error message indicating what went wrong with the request, this field will be

PARTIALLY_SUCCESSFUL or FAILED.

images

array of strings

No

A list of URLs pointing to the generated images in PNG format. Each URL corresponds to a generated image.

svg_images

array of strings

No

A list of URLs pointing to the generated images in SVG format. Each URL corresponds to a generated image.

Example Request

curl --location 'https://api.genaifactory.ai/v1/get_image_result/task_1234567890abcdef' \
--header 'formacloud-api-key: [put the key here]' \
--header 'Content-Type: application/json'

Example Pending Response

{
    "status": "CREATED",
    "tasks_ahead_count": 0,
    "created_at": "2024-12-30 05:03:51.022874 +00:00"
}

Example Running Response

{
    "status": "RUNNING",
    "created_at": "2024-12-30 05:03:51.022874 +00:00",
    "started_at": "2024-12-31 01:34:00.414493 +00:00"
}

Example Successful Response

{
    "status": "SUCCESS",
    "created_at": "2024-12-30 05:03:51.022874 +00:00",
    "started_at": "2024-12-30 05:03:51.572481 +00:00",
    "finished_at": "2024-12-30 05:06:35.493555 +00:00",
    "images": [
"https://cdn.genaifactory.ai/gen_ai_factory/temp/image/2024/12/30/32deb38c95cb472a99de75aba5bb9e8e.png",
    ],
    "svg_images": [
        null,
    ],
    "images_model_names": [
        ["M6"],
    ],
    "total_cost": "1.6000",
    "input_parameters": {
        "create_background": true,
        ...
    }
}

Example Failure Response

{
    "error": "'builtin_function_or_method' object has no attribute 'sleep'",
    "images": [
        "https://cdn.genaifactory.ai/gen_ai_factory/temp/image/2024/10/9/97b1901d1e5c4bb499a67d82cd16b5cd.png"
    ],
    "status": "PARTIALLY_SUCCESSFUL",
    "svg_images": [
        null,
    ]
}

Retrieve Image History

The image_history endpoint allows you to query the history of image creation, including the input parameters, creation time, and response results (both successful and failed) within a specified period. This endpoint supports pagination to navigate through large sets of historical data.

API Endpoint

To retrieve the image creation history, send a GET request to the following URL:

GET https://api.genaifactory.ai/v1/image_history

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.

Query Parameters

You can use the following query parameters to specify the time period, pagination, and other details for retrieving the image history:

Name

Type

Required

Description

start

string

No

The start date of the history retrieval period in UTC (e.g., 2023-01-01T00:00:00Z).

end

string

No

The end date of the history retrieval period in UTC (e.g., 2023-01-31T23:59:59Z).

page_size

int

No

The maximum number of records to retrieve per page (default: 10).

page

int

No

The page number to retrieve (default: 1).

task_types

string

No

A comma-separated list of task types to filter results (e.g., POSTER,IMG_WITHOUT_TEXT). Supported values include task types such as POSTER, IMG_WITHOUT_TEXT, and REDRAW_IMAGE. If not provided, the default is POSTER,IMG_WITHOUT_TEXT.

Response Body

The response will include a list of image creation records, each containing the following details:

Name

Type

Required

Description

create_time

string

Yes

The time when the image was created, in UTC.

input_parameters

object

Yes

The input parameters used for creating the image, including struct_content, logo_url, main_image_url, and image_count.

response_result

object

Yes

The response result of the image creation, including the success or failure response.

Example Request two

curl -G 'https://api.genaifactory.ai/v1/image_history' \
-H 'formacloud-api-key: abc123' \
--data-urlencode "start=2023-01-01T00:00:00Z&end=2023-01-31T23:59:59Z&page_size=10&page=1"


curl --location 'https://api.genaifactory.ai/v1/image_history?page_size=2&page=1&task_types=REDRAW_IMAGE' \
--header 'formacloud-api-key: abc123' \
--data ''

Example Response two

Success Response (Status Code 200)

{
    "history": [
        {
            "creation_time": "2025-01-07T21:06:26.632791+00:00",
            "input_parameters": {
                "image": "https://cdn.genaifactory.ai/gen_ai_factory/temp/image/2025/1/7/a32840a4846e48658b3d36378c6992a3.jpg",
                "mask": "https://replicate.delivery/pbxt/M0gpLCYdCLbnhcz95Poy66q30XW9VSCN65DoDQ8IzdzlQonw/kill-bill-mask.png",
                "prompt": "formacloud"
            },
            "response_result": {
                "created_at": "2025-01-07 21:06:26.632791 +00:00",
                "finished_at": "2025-01-07 21:06:41.584666 +00:00",
                "images": [
                    "https://cdn.genaifactory.ai/gen_ai_factory/temp/image/2025/1/7/57f04b22c19549bb95c548dc388bfb68.png"
                ],
                "images_model_names": [],
                "poster_imgs": [
                    "https://cdn.genaifactory.ai/gen_ai_factory/temp/image/2025/1/7/57f04b22c19549bb95c548dc388bfb68.png"
                ],
                "poster_svg_imgs": [
                    null
                ],
                "started_at": "2025-01-07 21:06:26.828427 +00:00",
                "svg_images": [
                    null
                ]
            },
            "task_id": 6928
        },
        {
            "creation_time": "2025-01-07T20:45:50.173454+00:00",
            "input_parameters": {
                "image": "https://cdn.genaifactory.ai/gen_ai_factory/temp/image/2025/1/7/c26c9814f7e4428c971b8c3a63bd8890.jpg",
                "mask": "https://replicate.delivery/pbxt/M0gpLCYdCLbnhcz95Poy66q30XW9VSCN65DoDQ8IzdzlQonw/kill-bill-mask.png",
                "prompt": "movie poster says \\\"moonveil\\\"\""
            },
            "response_result": {
                "created_at": "2025-01-07 20:45:50.173454 +00:00",
                "error": "Error generating image: Cannot connect to host api.bfl.ml:443 ssl:default [Connect call failed ('74.241.144.241', 443)]",
                "finished_at": "2025-01-07 20:45:57.575906 +00:00",
                "images": [],
                "images_model_names": [],
                "poster_imgs": [],
                "poster_svg_imgs": [],
                "started_at": "2025-01-07 20:45:50.328150 +00:00",
                "status": "The task encountered an error and did not complete successfully.",
                "svg_images": []
            },
            "task_id": 6927
        }
    ],
    "pagination": {
        "current_page": 1,
        "total_pages": 9,
        "total_records": 18
    }
}

Failure Response (Status Code 4XX)

{
    "error": "Invalid date range",
}

Example Request one

curl -G 'https://api.genaifactory.ai/v1/image_history' \
-H 'formacloud-api-key: abc123' \
--data-urlencode "start=2023-01-01T00:00:00Z&end=2023-01-31T23:59:59Z&page_size=10&page=1"

Example Response one

Success Response (Status Code 200)

```json
{
    "history": [
        {
            "creation_time": "2025-01-15T23:43:14.616443+00:00",
            "input_parameters": {
                "create_image_without_text": true,
                "freeform_content": "Subject: A sleeping tabby cat\r\nDetails: Striped brown, black and white fur pattern, curled up position, peaceful sleeping expression, visible whiskers, soft fur texture\r\nEnvironment: Grey plush blanket, white duck-shaped night light in background, warm sunlit indoor setting\r\nStyle: Natural photography with soft focus\r\nComposition: Close-up horizontal frame, cat centered, decorative duck lamp providing background interest\r\nLighting: Natural sunlight creating gentle highlights on fur, warm ambient glow\r\nQuality: High resolution with sharp detail capture, professional depth of field",
                "image_count": "1",
                "industry": "Finance/Insurance",
                "poster_count": 1,
                "resolution": "RESOLUTION_1248_702",
                "style": "WATERCOLOR"
            },
            "response_result": {
                "created_at": "2025-01-15 23:43:14.616443 +00:00",
                "finished_at": "2025-01-15 23:43:29.732993 +00:00",
                "images": [
                    "https://cdn.genaifactory.ai/gen_ai_factory/temp/image/2025/1/15/39e9b78a50b04f239406fddb46371c3b.png"
                ],
                "images_model_names": [
                    [
                        "M6"
                    ]
                ],
                "poster_imgs": [
                    "https://cdn.genaifactory.ai/gen_ai_factory/temp/image/2025/1/15/39e9b78a50b04f239406fddb46371c3b.png"
                ],
                "poster_svg_imgs": [
                    null
                ],
                "started_at": "2025-01-15 23:43:14.763913 +00:00",
                "svg_images": [
                    null
                ]
            },
            "task_id": 7384
        }
    ],
    "pagination": {
        "current_page": 100,
        "total_pages": 3911,
        "total_records": 3911
    }
}
```