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,
    ]
}

Last updated