Skip to main content
Describe an image in text, submit it to POST /v1/images, poll the returned job until it’s ready, and download the PNGs. One request generates 1–6 images with the qwen model; add up to 8 reference images to guide them. Set VIGGLE_API_KEY and run the example below as-is — it needs no other input.

What you need

  • An API key from the Viggle Dashboard, exported as VIGGLE_API_KEY
  • A text prompt, up to 4000 characters
  • Credits: 1 credit (0.01)perimage∗∗at‘1K‘,∗∗2credits(0.01) per image** at `1K`, **2 credits (0.02) per image at 2K. The example below generates two 1K images for 2 credits.

Generate, poll, and download

The script creates a job for two 16:9 images, polls every 3 seconds, and saves each image as image_0.png, image_1.png, and so on.
The @viggle/sdk example requires an SDK version that includes the images resource.

Response

The create request answers immediately with a queued job:
Poll GET /v1/images/{image_id} until status is ready or failed. While processing, progress rises as each image finishes. Once ready, images lists all n images in request order, each with a url, its width and height in pixels, and the seed it used. In production, two 1K images take about 17–22 seconds. Each url is a signed link, valid for 1 hour — if it expires, fetch the job again for a fresh one. Generated images are deleted 24 hours after the job finishes, so download them before then.

Add reference images

Upload files with reference_image, pass public http(s) URLs with reference_image_url, or mix both. Either field can be repeated, up to 8 reference images in total:
Poll and download the same way. With reference images, 2K produces a smaller size than text-only 2K — here 1536 × 1536 instead of 2048 × 2048 — at the same price. One 2K image with a reference image takes about 37 seconds. Each reference image can be up to 24 MiB; see Generate Image for formats and limits.

If a job fails

Read error.code. SERVICE_BUSY and TASK_FAILED are retryable — create a new job with the same parameters. INVALID_REQUEST means the model rejected the request, for example an unusable reference image; change the inputs first. A failed job is refunded in full. See Get Image.

Generate Image

Every field, output size, and limit.

Get Image

The full Image object, statuses, and error codes.