Skip to main content
The SDK exposes completed result wrappers and an async task representation:
  • ImageGenerationResult for completed work
  • ImageRateResult for completed rating tasks
  • ImageAltResult for completed alt text tasks
  • TaskAsync for in-progress work

ImageGenerationResult

ImageGenerationResult is returned from sync generation (generate()) and from TaskAsync.wait() on generation tasks. Useful properties and helpers:
  • result.id
  • result.status
  • result.result
  • result.urls
  • result.getImages()
  • result.getImages({ includeFailed: true })
  • result.getMetadata()
Example:

ImageRateResult and ImageAltResult

Single-image analysis results from rate() / alt() (or the matching TaskAsync.wait()):

TaskAsync

TaskAsync is returned from:
It provides:
  • task.id
  • task.access.publicAccessToken
  • task.wait() — polls until completion and resolves to the matching result wrapper

Browser-safe access token

publicAccessToken is a task-scoped JWT (prefixed with pat_) designed for client-side polling of:
  • GET /tasks/:id/status
  • GET /tasks/:id/result
Generation tasks include a Public Access Token by default. Rating and alt text tasks currently return undefined for task.access.publicAccessToken, so poll those from trusted server code with your API key. Do not use a Public Access Token as a replacement for your server-side API key.

Polling behavior

wait():
  • starts polling lazily — only when first called
  • reuses the same promise if called multiple times
  • polls every 2.5s for the first 12s, then slows to every 5s
  • times out after five minutes
  • retries transient fetch failures up to 7 times, resetting the count after any successful poll

Error classes

The SDK exposes dedicated error classes:
  • MynthAPIError
  • TaskAsyncTimeoutError
  • TaskAsyncUnauthorizedError
  • TaskAsyncFetchError
  • TaskAsyncTaskFetchError
  • TaskAsyncTaskFailedError
Use them when you want differentiated handling for validation failures, unauthorized access, timeouts, and failed tasks. See Errors and Limits for usage examples.