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.

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
Object type, always generation.task
string
Task status
  • queued - Queued for processing
  • in_progress - Processing
  • completed - Successfully completed
  • failed - Failed
string
Image generation model used
integer
Task creation time (Unix timestamp)
integer
Task completion time (Unix timestamp, only returned when completed)
string
Generated image URL (only returned on success)
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 settled image-token usage. Image-token fields are returned only when billing.status is settled and the saved usage is valid and matches the final charge. Missing or invalid usage is omitted, not estimated or replaced with zeros. Confirmed amounts and image results can still be returned.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 may include the same image-token fields in data.usage and may include confirmed charges in data.billing. If either 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

Error Codes

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.