API キーはサーバー側の環境変数またはシークレット管理に保管してください。ブラウザのバンドル、Git、ログ、スクリーンショットに含めないでください。

公式 SDK クイックスタート

The official SDKs wrap the one-step contract (create → poll → download) with automatic idempotency keys and typed errors; the Node SDK has zero dependencies and Python depends only on httpx. Distributed as GitHub repositories for now — npm/PyPI releases will be announced separately.

Node

npm install github:openaiav/sdk-node   # npm 正式发布另行公告

import { OpenAiav } from '@openaiav/sdk'
const client = new OpenAiav({ apiKey: process.env.OPENAIAV_API_KEY })
const task = await client.generations.createAndWait({
  model: 'seedance-2.5-oa', prompt: 'She walks into the sunlight.',
  resolution: '480p', aspectRatio: 'adaptive', durationSeconds: 4,
  generateAudio: false
})
await client.generations.downloadToFile(task.id, './out.mp4')

Python

pip install git+https://github.com/openaiav/sdk-python   # PyPI 正式发布另行公告

from openaiav import OpenAiav
client = OpenAiav(os.environ["OPENAIAV_API_KEY"])
task = client.generations.create_and_wait({
    "model": "seedance-2.5-oa", "prompt": "She walks into the sunlight.",
    "resolution": "480p", "aspectRatio": "adaptive", "durationSeconds": 4,
    "generateAudio": False,
})
client.generations.download_to_file(task["id"], "./out.mp4")

4 ステップで統合

  1. サーバー側の環境変数 OPENAIAV_API_KEY を使って https://api.openaiav.com/v1/models を呼び出し、現在のモデルキー、料金、reference_modes を取得します。
  2. POST /v1/generations に prompt、referenceMode、referenceImages を送信します。参考画像は公開 HTTPS URL で、事前登録は不要です。作成成功は HTTP 201 です。
  3. 返された id を保存し、poll_after_ms の後に同じ GET /v1/generations/{id} をポーリングします。processing、result_pending、submission_unknown はいずれも待機を続け、作成をやり直さないでください。
  4. 状態が succeeded になったら GET /v1/generations/{id}/content でダウンロードします。全体取得は HTTP 200、単一のバイト範囲は 206 です。

認証と冪等性

export OPENAIAV_API_KEY='oav_...'
export OPENAIAV_IDEMPOTENCY_KEY='openaiav-quickstart-4s-480p-001'

すべてのリクエストで Authorization: Bearer oav_... を送信し、キーはサーバー側に保管してください。作成には generation:create、ポーリングとダウンロードには generation:read が必要です。ネットワークの結果が不明な場合は元の Idempotency-Key を再利用してください。同じキーを異なるボディと組み合わせてはいけません。

Request headers

パラメータ必須説明
Authorizationstring必須すべての /v1 リクエストで Bearer oav_... を使用します。キーはサーバー側に保管してください。
Idempotency-Keystringタスク作成時は必須ネットワーク再試行では同じ値を再利用してください。同じ値と同じボディなら二重に作成・課金されることはありません。
Content-TypestringPOST では必須生成の作成は application/json を使用します。

エンドポイント一覧

MethodPathSuccessScope説明
GET/v1/models200valid API key現在販売中のモデル、料金、解像度、長さ、reference_modes を取得します。送信前にカタログと照らして対応状況を確認してください。
POST/v1/generations201generation:create非同期タスクを作成します。参考画像と referenceMode は同じ JSON リクエストで送信します。
GET/v1/generations/{id}200generation:read終了状態になるまで、poll_after_ms に従って同じタスクをポーリングします。
GET/v1/generations/{id}/content200 / 206generation:read成功後に出力をダウンロードします。単一のバイト範囲リクエストには 206 が返ります。

ステップ 1:モデルの対応状況を取得

モデルの対応状況をハードコードしないでください。reference_modes に記載されたモードのみを送信し、非対応の組み合わせは送信前に非表示または無効化してください。最小構成のサンプルは seedance-2.5 で 4 秒・480p・音声なしのリクエストを示しています。

curl --fail-with-body 'https://api.openaiav.com/v1/models' \
  --header "Authorization: Bearer $OPENAIAV_API_KEY"

最小構成の公開動画サンプル

