Skip to main content
GET
Note for users in mainland China: Please use https://toapis.cn as the API endpoint (Base URL). Replace https://toapis.com with https://toapis.cn in the examples in this document.
  • Query async image generation task execution status and results
  • Real-time status updates and progress tracking
  • Get generated images when task completes
  • Multi-language support (zh/en/ko/ja)
All image generation tasks are executed asynchronously. After submitting a task, you need to query the status and results via the query endpoint. Ordinary image and video tasks can also be queried with GET /v1/tasks/{task_id}, using the same usage and billing definitions. This page describes responses from the generation-task query path shown above. Examples illustrate the fields, not current model prices or a fixed billing mode. Use the fields and amounts returned for the actual task.

Authorizations

string
required
All endpoints require Bearer Token authenticationGet your API Key:Visit the API Key Management Page to get your API KeyAdd it to the request header:

Path Parameters

string
required
Task ID returned by the image generation API

Response

string
Unique task identifier
string
Optional customer business ID, returned only when client_business_id was supplied at task creation.
string
Object type, always generation.task
string
Task status
  • queued - Queued for processing
  • in_progress - Processing
  • completed - Successfully completed
  • failed - Failed
integer
Integer progress percentage, from 0 to 100.
string
Image generation model used
integer
Task creation time (Unix timestamp)
integer
Task finish time as a Unix timestamp. This query path returns it for successful or failed tasks when a finish time has been saved.
integer
Task completion time (Unix timestamp, only returned when completed)
integer
Image URL expiration time (Unix timestamp, only returned on completion)
object
Task result (only returned on success)
object
Optional image-task billing information. Billing status is independent of generation status: completed does not guarantee settlement. If billing data cannot be confirmed, the entire billing field is omitted, not returned as null. Omission does not mean the task was free.
object
Optional billing quantities, image-token details, and tool counts. See Task usage fields for charge_type, requests, billed_tokens, and related fields. Image-token details are returned only when billing.status is settled and saved usage is valid and consistent with the final charge. Unconfirmed parts are omitted; confirmed amounts and image results remain available.charge_type, requests, billed_tokens, and input_images are billing quantities and are returned only together with billing.status=settled. Per-request tasks charged once at submission also return settled with the actual amount. All token counts are non-negative JSON integers. Cached tokens are a subset of input tokens and must not be added again. output_tokens_details is omitted entirely when the breakdown is unavailable. usage.tool_usage.web_search may be returned independently or alongside image tokens.
object
Error information (only returned on failure)

Billing Status and Spend Tracking

These billing rules apply to image-task queries across models and channels. GPT-Image-2.5 Sunburst and Flare VIP / Official variants provide token usage when settlement data is available; other models depend on their recorded settlement data. Example amounts illustrate the response format, not a fixed price.
  • Amounts reflect the task’s confirmed final charge. Querying does not charge, add charges, refund, or recalculate using current model prices. Use the returned amounts for accounting instead of multiplying tokens by current prices.
  • Deduplicate by task id and update its amount; do not sum the same charge on every poll. Use decimal arithmetic. Treat pending or missing fields as unknown spend, not zero.
  • Amounts use decimal strings with no fixed number of decimal places.
  • Missing or inconsistent billing records can cause billing to be omitted. When an image is not yet deliverable and the task is temporarily shown as in_progress, both billing and usage may be omitted.
  • A successful Webhook uses the same confirmation rules and field values for data.usage and data.billing as this endpoint. A Webhook is a snapshot taken when the event is created; if a field is absent, query this endpoint as a fallback. See Pricing and Actual Charges.

Task Status Reference

Polling Strategy

Python Polling Example

Resource Expiration

Generated image URLs are valid for 24 hours
  • Please download and save images within the validity period
  • expires_at field indicates image expiration time (Unix timestamp)
  • Expired images cannot be accessed; to regenerate, submit a new task

Errors and failure reasons

See the error reference for request errors, task failures, specific causes, and recovery guidance. A successful query still requires checking task status; HTTP status is not a business error code.
ToAPIs provides a unified Task Webhook. Prefer callbacks and use polling as fallback. Poll every 5–10 seconds or slower with jitter and honor Retry-After on 429. Batch queries accept at most 100 task IDs; see rate limits.