Skip to main content

Text-to-image

What this lets you do

Generate one image from a text prompt through a durable managed execution.

What you need

  • A server-side DreamLayer test or live key
  • A unique idempotency key for this logical turn
  • One available live credit when using a live key

Steps

1. Send the request

2. Check the request schema

prompt is required and accepts 1 to 4,000 characters. max_credits is fixed at 1 in V1.

3. Read the result

A successful stream emits one asset event and ends with done status completed. The asset object contains an opaque ID, owned download URL, PNG content type, width, and height. One completed text-to-image operation uses one live credit.

Confirm it worked

The stream emits one asset and ends with done status completed. The live credit changes from reserved to settled only after delivery.

Common errors

  • 400: fix a missing or out-of-range request field.
  • 402: add credits or switch to a test key.
  • 409: do not reuse the idempotency key for different request bytes.

Troubleshooting

If the connection closes, read canonical execution state before retrying. Reuse the same idempotency key only for the same logical request.

Next steps