サンプルには一連の流れがすべて含まれます:作成 → 同じタスクをポーリング → ダウンロード。 first_frame は参考画像 1 枚と adaptive を使用し、generateAudio=false で音声を要求しません。成功時のコードは 201、200、200/206 です。失敗時はまず HTTP を確認し、次に error.code をご確認ください。

# Keep both values in environment variables; do not paste secrets into shell history.
# Generate OPENAIAV_IDEMPOTENCY_KEY once for this create intent and keep it unchanged on every retry.
# Set it before the first create, then reuse the exact value after a lost response.
# 1. Create — success: HTTP 201. On failure, the response body contains error.code.
curl --fail-with-body --request POST 'https://api.openaiav.com/v1/generations' \
  --header "Authorization: Bearer $OPENAIAV_API_KEY" \
  --header "Idempotency-Key: $OPENAIAV_IDEMPOTENCY_KEY" \
  --header 'Content-Type: application/json' \
  --data '{
  "model": "seedance-2.5",
  "prompt": "女孩写完一封信,从乡间石屋走入清晨阳光",
  "resolution": "480p",
  "aspectRatio": "adaptive",
  "durationSeconds": 4,
  "referenceMode": "first_frame",
  "referenceImages": [
    "https://developers.openaiav.com/samples/seedance-letter-reference.webp"
  ],
  "generateAudio": false,
  "outputFormat": "mp4"
}'

# 2. Save the returned id as TASK_ID. Poll the same id — success: HTTP 200.
curl --fail-with-body 'https://api.openaiav.com/v1/generations/TASK_ID' \
  --header "Authorization: Bearer $OPENAIAV_API_KEY"

# Repeat step 2 after poll_after_ms until status is succeeded or failed.
# Never recreate a task whose status is submission_unknown.

# 3. After succeeded, download — success: HTTP 200 (or 206 with Range).
curl --fail-with-body --location 'https://api.openaiav.com/v1/generations/TASK_ID/content' \
  --header "Authorization: Bearer $OPENAIAV_API_KEY" \
  --output 'result.mp4'

リクエストパラメータ

