> ## Documentation Index
> Fetch the complete documentation index at: https://docs.gengen.farm/llms.txt
> Use this file to discover all available pages before exploring further.

# Generate your first video with Seedance or Wan Spicy

> Build a complete Seedance 2.5 or Wan 3.0 Spicy integration: create a task, save its ID, poll for completion, download the video, and handle failures.

This walkthrough creates one five-second, 720p video from text. It uses the normalized GENGEN request and response format for both models.

## Prepare your account

Create an [API key](https://gengen.farm/dashboard?section=apiKeys\&createKey=1), fund your wallet, and review [current prices](https://docs.gengen.farm/pricing.md). Each successful generation is billable. You need curl and Python 3; no provider SDK is required.

Set `GENGEN_API_KEY` in your local environment. Keep the key on your backend and out of browser code, source control and shared logs.

## Choose one request

Save **one** of these examples as `request.json`. The examples use no input media, so you can first verify your task lifecycle without hosting reference files.

> [tab] Seedance 2.5
>
> ```json request.json theme={"dark"}
> {
>   "model": "dreamina-seedance-2-5-260628",
>   "mode": "text_to_video",
>   "prompt": "A slow camera orbit around a ceramic vase on a sunlit table.",
>   "controls": { "duration": 5, "resolution": "720p", "ratio": "16:9" }
> }
> ```
>
> Next, explore [Seedance reference and editing workflows](https://docs.gengen.farm/guides/video-generation) or [source-attributed prompt examples](https://gengen.farm/prompts). Output duration, resolution and reference-video usage affect billing.

> [tab] Wan 3.0 Spicy
>
> ```json request.json theme={"dark"}
> {
>   "model": "wan-3.0-spicy",
>   "mode": "text_to_video",
>   "prompt": "A sailboat enters a quiet harbor at sunrise. Slow tracking shot.",
>   "controls": { "duration": 5, "resolution": "720p", "ratio": "16:9" }
> }
> ```
>
> This is the base **Spicy** model. Standard and Pro editions have different IDs and capabilities. For reference inputs, review [Wan input limits](https://docs.gengen.farm/api-reference/wan/video-generation/create-task.md). Billing includes output plus reference-video seconds.

## Submit once and save the response

```bash theme={"dark"}
curl --fail-with-body --silent --show-error \
  --connect-timeout 15 --max-time 120 \
  --request POST 'https://gengen.farm/v1/contents/generations/tasks' \
  --header "Authorization: Bearer ${GENGEN_API_KEY:?Set GENGEN_API_KEY first}" \
  --header 'Content-Type: application/json' \
  --data-binary @request.json \
  --output task.json
```

Continue only after a successful HTTP response containing `id`. Keep `task.json`: it contains the ID needed to resume polling. Do not rerun the creation command to check progress. If the POST times out or its outcome is unclear, check Dashboard task logs or contact [support](https://gengen.farm/support) before creating another paid task.

## Poll and download

Save this as `poll_video.py` and run `python3 poll_video.py`. It resumes the ID in `task.json`, retries only temporary **GET** failures, and never creates another generation task. The 30-minute polling limit is a client timeout, not a provider completion guarantee; you can resume polling later with the same file.

```python poll_video.py theme={"dark"}
import json
import os
import shutil
import time
from pathlib import Path
from urllib.error import HTTPError, URLError
from urllib.parse import quote, urlparse
from urllib.request import Request, urlopen

task_id = json.loads(Path("task.json").read_text()).get("id")
if not isinstance(task_id, str) or not task_id:
    raise SystemExit("No task ID. Inspect task.json before continuing.")

endpoint = "https://gengen.farm/v1/contents/generations/tasks/"
request = Request(endpoint + quote(task_id, safe=""), headers={
    "Authorization": "Bearer " + os.environ["GENGEN_API_KEY"]
})
deadline = time.monotonic() + 30 * 60
while time.monotonic() < deadline:
    try:
        with urlopen(request, timeout=30) as response:
            task = json.load(response)
    except HTTPError as error:
        if error.code == 429 or 500 <= error.code < 600:
            time.sleep(15)
            continue
        raise SystemExit(f"Retrieval failed with HTTP {error.code}. Check the key and task ID.")
    except (URLError, TimeoutError):
        time.sleep(15)
        continue

    status = task.get("status")
    if status in ("failed", "cancelled", "canceled", "expired"):
        Path("task-result.json").write_text(json.dumps(task, indent=2))
        raise SystemExit("Task ended: " + status + ". Inspect task-result.json.")
    if status in ("completed", "succeeded"):
        videos = (task.get("outputs") or {}).get("videos") or []
        if not videos:
            raise SystemExit("No video URL. Inspect the task and its media expiry; do not resubmit automatically.")
        output_url = videos[0]
        if not isinstance(output_url, str) or urlparse(output_url).scheme != "https":
            raise SystemExit("Unexpected output URL.")
        # Download without forwarding the API key to the media host.
        with urlopen(output_url, timeout=60) as source, open("video.mp4.part", "wb") as target:
            shutil.copyfileobj(source, target)
        Path("video.mp4.part").replace("video.mp4")
        print("Saved video.mp4 for task", task_id)
        break
    time.sleep(10)
else:
    raise SystemExit("Polling paused. Resume with the saved task ID; do not create a replacement task.")
```

Download successful outputs promptly because output URLs can expire. If the download fails, rerun the polling script with the saved ID; it will retrieve the task again without submitting a new generation.

## Handle failures before retrying

| Result | Next step |
| - | - |
| HTTP 401 or 403 | Check the bearer key and its access. Retrieve with the same account/key used for creation. |
| Insufficient balance | Check wallet funds and the requested model's current price. |
| Invalid input or inaccessible media | Correct the specified field or media URL before making a new request. |
| Content-policy rejection | Review the error and the input. A different model is not a guaranteed workaround. |
| POST timeout or unclear acceptance | Preserve the response and request time. Check task logs or contact support; do not automatically resubmit. |
| Temporary GET error | Retry retrieval with a delay using the same task ID. |

For assistance, include the task ID, model ID and error code, without your API key. See [provider troubleshooting](https://docs.gengen.farm/help/provider-errors.md) and [support](https://gengen.farm/support).

## Add reference media after the first successful task

Choose the model-specific media fields and limits from the API reference. Make input URLs accessible without browser cookies or custom headers, and keep signed URLs valid through processing. An image keyframe, reference video and source video are different inputs; do not interchange them.

* [Seedance 2.5 workflows and pricing](https://gengen.farm/models/seedance-2-5)
* [Wan 3.0 Spicy workflows and pricing](https://gengen.farm/models/wan-3-0-spicy)
* [Normalized API response format](https://docs.gengen.farm/api-reference/introduction.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.