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

Success Response (Status Code 200)

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

Name

Type

Required

Description

images

array of strings

Yes

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

svg_images

array of strings

Yes

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

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.

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.

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 currently retained for a maximum duration of one month.

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 currently retained for a maximum duration of one month.

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.

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 Successful Response

{
    "images": [
    "https://cdn.genaifactory.ai/gen_ai_factory/temp/image/2024/7/12/image1.webp",
        "https://cdn.genaifactory.ai/gen_ai_factory/temp/image/2024/7/12/image2.webp"
    ]
    "svg_images": [
"https://cdn.genaifactory.ai/gen_ai_factory/temp/image/2024/9/21/46fb9eea11b84f1c9bfbe1a0b9cb0481.svg",
        "https://cdn.genaifactory.ai/gen_ai_factory/temp/image/2024/7/12/image2.svg",
    ]
}

Example Pending Response

{
    "status": "The image generation task is still in progress. Please try again later.",
    "images": [
"https://cdn.genaifactory.ai/gen_ai_factory/temp/image/2024/10/9/97b1901d1e5c4bb499a67d82cd16b5cd.png"
    ]
}

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": "The task encountered an error and did not complete successfully.",
    "svg_images": []
}

Last updated