Generation APIs/Images

Get Image Task

GET

Overview

Read the current status and result payload for a previously submitted image task. Poll this endpoint until data.status reaches completed or failed.

Authentication

All API requests require a Bearer token in the request header.

Authorization: Bearer YOUR_API_KEY

Create and manage API keys from API Keys or use https://www.apimall.ai/api-keys.

Request

API Information

  • URL: GET https://gateway.apimall.ai/api/v1/images/{task_id}

Path Parameters

ParameterTypeRequiredDescription
task_id
stringRequired

Image task identifier returned by `POST /api/v1/images/generate`.

Request Example

GET https://gateway.apimall.ai/api/v1/images/img_01HQ9M7XJQ7PZ3GQ9F6C5W3N2M

Response Example

{
  "success": true,
  "data": {
    "task_id": "img_01HQ9M7XJQ7PZ3GQ9F6C5W3N2M",
    "model": "nano-banana",
    "status": "completed",
    "output": {
      "resultUrls": [
        "https://cdn.apimall.ai/generated/image-01.webp"
      ]
    },
    "primary_url": "https://cdn.apimall.ai/generated/image-01.webp",
    "image_url": "https://cdn.apimall.ai/generated/image-01.webp",
    "error_message": null,
    "credits_used": 8,
    "credits_refunded": 0,
    "created_at": "2026-03-12T09:30:00.000Z",
    "updated_at": "2026-03-12T09:31:06.000Z",
    "completed_at": "2026-03-12T09:31:06.000Z"
  },
  "request_id": "req_01HQ9M7J7X9P7Y8T6W5V4U3S2R"
}

cURL Example

curl --request GET 'https://gateway.apimall.ai/api/v1/images/img_01HQ9M7XJQ7PZ3GQ9F6C5W3N2M' \
  --header 'Authorization: Bearer YOUR_API_KEY'

JavaScript Example

const API_KEY = process.env.APIMALL_API_KEY;

const task_id = "img_01HQ9M7XJQ7PZ3GQ9F6C5W3N2M";

const response = await fetch(`https://gateway.apimall.ai/api/v1/images/${encodeURIComponent(String(task_id))}`, {
  headers: {
    Authorization: `Bearer ${API_KEY}`,
  },
});

if (!response.ok) {
  throw new Error(`Request failed: ${response.status} ${response.statusText}`);
}

const data = await response.json();
console.log(data);

Response Parameters

ParameterTypeDescription
success
boolean

Whether the request completed successfully.

data.task_id
string

Task ID used to query task status and results.

data.model
string

Model name used for the task.

data.status
string

Current status value returned by the API. Generation task endpoints use normalized values such as `pending`, `processing`, `completed`, `failed`, or `unknown`; management endpoints may return resource states such as `created`, `revoked`, or `active`.

data.output.resultUrls
array

Generated result URLs returned by the upstream provider payload.

data.primary_url
string

Primary hosted image URL for image tasks.

data.image_url
string

Hosted image result URL.

data.error_message
string

Failure reason returned when the music task does not complete successfully.

data.credits_used
integer

Credits consumed by this request.

data.credits_refunded
integer

Credits refunded after failure or partial refund handling.

data.created_at
string

Creation timestamp for the returned resource or task record.

data.updated_at
string

Last update timestamp for the returned resource or task record.

data.completed_at
string

Completion timestamp for the task when available.

request_id
string

Request identifier for debugging and support.

Error Response Example

{
  "success": false,
  "error": {
    "code": "not_found",
    "message": "Task not found"
  },
  "request_id": "req_01HQ9M7J7X9P7Y8T6W5V4U3S2R"
}

Integration Notes

  • Store your API key on the server side only.
  • Treat `completed` and `failed` as terminal states when implementing polling.
  • Use the hosted asset URL fields in the response for downstream delivery or storage.

Error Codes

Common Error Codes

Status CodeDescription
200Request successful
401API key required or invalid API key
403API access not approved or request made on a non-gateway host
404Resource not found
429Rate limit exceeded
500Internal server error
Get Image Task - API Reference | API Mall | API Mall