パラメータ必須説明
modelstring必須GET /v1/models が返す model の値を使用します。最小構成の動画サンプルでは seedance-2.5 を使います。
promptstring必須1〜4000 文字。オムニリファレンスでは配列の順に @画像1@画像2 のように参照できます。
resolutionstring任意選択したモデルの resolutions に含まれている必要があります。最小構成の動画サンプルでは 480p を使います。
aspectRatiostring任意選択したモデルの aspect_ratios に含まれている必要があります。画像モデルにも適用されます。先頭フレームのタスクでモデルが要求する場合は adaptive を使用してください。
durationSecondsinteger任意動画リクエストは既定でモデルの最小値になります。明示する場合はカタログの duration_seconds の範囲内である必要があります。最小構成のサンプルでは 4 秒を使います。
referenceModefirst_frame | omni_reference参考画像を使う動画では必須reference_modes にそのモードが明示されている Seedance 動画モデルでのみ使用します。1 リクエストにつき 1 モードのみ選択できます。
referenceImagesstring[]referenceMode と一緒に指定公開された HTTPS 画像 URL。first_frame はちょうど 1 枚が必要です。omni_reference の上限は reference_images_max で確認してください。
inputImagesstring[]任意画像モデル専用の画像から画像への入力です。HTTPS または data:image/* を使用します。input_images_max を確認し、動画の参考モードとは併用しないでください。
generateAudioboolean任意音声に対応する動画モデルでは既定で true です。最小コストのサンプルでは明示的に false を送信します。現在のカタログに音声単体の料金項目はありません。
outputFormatmp4 | mov任意カタログの output_formats からのみ選択します。最小構成のサンプルでは mp4 を使います。

参考素材モード

first_frame

first_frame:参考画像が開始フレームとなり、構図を決定します。referenceImages はちょうど 1 件を送信します。aspectRatio はモデルの aspect_ratios から選び、カタログに adaptive がある場合はそれに固定されます(出力は参考画像に追従します)。\n\nfirst_last_frame:referenceImages をちょうど 2 件送信します。配列の順序が先頭フレーム、次に末尾フレームとなり、その間はモデルが補完します。2 枚の画像は同じ寸法である必要はありません。フレームモードは omni_reference と併用できません。

{
  "model": "seedance-2.5",
  "prompt": "女孩写完一封信,从乡间石屋走入清晨阳光",
  "resolution": "480p",
  "aspectRatio": "adaptive",
  "durationSeconds": 4,
  "referenceMode": "first_frame",
  "referenceImages": [
    "https://developers.openaiav.com/samples/seedance-letter-reference.webp"
  ],
  "generateAudio": false,
  "outputFormat": "mp4"
}

omni_reference

omni_reference:参考素材は開始フレームにはならず、被写体・スタイル・シーンの一貫性を保ちます。referenceImages に加えて、対応モデルでは referenceVideosreferenceAudios も受け付けます。種類ごとの上限は下表のとおりで、カタログが宣言していない種類は送信時に 400 となります。プロンプトでは種類ごとの順序で @画像1@動画1@音声1 のように指定します。

{
  "model": "seedance-2.5",
  "prompt": "@Image1 保持人物身份与服装一致,女孩从乡间石屋走入清晨阳光",
  "resolution": "480p",
  "aspectRatio": "16:9",
  "durationSeconds": 4,
  "referenceMode": "omni_reference",
  "referenceImages": [
    "https://developers.openaiav.com/samples/seedance-letter-reference.webp"
  ],
  "generateAudio": false,
  "outputFormat": "mp4"
}

Live compatibility

すべての動画モデルで統合方法は同一です:同じエンドポイント、同じフィールドで、モデルを変えるときは model を変更するだけです。差異はすべてカタログが宣言します。下表がそのカタログそのもので、モデルごとに対応する参考モードと各素材の受け入れ数を示します。カタログが宣言していない機能は送信時に明示的に拒否され、黙って無視されることはありません。

The catalog is not loaded. Call GET /v1/models first; do not submit a reference mode for a model without reference_modes.

First-frame details & last-frame relay

先頭フレームの詳細:first_frameomni_reference は排他で、1 リクエストにつきどちらか一方のみを選択します。オムニリファレンスでもプロンプトで参考画像を開始画面に寄せることはできますが、先頭フレームの厳密な一致が必要な場合は、その画像を first_frame モードで送信してください。Seedance 2.5 では先頭フレームのタスクはアスペクト比が adaptive に固定されます(出力は先頭フレームに追従)。末尾フレームの受け渡し:作成時に returnLastFrame: true を指定すると、成功したタスクは last_frame_url も返します(動画と同じサイズのウォーターマークなし PNG、24 時間保持)。その URL をそのまま次のリクエストの first_framereferenceImages に渡せば、事前登録なしで複数カットを連結できます。

ポーリングとダウンロード

終了状態は succeededfailed のみです。submission_unknown は突合中の状態です。元のタスク ID を保持してポーリングを続け、作成を再実行しないでください。成功後は、Open AIav 以外の場所に依存せず、認証付きの /content パスをご利用ください。結果は 24 時間保持されます(詳細レスポンスに output_expires_at が含まれます。期限切れのダウンロードは 410 OUTPUT_EXPIRED を返すため、早めに保存してください)。

StatusTerminalAction
processingNo受理されました。poll_after_ms の後に再度ポーリングしてください。
result_pendingNo精算に向けて出力を確定中です。同じタスクのポーリングを続けてください。
submission_unknownNo結果を突合中です。作成を再実行しないでください。元のタスク ID を保持してポーリングしてください。
succeededYes成功しました。/content で出力をダウンロードしてください。
failedYes確定的に失敗し、予約額は返金されました。error_code をご確認ください。

廃止エンドポイントからの移行

旧来の /v1/assets/v1/assets/content/v1/assets/{id}/v1/asset-groups/v1/asset-groups/{id} は廃止されました。対応する旧スコープを持つ有効なキーでも呼び出せません。

エラーコード一覧

Full reference: HTTP status, code, meaning, suggested handling, and the SDK error class. This table shares its data source with the SDK error map; unknown new codes fall back by HTTP status in the SDK.

HTTPCode意味Suggested handlingSDK
401UNAUTHENTICATEDMissing or unrecognized API key.Send Authorization: Bearer oav_…; keep the key server-side.AuthenticationError
401INVALID_API_KEYThe API key is invalid or revoked.Check the key in the console; rotate to mint a new one if needed.AuthenticationError
403INSUFFICIENT_SCOPEThe key lacks the scope this operation needs.Creation needs generation:create; polling and download need generation:read.PermissionError
429RATE_LIMITEDRequests exceeded the key rate limit.Back off per Retry-After / retryAfterSeconds; the SDK handles this automatically.RateLimitError
400IDEMPOTENCY_KEY_REQUIREDCreation requires an Idempotency-Key header.Generate a unique key per new request and reuse it on retries. The SDK auto-generates one.InvalidRequestError
409IDEMPOTENCY_KEY_CONFLICTThe same idempotency key was used with a different body.Use a fresh key for different parameters; keep key and body identical on retries.InvalidRequestError
400MODEL_NOT_FOUNDUnknown model id.Use ids from GET /v1/models (e.g. seedance-2.5-oa).InvalidRequestError
400INVALID_PROMPTThe prompt is empty or too long.Prompts must be 1–4000 characters.InvalidRequestError
400INVALID_DURATIONdurationSeconds is outside the model range.Use an integer within the catalog range, or -1 when auto duration is supported.InvalidRequestError
400INVALID_RESOLUTIONThe resolution is not supported by the model.Pick a value from the catalog resolutions.InvalidRequestError
400INVALID_ASPECT_RATIOThe aspect ratio is not supported by the model.Pick from catalog aspect_ratios; first_frame often locks adaptive.InvalidRequestError
400INVALID_REFERENCE_IMAGESreferenceImages must be an array of public HTTPS URLs.Provide https:// image URLs readable for the task lifetime.InvalidRequestError
400INVALID_REFERENCE_IMAGEA reference image entry is not a valid URL.The message carries the index (referenceImages[i]); fix that entry.InvalidRequestError
400REFERENCE_IMAGE_URL_NOT_HTTPSA reference image URL is not public HTTPS.http, private-network and data URLs are rejected; host the image publicly over HTTPS.InvalidRequestError
400REFERENCE_MODE_REQUIRES_IMAGESreferenceMode was set without reference images.Provide referenceMode and referenceImages together.InvalidRequestError
400REFERENCE_MODE_NOT_SUPPORTEDThe model does not support the requested reference mode.Choose first_frame / omni_reference per the catalog reference_modes.InvalidRequestError
400FIRST_FRAME_REQUIRES_ONE_IMAGEfirst_frame takes exactly one reference image.Submit exactly one image; use omni_reference for multiple.InvalidRequestError
400TOO_MANY_REFERENCESReference image count exceeds the catalog limit.See reference_images_max in the catalog.InvalidRequestError
400INVALID_INPUT_IMAGESinputImages must be an array.Each item is an HTTPS URL or data:image/* base64.InvalidRequestError
400INVALID_INPUT_IMAGEAn input image entry is malformed.Each entry must be an HTTPS URL or data:image/* base64; the message carries the index.InvalidRequestError
400INPUT_IMAGE_TOO_LARGEAn embedded image exceeds 10 MB.Compress it or switch to a public HTTPS URL.InvalidRequestError
400IMAGE_INPUT_NOT_SUPPORTEDThe model does not accept image input.Only image models with input_images_max>0 accept inputImages.InvalidRequestError
400TOO_MANY_INPUT_IMAGESToo many input images.See input_images_max in the catalog.InvalidRequestError
400INSUFFICIENT_BALANCEBalance is insufficient to reserve this task.Redeem a top-up card on the Billing page, then retry.InvalidRequestError
400LEGACY_ASSET_REFERENCE_RETIREDAsset-id references are retired.Submit referenceMode + referenceImages (public HTTPS) in the same request.InvalidRequestError
404NOT_FOUNDThe task does not exist or belongs to another account.Confirm the task id and the key belong to the same account.InvalidRequestError
409OUTPUT_NOT_READYThe output is not ready yet.Keep polling the task per poll_after_ms until terminal.InvalidRequestError
410OUTPUT_EXPIREDThe download window (24h after success) has closed.Save outputs promptly; regenerate after expiry. Use output_expires_at for countdowns.OutputExpiredError

Console-session-only codes

HTTPCode意味Suggested handling
400REFERENCE_UPLOAD_NOT_FOUNDThe upload reference is missing, expired, or owned by another account.Re-upload in the Playground and run again (uploads are short-lived).
429UPLOAD_QUOTA_EXCEEDEDToo many unused uploads.Run a task to consume uploads, or wait for them to expire.
429WEBHOOK_ENDPOINT_LIMITWebhook endpoint limit reached.Delete or disable an unused endpoint.
400INVALID_WEBHOOK_URLThe callback URL is not publicly reachable HTTPS.Use a public HTTPS address; private/loopback hosts are rejected.