New to Kestra?
Use blueprints to kickstart your first workflows.
Generate AI images with Magic Hour in Kestra, safely poll one project to completion, and retrieve the final download URL.
Turn an image prompt into a completed Magic Hour asset from a reusable Kestra workflow. The flow starts one billable image project, stores its project ID, polls that same project until it reaches a terminal state, and reports the exact download URL and expiration time. Reusing the original ID is essential: starting a new project after an ambiguous timeout can create duplicate renders and extra API spend.
create_image (io.kestra.plugin.core.http.Request) sends the prompt and aspect ratio to POST /v1/ai-image-generator. It requests one image with Magic Hour's default model and stores the returned project ID in {{ outputs.create_image.body | jq('.id') | first }}.wait_for_image (io.kestra.plugin.core.flow.LoopUntil) calls GET /v1/image-projects/{id} every 10 seconds. It stops only when the same project reaches complete or error, with a 10-minute maximum duration.fail_render_error converts Magic Hour's terminal error state into a failed Kestra execution that includes the API error details.report_completed_image logs the project ID, exact download URL, and expiration timestamp from the completed project.api.magichour.ai.MAGIC_HOUR_API_KEY: authenticates the create and project-status requests. Each Kestra user should supply their own key; never place it directly in the flow YAML.prompt (STRING): required image description. The default demonstrates product photography.aspect_ratio (SELECT): 1:1, 16:9, or 9:16; defaults to 1:1.{{ outputs.create_image.body | jq('.id') | first }}.{{ outputs.poll_project.body | jq('.downloads[0].url') | first }}.{{ outputs.poll_project.body | jq('.downloads[0].expires_at') | first }}.Download URLs expire. Copy a completed asset to durable storage in a downstream task when the workflow needs to retain it.
https://magichour.ai/developer and save it as the Kestra secret MAGIC_HOUR_API_KEY.report_completed_image to copy the final URL before it expires.io.kestra.plugin.core.http.Download and an S3, GCS, or Azure Blob upload task to persist the completed image.