Video with sound guided by reference images and audio, 2 to 30 seconds.
キーはrsw_で始まり、作成時に一度だけ表示されます。キーはサーバー側に置き、コードには環境変数RAWSWITCH_API_KEYとして渡してください。
export RAWSWITCH_API_KEY="rsw_live_…"すべてのモデルが同じエンドポイントで応答します。本文は共通の枠です。modelでモデルを選び、inputにそのモデル固有の入力を入れます。webhook・route・tagsは任意です。
curl -X POST https://rawswitch.ai/v1/requests \
-H "Authorization: Bearer $RAWSWITCH_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "alibaba/wan-3.0-reference-to-video",
"input": {
"prompt": "The subject in Image 1 walks along the shore",
"reference_image_urls": [
"https://files.rawswitch.example/samples/person-front.jpg"
],
"resolution": "720p",
"duration": 5
}
}'リクエストは受け付けられ、キューに入ります。IDと、状態を追うためのURLが返ります。
{
"id": "req_01JDF3K8Q2",
"status": "queued",
"urls": {
"self": "https://rawswitch.ai/v1/requests/req_01JDF3K8Q2",
"events": "https://rawswitch.ai/v1/requests/req_01JDF3K8Q2/events",
"cancel": "https://rawswitch.ai/v1/requests/req_01JDF3K8Q2/cancel"
}
}キーはAuthorizationヘッダーでBearerトークンとして送ります。有効なキーがない呼び出しはerror.type = "authentication_error"で失敗します。
Authorization: Bearer $RAWSWITCH_API_KEYリクエストはqueued → running → succeeded・failed・canceledの順に進みます。短い処理なら、送信時に待つよう指定できます。制限時間内に到達した状態をそのまま返します。
curl -X POST "https://rawswitch.ai/v1/requests?wait=60" \
-H "Authorization: Bearer $RAWSWITCH_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: 6b1f0c1e-2f0a-4c57-9a55-1d2f6f0b7c11" \
-d @body.jsonIdempotency-Keyを送り、再試行するときは同じ値を使ってください。ないと、再試行したリクエストがもう一度実行され、二重に課金されることがあります。1回の呼び出しで状態を取得でき、完了していれば出力も受け取れます。
curl https://rawswitch.ai/v1/requests/req_01JDF3K8Q2 \
-H "Authorization: Bearer $RAWSWITCH_API_KEY"ポーリングを繰り返す代わりに、Server-Sent Events(SSE)でリクエストをリアルタイムに追えます。
curl -N https://rawswitch.ai/v1/requests/req_01JDF3K8Q2/events \
-H "Authorization: Bearer $RAWSWITCH_API_KEY"
event: status
data: {"status":"running"}
event: status
data: {"status":"succeeded"}served_byは出力を生成した経路の名前、attemptsは試行したすべての経路です。ルーティングについて隠すものはありません。
{
"id": "req_01JDF3K8Q2",
"model": "alibaba/wan-3.0-reference-to-video",
"status": "succeeded",
"output": {
"videos": [
{
"url": "https://files.rawswitch.example/req_01JDF3/wan-3.0-reference-to-video-0.mp4",
"content_type": "video/mp4",
"bytes": 4821933,
"width": 1280,
"height": 720,
"duration_seconds": 5
}
]
},
"served_by": "partner/gateway",
"attempts": [
{
"route": "partner/gateway",
"status": "succeeded"
}
],
"usage": {
"unit": "video",
"quantity": 1
},
"timings": {
"queued_ms": 38,
"running_ms": 4120
}
}curl -X POST https://rawswitch.ai/v1/requests/req_01JDF3K8Q2/cancel \
-H "Authorization: Bearer $RAWSWITCH_API_KEY"入力はURLで受け取ります。公開URLはそのまま使えます。手元のファイルはアップロード用のURLを取得してそこへ送り、返されたfile_urlを渡してください。
# 1) ask for an upload URL
curl -X POST https://rawswitch.ai/v1/files \
-H "Authorization: Bearer $RAWSWITCH_API_KEY" \
-H "Content-Type: application/json" \
-d '{"filename": "jacket-front.jpg", "content_type": "image/jpeg"}'
# 2) send the bytes to upload_url, then use file_url in your input
curl -X PUT "$UPLOAD_URL" -H "Content-Type: image/jpeg" --data-binary @jacket-front.jpgリクエストにwebhookを入れると、Rawswitchが完了したリクエストをそのURLへPOSTします。配信にはStandard Webhooks方式の署名が付き、受信側が失敗すると再送します。
{
"model": "alibaba/wan-3.0-reference-to-video",
"input": {},
"webhook": {
"url": "https://your-app.example/hooks/rawswitch"
}
}| フィールド | 型 | 必須 | 説明 |
|---|---|---|---|
| prompt | string | — | How to use the references. Refer to them by position, for example "the subject in Image 1". |
| reference_image_urls | string[] (URL) | — | Up to ten images of people, objects or places to keep.最大10件。 |
| reference_audio_urls | string[] (URL) | — | Up to five audio clips, 15 seconds in total.公開URLのみ(音声ファイルのアップロードには未対応)。最大5件。 |
| resolution | enum | — | Output resolution.480p, 720p, 1080pのいずれか。デフォルトは"1080p"。 |
| aspect_ratio | enum | — | Shape of the output video. "adaptive" lets the model choose.adaptive, 16:9, 4:3, 1:1, 3:4, 9:16のいずれか。デフォルトは"adaptive"。 |
| duration | integer | — | Length in seconds, 2 to 30.デフォルトは5。 |
| generate_audio | boolean | — | Generate sound with the video.デフォルトはtrue。 |
| enable_prompt_expansion | boolean | — | Let the model rewrite the prompt before generating. Turning it off is faster but can lower quality.デフォルトはtrue。 |
| enable_thinking | boolean | — | Let the model reason about the prompt before generating.デフォルトはfalse。 |
| seed | integer | — | モデルが対応していれば、同じシードと同じ入力から同じ画像が得られます。 |
生成された動画はoutput.videosに入ります。動画ごとにurl・content_type・bytesがあり、ファイルから読み取れる場合はwidth・height・duration_secondsも入ります。
| フィールド | 型 | 説明 |
|---|---|---|
| videos | array | Generated videos. Each item has url, content_type and bytes, plus width, height and duration_seconds when they can be read from the file. |
{
"videos": [
{
"url": "https://files.rawswitch.example/req_01JDF3/wan-3.0-reference-to-video-0.mp4",
"content_type": "video/mp4",
"bytes": 4821933,
"width": 1280,
"height": 720,
"duration_seconds": 5
}
]
}このモデルの経路:
partner/gateway — 提携ゲートウェイ (プライマリ)コーディングエージェントに貼り付けてください。エンドポイント、スキーマ、このモデルを安全に呼び出すためのルールが入っています。
You are adding the Rawswitch model `alibaba/wan-3.0-reference-to-video` (Wan 3.0 Reference to Video — reference to video) to this codebase.
## What it does
Video with sound guided by reference images and audio, 2 to 30 seconds.
Price: $0.105 per second (720p).
## API
- Base URL: https://rawswitch.ai
- Auth: header `Authorization: Bearer <key>`. Read the key from the `RAWSWITCH_API_KEY` environment variable. Never hard-code it and never send it to the browser.
- Submit: `POST /v1/requests` with JSON `{ model, input, webhook?, route?, tags? }`. The response is `{ id, status: "queued", urls }`.
- Result: `GET /v1/requests/{id}` until `status` is `succeeded`, `failed` or `canceled`. One call returns status and output together.
- Short jobs: `POST /v1/requests?wait=60` waits up to 60 seconds and returns whatever state the request reached.
- Live status: `GET /v1/requests/{id}/events` is a server-sent event stream.
- Cancel: `POST /v1/requests/{id}/cancel`.
- Files: `POST /v1/files` returns `{ upload_url, file_url }`. PUT the bytes to `upload_url`, then pass `file_url` in the input.
## Request
```json
{
"model": "alibaba/wan-3.0-reference-to-video",
"input": {
"prompt": "The subject in Image 1 walks along the shore",
"reference_image_urls": [
"https://files.rawswitch.example/samples/person-front.jpg"
],
"resolution": "720p",
"duration": 5
}
}
```
## Input fields
- `prompt` (string): How to use the references. Refer to them by position, for example "the subject in Image 1".
- `reference_image_urls` (array of URLs, at most 10 items): Up to ten images of people, objects or places to keep.
- `reference_audio_urls` (array of URLs, public URL only, audio cannot be uploaded, at most 5 items): Up to five audio clips, 15 seconds in total.
- `resolution` (string, one of "480p", "720p", "1080p", default "1080p"): Output resolution.
- `aspect_ratio` (string, one of "adaptive", "16:9", "4:3", "1:1", "3:4", "9:16", default "adaptive"): Shape of the output video. "adaptive" lets the model choose.
- `duration` (integer, range 2–30, default 5): Length in seconds, 2 to 30.
- `generate_audio` (boolean, default true): Generate sound with the video.
- `enable_prompt_expansion` (boolean, default true): Let the model rewrite the prompt before generating. Turning it off is faster but can lower quality.
- `enable_thinking` (boolean, default false): Let the model reason about the prompt before generating.
- `seed` (integer, range 0–2147483647): Same seed and same input give the same image where the model supports it.
## Output
- `videos` (array): Generated videos. Each item has url, content_type and bytes, plus width, height and duration_seconds when they can be read from the file.
```json
{
"videos": [
{
"url": "https://files.rawswitch.example/req_01JDF3/wan-3.0-reference-to-video-0.mp4",
"content_type": "video/mp4",
"bytes": 4821933,
"width": 1280,
"height": 720,
"duration_seconds": 5
}
]
}
```
## Rules to follow
- Send an `Idempotency-Key` header (a UUID per logical job) on every submit, and reuse the same key when you retry. A retry without it can run and bill twice.
- Do not poll faster than once per second. Prefer `?wait=`, the event stream or a webhook over tight polling.
- On `failed`, branch on `error.type`; show `error.message` to the user. Do not switch to another model yourself: Rawswitch already retries the same model on another path, and a different model is a product decision.
- Log `id`, `served_by` and `attempts` with your own request log. They say which path served the call.
- Output file URLs are for download. Copy the files into your own storage if you need to keep them.
- If you receive webhooks, verify the Standard Webhooks signature before trusting the body.
## Paths behind this model
- `partner/gateway` — Partner gateway (primary)
Write a small typed function that submits a request, waits for the result and returns the output. Add one test that mocks the HTTP calls.例のベースURLhttps://rawswitch.aiは、ドメインが決まるまでの仮の値です。