Skip to content

Video Generation

Video generation is an asynchronous task flow: submit a task to get a task ID, poll its status, then fetch the video content once it completes. The endpoint is compatible with the OpenAI video protocol.

Full flow

Submit task → get id → poll status → status becomes completed → fetch video content

Step 1: Submit the task

POST /v1/videos

Common request parameters

ParameterTypeRequiredDescription
modelstringVideo model ID; see the console Models page for valid values
promptstringVideo description prompt
secondsstringVideo duration in seconds
sizestringVideo resolution, e.g. "1280x720", "1920x1080"
imagestringReference image (URL or base64) for image-to-video

TIP

Different video models support different parameters and value ranges. Refer to the console Models page and each model's documentation.

Example

bash
curl https://api.idreame.ai/v1/videos \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sk-xxxxxxxx" \
  -d '{
    "model": "sora-2",
    "prompt": "A corgi surfing on a beach at sunset, slow motion, cinematic",
    "seconds": "8"
  }'

Response example

json
{
  "id": "video_abc123",
  "object": "video",
  "model": "sora-2",
  "status": "queued",
  "progress": 0,
  "created_at": 1752600000,
  "seconds": "8",
  "size": "1280x720"
}

Step 2: Poll status

GET /v1/videos/{video_id}

bash
curl https://api.idreame.ai/v1/videos/video_abc123 \
  -H "Authorization: Bearer sk-xxxxxxxx"

Task statuses

statusMeaning
queuedQueued and waiting
in_progressGenerating (see the progress field)
completedDone; content can be fetched
failedGeneration failed; see the error field

Response on completion

json
{
  "id": "video_abc123",
  "object": "video",
  "model": "sora-2",
  "status": "completed",
  "progress": 100,
  "created_at": 1752600000,
  "completed_at": 1752600120,
  "expires_at": 1752686520,
  "seconds": "8",
  "size": "1280x720"
}

Step 3: Fetch the video content

GET /v1/videos/{video_id}/content

Once the task completes, fetch the video's binary content:

bash
curl https://api.idreame.ai/v1/videos/video_abc123/content \
  -H "Authorization: Bearer sk-xxxxxxxx" \
  --output my_video.mp4

Full Python example

python
import time
import httpx

API_KEY = "sk-xxxxxxxx"
BASE_URL = "https://api.idreame.ai/v1"

headers = {"Authorization": f"Bearer {API_KEY}"}

# 1. Submit the task
resp = httpx.post(
    f"{BASE_URL}/videos",
    headers={**headers, "Content-Type": "application/json"},
    json={
        "model": "sora-2",
        "prompt": "A corgi surfing on a beach at sunset, slow motion, cinematic",
        "seconds": "8",
    },
)
video_id = resp.json()["id"]
print(f"Task submitted, ID: {video_id}")

# 2. Poll status
while True:
    data = httpx.get(f"{BASE_URL}/videos/{video_id}", headers=headers).json()
    status = data["status"]
    print(f"status: {status}  progress: {data.get('progress')}")

    if status == "completed":
        break
    elif status == "failed":
        print(f"generation failed: {data.get('error')}")
        raise SystemExit(1)

    time.sleep(5)  # poll every 5 seconds

# 3. Fetch the video content
content = httpx.get(f"{BASE_URL}/videos/{video_id}/content", headers=headers)
with open("my_video.mp4", "wb") as f:
    f.write(content.content)
print("Saved my_video.mp4")

Available video models

The platform aggregates video models from multiple providers. For the exact model IDs, supported durations, and resolutions, refer to the console Models page. Use GET /v1/models to list the models available to your token.

TIP

Video generation usually takes a while, depending on the model and duration. A polling interval of 5–10 seconds is recommended, along with a sensible overall timeout.

OpenAI-compatible · Multimodal AI gateway