Skip to main content
POST
Image-to-video: submit a video generation task from a reference image
右側のインタラクティブな Playground では、ライブデバッグをサポートしています。Authorization フィールドに API Key を設定し(形式: Bearer sk-xxx)、参照画像をアップロードして、prompt を入力し、モデル / サイズ / 秒数を選んで送信してください。
適用範囲: このページでは「参照画像から動画を生成」する方法を扱います。1枚の画像を開始フレーム / 視覚アンカーとしてアップロードし、静止画をアニメーション化します。参照画像が不要な場合は、Text-to-Video エンドポイント(同じパス、JSON ボディ)を使用してください。
⚠️ 参照画像のサイズは size と完全に一致している必要があります
  • アップロードする画像のピクセル寸法は size フィールドと一致していなければなりません(例: size=1280x720 には 1280×720 の画像が必要です)
  • 不一致の場合は 400 が返ります: Inpaint image must match the requested width and height
  • アップロード前に ffmpeg / Pillow で事前にトリミングしてください
その他の注意事項:
  • Content-Type は multipart/form-data である必要があります(JSON ではありません)
  • 対応ファイルは1つのみで、フィールド名は input_reference に固定されています
  • 対応形式: image/jpeg / image/png / image/webp

コードサンプル

Python (OpenAI SDK ドロップイン)

Python (Raw requests + multipart)

cURL

Node.js (fetch + FormData)

ブラウザ JavaScript

パラメータ クイックリファレンス

詳細なパラメータ制約、許可される値、例は右側の Playground で確認できます。input_reference は multipart でアップロードする必要があります — URL と base64 は受け付けられません。

参照画像の準備

1

ターゲット解像度を選びます

用途に応じて、まず size を選びます: 縦長 720x1280、横長 1280x720、Pro 1080p 横長 1920x1080 など。
2

ローカルでピクセル単位まで正確に切り抜きます

Pillow / ffmpeg を使って、画像をターゲットサイズに切り抜きます:
または、1 行の ffmpeg で:
3

適切なフォーマットを選びます

PNG(ロスレスで、イラスト / スクリーンショットに最適)を優先し、写真には容量を節約できる JPEG、透過が必要なら WebP を使います。
4

Focus the prompt on "motion" not "appearance"

参照画像でビジュアルはすでに決まっています。prompt では どのようにアニメーションさせるか に集中してください: カメラの前進/後退、オブジェクトの動き、ライティングの変化、キャラクターの表情など。例: "Camera slowly pushes in, leaves gently swaying, sunlight flickering through branches".

レスポンス形式

レスポンスの形は Text-to-Video同一です。submit は id + status: "queued" を返し、ポーリングで進行状況を報告し、完了後は /v1/videos/{id}/content 経由で MP4 としてダウンロードします。
⚠️ よくある 400 エラー
  • Inpaint image must match the requested width and height — 参照画像のサイズが size と一致しません。最も一般的です。 アップロード前にクライアント側でサイズを検証してください
  • Invalid file format — アップロードされたファイルが jpeg / png / webp ではないか、破損しています
  • Missing required parameter: input_reference — multipart のフィールド名が誤っています(input_reference である必要があり、imagereference ではありません)
  • seconds must be one of "4", "8", "12" — 文字列の "4" ではなく、整数の 4 を渡しています
画像から動画とテキストから動画は、同じ 1 秒あたりの料金です(seconds によって課金されます)。参照画像をアップロードしても追加料金はかかりません。料金表 をご覧ください。

承認

Authorization
string
header
必須

API Key from the APIYI console (must use Sora2官转 group + usage-based billing)

ボディ

multipart/form-data
model
enum<string>
デフォルト:sora-2
必須

Model ID. sora-2 supports 720p only; sora-2-pro supports 720p / 1024p / 1080p

利用可能なオプション:
sora-2,
sora-2-pro
prompt
string
必須

Video generation prompt. Focus on how the image should animate: camera motion, object motion, lighting changes

:

"Animate this scene: gentle waves lapping, leaves swaying, cinematic camera push-in"

input_reference
file
必須

Reference image file used as the video's starting frame / visual anchor.

  • Accepted formats: image/jpeg / image/png / image/webp
  • Dimensions must equal size, otherwise you get Inpaint image must match the requested width and height
  • Only one file is supported; field name is fixed as input_reference
seconds
enum<string>
デフォルト:4

Video duration as string enum: "4" / "8" / "12"

利用可能なオプション:
4,
8,
12
size
enum<string>
デフォルト:720x1280

Output resolution. Must exactly match the input_reference image dimensions:

  • sora-2 (720p only): 720x1280 / 1280x720
  • sora-2-pro additionally: 1024x1792 / 1792x1024 / 1080x1920 / 1920x1080
利用可能なオプション:
720x1280,
1280x720,
1024x1792,
1792x1024,
1080x1920,
1920x1080

レスポンス

Task submitted, returns video_id with queued status

id
string

Task ID for subsequent polling and download

:

"video_abc123def456"

object
string

Object type, fixed video

:

"video"

model
string

Model ID used for this task

:

"sora-2"

status
enum<string>

Task status:

  • queued — submitted, waiting in queue
  • in_progress — generating
  • completed — done, ready to download (/v1/videos/{id}/content)
  • failed — failed (not billed), safe to retry
利用可能なオプション:
queued,
in_progress,
completed,
failed
:

"queued"

progress
integer

Generation progress percentage (0–100), not strictly linear

:

0

created_at
integer

Task creation Unix timestamp (seconds)

:

1712697600

completed_at
integer

Task completion Unix timestamp (seconds), present only on completed status

:

1712697900

size
string

Actual output resolution (matches the requested size)

:

"1280x720"

seconds
string

Actual duration generated (matches the requested seconds)

:

"8"

quality
string

Quality tier (standard for sora-2, high for sora-2-pro)

:

"standard"