How it works
#Typical workflows
#Media (image or video)
- Optionally call get_models to pick a model and see cost; call get_balance to confirm you have enough credits.
- Call generate_media with prompt, model, and options. You receive a
generation_id. - Poll get_generation_status with that ID every few seconds (e.g. 2-5 seconds) until
statusiscompletedorfailed. - When completed, use the
outputsarray: each item hasurl(full quality),thumbnail_url, and optionallyoptimized_url. Use the one that fits your use case (preview vs download).
#Music
- Optionally call get_balance and get_models (music) to check credits and cost.
- Call generate_music with prompt, style, and options. You receive a
generation_id. - Poll get_music_status with that ID until
statusiscompletedorfailed. - When completed, use the
songsarray: each song hasaudio_url,title,lyrics, and oftenimage_url.
#Ads
- Call create_ad_copy with reference ad image URL, and your product (user-uploaded product image URL or text), and options. You receive
generation_ids(one per variant). - For each ID, poll get_generation_status (same as media) until completed.
- Use the returned image URLs for each variant.
#Best practices
- Check balance and cost first - Call get_balance and get_models before expensive generations so users are not surprised by failures or costs.
- Respect model requirements - For media, only send
source_media_urlswhen the model supports image-to-video or image-to-image. Use get_models to see which models need input media. - Poll sensibly - Use a 2-5 second interval when polling status. Set a maximum wait time (e.g. 5-10 minutes for media, longer for music/ads) and show a timeout message if the job does not complete.
- Handle errors - On rate limit (e.g. 429), wait and retry. On insufficient credits or invalid parameters, show a clear message and do not retry the same request without user action.
- Use the right URL - For previews use
thumbnail_urloroptimized_url; for full quality useurl.
See Limitations for rate limits and credit behavior.
