# LINGTU AI image and video generation workflow

Create one generation schedule, keep querying the same scheduleId and read the final images or videos, so a network interruption does not create duplicate tasks.

## Endpoints

- Create: [createAiGenerationSchedule](/en/openapi/operations/createAiGenerationSchedule.md)
- Query: [listAiTasksByScheduleId](/en/openapi/operations/listAiTasksByScheduleId.md)

## Sequence

1. Call POST /v1/ai/schedule/create with either an image or a video request body.
2. Save data.scheduleId from the success response.
3. Call GET /v1/ai/task/listByScheduleId?scheduleId=... about every 5 seconds.
4. Keep polling while tasks are WAITING_SUBMIT, SUBMITTING, PENDING or PROCESSING.
5. Stop when every task in this request is COMPLETED.
6. Treat SUBMIT_FAILED, FAILED, CANCELLED and EXPIRED as failures.
7. For videos read customResult.videoUrl first, then result.url; for images read result.url first, then resultUrl.

## Interruptions and retries

- Network errors or a stopped polling process do not mean the generation task failed; resume polling with the original scheduleId.
- Create a new schedule only after the original task reached a terminal failure and the business decided to retry.
- Retry safe queries with exponential backoff on HTTP 408, 429 or transient 5xx, and respect Retry-After when present.
