公式 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 ステップで統合
- サーバー側の環境変数 OPENAIAV_API_KEY を使って https://api.openaiav.com/v1/models を呼び出し、現在のモデルキー、料金、reference_modes を取得します。
- POST /v1/generations に prompt、referenceMode、referenceImages を送信します。参考画像は公開 HTTPS URL で、事前登録は不要です。作成成功は HTTP 201 です。
- 返された id を保存し、poll_after_ms の後に同じ GET /v1/generations/{id} をポーリングします。processing、result_pending、submission_unknown はいずれも待機を続け、作成をやり直さないでください。
- 状態が 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
| パラメータ | 型 | 必須 | 説明 |
|---|---|---|---|
| Authorization | string | 必須 | すべての /v1 リクエストで Bearer oav_... を使用します。キーはサーバー側に保管してください。 |
| Idempotency-Key | string | タスク作成時は必須 | ネットワーク再試行では同じ値を再利用してください。同じ値と同じボディなら二重に作成・課金されることはありません。 |
| Content-Type | string | POST では必須 | 生成の作成は application/json を使用します。 |
エンドポイント一覧
| Method | Path | Success | Scope | 説明 |
|---|---|---|---|---|
| GET | /v1/models | 200 | valid API key | 現在販売中のモデル、料金、解像度、長さ、reference_modes を取得します。送信前にカタログと照らして対応状況を確認してください。 |
| POST | /v1/generations | 201 | generation:create | 非同期タスクを作成します。参考画像と referenceMode は同じ JSON リクエストで送信します。 |
| GET | /v1/generations/{id} | 200 | generation:read | 終了状態になるまで、poll_after_ms に従って同じタスクをポーリングします。 |
| GET | /v1/generations/{id}/content | 200 / 206 | generation: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'リクエストパラメータ
| パラメータ | 型 | 必須 | 説明 |
|---|---|---|---|
| model | string | 必須 | GET /v1/models が返す model の値を使用します。最小構成の動画サンプルでは seedance-2.5 を使います。 |
| prompt | string | 必須 | 1〜4000 文字。オムニリファレンスでは配列の順に @画像1、@画像2 のように参照できます。 |
| resolution | string | 任意 | 選択したモデルの resolutions に含まれている必要があります。最小構成の動画サンプルでは 480p を使います。 |
| aspectRatio | string | 任意 | 選択したモデルの aspect_ratios に含まれている必要があります。画像モデルにも適用されます。先頭フレームのタスクでモデルが要求する場合は adaptive を使用してください。 |
| durationSeconds | integer | 任意 | 動画リクエストは既定でモデルの最小値になります。明示する場合はカタログの duration_seconds の範囲内である必要があります。最小構成のサンプルでは 4 秒を使います。 |
| referenceMode | first_frame | omni_reference | 参考画像を使う動画では必須 | reference_modes にそのモードが明示されている Seedance 動画モデルでのみ使用します。1 リクエストにつき 1 モードのみ選択できます。 |
| referenceImages | string[] | referenceMode と一緒に指定 | 公開された HTTPS 画像 URL。first_frame はちょうど 1 枚が必要です。omni_reference の上限は reference_images_max で確認してください。 |
| inputImages | string[] | 任意 | 画像モデル専用の画像から画像への入力です。HTTPS または data:image/* を使用します。input_images_max を確認し、動画の参考モードとは併用しないでください。 |
| generateAudio | boolean | 任意 | 音声に対応する動画モデルでは既定で true です。最小コストのサンプルでは明示的に false を送信します。現在のカタログに音声単体の料金項目はありません。 |
| outputFormat | mp4 | 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 に加えて、対応モデルでは referenceVideos と referenceAudios も受け付けます。種類ごとの上限は下表のとおりで、カタログが宣言していない種類は送信時に 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 を変更するだけです。差異はすべてカタログが宣言します。下表がそのカタログそのもので、モデルごとに対応する参考モードと各素材の受け入れ数を示します。カタログが宣言していない機能は送信時に明示的に拒否され、黙って無視されることはありません。
First-frame details & last-frame relay
先頭フレームの詳細:first_frame と omni_reference は排他で、1 リクエストにつきどちらか一方のみを選択します。オムニリファレンスでもプロンプトで参考画像を開始画面に寄せることはできますが、先頭フレームの厳密な一致が必要な場合は、その画像を first_frame モードで送信してください。Seedance 2.5 では先頭フレームのタスクはアスペクト比が adaptive に固定されます(出力は先頭フレームに追従)。末尾フレームの受け渡し:作成時に returnLastFrame: true を指定すると、成功したタスクは last_frame_url も返します(動画と同じサイズのウォーターマークなし PNG、24 時間保持)。その URL をそのまま次のリクエストの first_frame の referenceImages に渡せば、事前登録なしで複数カットを連結できます。
ポーリングとダウンロード
終了状態は succeeded と failed のみです。submission_unknown は突合中の状態です。元のタスク ID を保持してポーリングを続け、作成を再実行しないでください。成功後は、Open AIav 以外の場所に依存せず、認証付きの /content パスをご利用ください。結果は 24 時間保持されます(詳細レスポンスに output_expires_at が含まれます。期限切れのダウンロードは 410 OUTPUT_EXPIRED を返すため、早めに保存してください)。
| Status | Terminal | Action |
|---|---|---|
| processing | No | 受理されました。poll_after_ms の後に再度ポーリングしてください。 |
| result_pending | No | 精算に向けて出力を確定中です。同じタスクのポーリングを続けてください。 |
| submission_unknown | No | 結果を突合中です。作成を再実行しないでください。元のタスク ID を保持してポーリングしてください。 |
| succeeded | Yes | 成功しました。/content で出力をダウンロードしてください。 |
| failed | Yes | 確定的に失敗し、予約額は返金されました。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.
| HTTP | Code | 意味 | Suggested handling | SDK |
|---|---|---|---|---|
| 401 | UNAUTHENTICATED | Missing or unrecognized API key. | Send Authorization: Bearer oav_…; keep the key server-side. | AuthenticationError |
| 401 | INVALID_API_KEY | The API key is invalid or revoked. | Check the key in the console; rotate to mint a new one if needed. | AuthenticationError |
| 403 | INSUFFICIENT_SCOPE | The key lacks the scope this operation needs. | Creation needs generation:create; polling and download need generation:read. | PermissionError |
| 429 | RATE_LIMITED | Requests exceeded the key rate limit. | Back off per Retry-After / retryAfterSeconds; the SDK handles this automatically. | RateLimitError |
| 400 | IDEMPOTENCY_KEY_REQUIRED | Creation requires an Idempotency-Key header. | Generate a unique key per new request and reuse it on retries. The SDK auto-generates one. | InvalidRequestError |
| 409 | IDEMPOTENCY_KEY_CONFLICT | The same idempotency key was used with a different body. | Use a fresh key for different parameters; keep key and body identical on retries. | InvalidRequestError |
| 400 | MODEL_NOT_FOUND | Unknown model id. | Use ids from GET /v1/models (e.g. seedance-2.5-oa). | InvalidRequestError |
| 400 | INVALID_PROMPT | The prompt is empty or too long. | Prompts must be 1–4000 characters. | InvalidRequestError |
| 400 | INVALID_DURATION | durationSeconds is outside the model range. | Use an integer within the catalog range, or -1 when auto duration is supported. | InvalidRequestError |
| 400 | INVALID_RESOLUTION | The resolution is not supported by the model. | Pick a value from the catalog resolutions. | InvalidRequestError |
| 400 | INVALID_ASPECT_RATIO | The aspect ratio is not supported by the model. | Pick from catalog aspect_ratios; first_frame often locks adaptive. | InvalidRequestError |
| 400 | INVALID_REFERENCE_IMAGES | referenceImages must be an array of public HTTPS URLs. | Provide https:// image URLs readable for the task lifetime. | InvalidRequestError |
| 400 | INVALID_REFERENCE_IMAGE | A reference image entry is not a valid URL. | The message carries the index (referenceImages[i]); fix that entry. | InvalidRequestError |
| 400 | REFERENCE_IMAGE_URL_NOT_HTTPS | A reference image URL is not public HTTPS. | http, private-network and data URLs are rejected; host the image publicly over HTTPS. | InvalidRequestError |
| 400 | REFERENCE_MODE_REQUIRES_IMAGES | referenceMode was set without reference images. | Provide referenceMode and referenceImages together. | InvalidRequestError |
| 400 | REFERENCE_MODE_NOT_SUPPORTED | The model does not support the requested reference mode. | Choose first_frame / omni_reference per the catalog reference_modes. | InvalidRequestError |
| 400 | FIRST_FRAME_REQUIRES_ONE_IMAGE | first_frame takes exactly one reference image. | Submit exactly one image; use omni_reference for multiple. | InvalidRequestError |
| 400 | TOO_MANY_REFERENCES | Reference image count exceeds the catalog limit. | See reference_images_max in the catalog. | InvalidRequestError |
| 400 | INVALID_INPUT_IMAGES | inputImages must be an array. | Each item is an HTTPS URL or data:image/* base64. | InvalidRequestError |
| 400 | INVALID_INPUT_IMAGE | An input image entry is malformed. | Each entry must be an HTTPS URL or data:image/* base64; the message carries the index. | InvalidRequestError |
| 400 | INPUT_IMAGE_TOO_LARGE | An embedded image exceeds 10 MB. | Compress it or switch to a public HTTPS URL. | InvalidRequestError |
| 400 | IMAGE_INPUT_NOT_SUPPORTED | The model does not accept image input. | Only image models with input_images_max>0 accept inputImages. | InvalidRequestError |
| 400 | TOO_MANY_INPUT_IMAGES | Too many input images. | See input_images_max in the catalog. | InvalidRequestError |
| 400 | INSUFFICIENT_BALANCE | Balance is insufficient to reserve this task. | Redeem a top-up card on the Billing page, then retry. | InvalidRequestError |
| 400 | LEGACY_ASSET_REFERENCE_RETIRED | Asset-id references are retired. | Submit referenceMode + referenceImages (public HTTPS) in the same request. | InvalidRequestError |
| 404 | NOT_FOUND | The task does not exist or belongs to another account. | Confirm the task id and the key belong to the same account. | InvalidRequestError |
| 409 | OUTPUT_NOT_READY | The output is not ready yet. | Keep polling the task per poll_after_ms until terminal. | InvalidRequestError |
| 410 | OUTPUT_EXPIRED | The download window (24h after success) has closed. | Save outputs promptly; regenerate after expiry. Use output_expires_at for countdowns. | OutputExpiredError |
Console-session-only codes
| HTTP | Code | 意味 | Suggested handling |
|---|---|---|---|
| 400 | REFERENCE_UPLOAD_NOT_FOUND | The upload reference is missing, expired, or owned by another account. | Re-upload in the Playground and run again (uploads are short-lived). |
| 429 | UPLOAD_QUOTA_EXCEEDED | Too many unused uploads. | Run a task to consume uploads, or wait for them to expire. |
| 429 | WEBHOOK_ENDPOINT_LIMIT | Webhook endpoint limit reached. | Delete or disable an unused endpoint. |
| 400 | INVALID_WEBHOOK_URL | The callback URL is not publicly reachable HTTPS. | Use a public HTTPS address; private/loopback hosts are rejected. |