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."
}

Last updated