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

# 動画生成クイックスタート

タスクを作成 → 状態を確認 → 動画 URL を取得。API キーを置き換え、サンプルモデルへのアクセスと videos 権限を確認すれば、5 秒・720p の動画を生成できます。素材のアップロードや事前の見積もりリクエストは不要です。

> [tab] Python
>
> pip install requests を実行してから、以下の Python サンプルをコピーして実行してください。自動で状態を確認し、動画 URL を出力します。
>
> ```python theme={null}
> import time
> import requests
>
> BASE = "https://api.cloudsome-inc.ai/v1"
> HEADERS = {"Authorization": "Bearer sk_live_your_key_here"}
>
> response = requests.post(f"{BASE}/videos", headers=HEADERS, json={
>     "model": "dreamina-seedance-2.5",
>     "prompt": "A golden retriever running on the beach at sunset",
>     "duration": 5,
>     "resolution": "720p",
> }, timeout=60)
> response.raise_for_status()
> task_id = response.json()["tasks"][0]["id"]
> print("Task ID:", task_id)
>
> for _ in range(120):
>     response = requests.get(f"{BASE}/videos/{task_id}", headers=HEADERS, timeout=30)
>     response.raise_for_status()
>     task = response.json()
>     if task["status"] == "completed":
>         url = task.get("download_url") or task.get("url")
>         if not url:
>             raise RuntimeError(f"Video URL unavailable; query task {task_id} again.")
>         print(url)
>         break
>     if task["status"] in ("failed", "cancelled", "expired"):
>         raise RuntimeError(task.get("error") or task["status"])
>     time.sleep(5)
> else:
>     raise TimeoutError(f"Keep querying task {task_id}; do not create it again.")
> ```

> [tab] Node.js
>
> Node.js 18+ を使用します。サンプルを video.mjs に保存し、node video.mjs を実行すると、自動で状態を確認し、動画 URL を出力します。
>
> ```javascript theme={null}
> const BASE = "https://api.cloudsome-inc.ai/v1";
> const headers = {
>   Authorization: "Bearer sk_live_your_key_here",
>   "Content-Type": "application/json",
> };
>
> async function request(path, options = {}) {
>   const response = await fetch(BASE + path, {
>     ...options, headers, signal: AbortSignal.timeout(60_000),
>   });
>   if (!response.ok) throw new Error(await response.text());
>   return response.json();
> }
>
> const batch = await request("/videos", {
>   method: "POST",
>   body: JSON.stringify({
>     model: "dreamina-seedance-2.5",
>     prompt: "A golden retriever running on the beach at sunset",
>     duration: 5,
>     resolution: "720p",
>   }),
> });
> const taskId = batch.tasks[0].id;
> console.log("Task ID:", taskId);
>
> for (let attempt = 0; ; attempt++) {
>   if (attempt === 120) throw new Error("Keep querying task " + taskId + "; do not create it again.");
>   const task = await request("/videos/" + taskId);
>   if (task.status === "completed") {
>     const url = task.download_url || task.url;
>     if (!url) throw new Error("Video URL unavailable; query task " + taskId + " again.");
>     console.log(url);
>     break;
>   }
>   if (["failed", "cancelled", "expired"].includes(task.status)) {
>     throw new Error(JSON.stringify(task.error || task.status));
>   }
>   await new Promise((resolve) => setTimeout(resolve, 5000));
> }
> ```

> [tab] cURL
>
> 最初のコマンドでタスクを作成し、レスポンスの tasks\[0].id を次のコマンドの VIDEO\_ID に設定してください（トップレベルのバッチ id ではありません）。status が completed、failed、cancelled、expired のいずれかになるまで、約 5 秒ごとに 2 番目のコマンドを繰り返します。
>
> ```bash theme={null}
> curl --fail-with-body -sS https://api.cloudsome-inc.ai/v1/videos \
>   -H "Authorization: Bearer sk_live_your_key_here" \
>   -H "Content-Type: application/json" \
>   -d '{
>     "model": "dreamina-seedance-2.5",
>     "prompt": "A golden retriever running on the beach at sunset",
>     "duration": 5,
>     "resolution": "720p"
>   }'
>
> curl --fail-with-body -sS https://api.cloudsome-inc.ai/v1/videos/VIDEO_ID \
>   -H "Authorization: Bearer sk_live_your_key_here"
> ```

成功時は download\_url または url を開いてダウンロードできます。失敗理由は error に表示されます。リンクの有効期限は 15 分です。期限切れの場合はタスクを再照会してください。タスク ID を保存し、照会回数の上限に達した場合や照会が中断した場合も、再作成せず元のタスクを照会してください。

タスクの stage は waiting\_submission、submitting、upstream\_queued、generating、saving、completed、failed、verification\_pending を区別します。既存の status と料金フィールドは互換性を維持します。request\_id はリクエスト ID です。created\_at と completed\_at はプラットフォームの観測時刻で、モデルの計算時間や最初のフレームの表示時刻ではありません。処理または精算が保留中は 5 秒ごとに照会し、完了・精算後に停止します。

save\_retrying=true は保存を再試行中です。同じタスクの照会を続けてください。status=failed かつ retryable=true の場合のみ、新しい冪等キーと n=1 で再生成でき、新規リクエストとして課金されます。error.category は入力審査、出力審査、著作権制限を区別し、error.provider\_code は上流の元のコードを保持します。キュー満杯またはレート制限の 429 は時間を置いて再試行してください。送信結果不明や使用量不完全の場合は確認を待ち、自動で再生成しません。


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