Rawswitch
  • ルーティング
  • ドキュメント
ENKOJAZH
お問い合わせAPIキーを取得

探す

  • すべてのモデル
  • 画像
  • 動画

経路

  • 提供元の直接API
  • 提携ゲートウェイ
  • 自社NPU
おすすめ
自社NPUで読み取る商品属性

製品

  • ルーティングAPI
  • モデル
  • プレイグラウンド
  • 共有経路のその先

モデル

  • 画像
  • 動画
  • Nano Banana 2.1
  • GPT Image 2.6
  • Kling 4.0
  • Product Attributes
  • すべてのモデル

経路

  • 提供元の直接API
  • 提携ゲートウェイ
  • 自社NPU
  • 自社キーの持ち込み

開発者

  • APIリファレンス
  • エージェントプロンプト
  • llms.txt
  • Webhook

リソース

  • ドキュメント
  • リクエストの流れ
  • ファイル

会社

  • お問い合わせ
  • APIキーを取得
キーは1つすべてのモデル
まずキューへリクエストを破棄しない
同じモデルでのみ切り替え黙って差し替えない
見えるルーティングserved_by + attempts
署名付きWebhookStandard Webhooks
リクエストごとの原価記録
© 2026 Rawswitch
利用規約プライバシーポリシー
プレビュー版

Kling 4.0 Video Edit

Kling (Kuaishou)動画 → 動画提供中
スキーマAPIドキュメント
kling/kling-4.0-video-edit
動画生成画像 → 動画参照 → 動画動画編集
$0.14805 / 秒 · 1080p, input + output seconds
商用利用可提供元の規約
プレイグラウンドAPI

1. APIの呼び出し

  • APIキーを取得
  • リクエストを送信

2. 認証

  • APIキー

3. キュー

  • リクエストの流れ
  • リクエストの状態を取得
  • 状態をストリームで受け取る
  • 結果を取得
  • リクエストをキャンセル

4. ファイル

  • ファイルのアップロード

5. Webhook

  • 署名付きWebhook

6. スキーマ

  • 入力
  • 出力

7. エージェント

  • エージェントプロンプト

概要

Edits a 3–30 second video from a written instruction at 720p, 1080p or 4k.

1. APIの呼び出し

APIキーを取得#

キーは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": "kling/kling-4.0-video-edit",
    "input": {
      "prompt": "Make it snow in @Video1, keep the people and the camera move",
      "video_url": "https://files.rawswitch.example/samples/walk.mp4",
      "resolution": "1080p"
    }
  }'

リクエストは受け付けられ、キューに入ります。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"
  }
}

2. 認証

APIキー#

キーはAuthorizationヘッダーでBearerトークンとして送ります。有効なキーがない呼び出しはerror.type = "authentication_error"で失敗します。

Authorization: Bearer $RAWSWITCH_API_KEY
キーを入れたままブラウザからAPIを呼び出さないでください。間に小さなサーバー側のルートを置いてください。

3. キュー

リクエストの流れ#

リクエストは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.json
送信のたびにIdempotency-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": "kling/kling-4.0-video-edit",
  "status": "succeeded",
  "output": {
    "videos": [
      {
        "url": "https://files.rawswitch.example/req_01JDF3/kling-4.0-video-edit-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"

4. ファイル

ファイルのアップロード#

入力は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

5. Webhook

署名付きWebhook#

リクエストにwebhookを入れると、Rawswitchが完了したリクエストをそのURLへPOSTします。配信にはStandard Webhooks方式の署名が付き、受信側が失敗すると再送します。

{
  "model": "kling/kling-4.0-video-edit",
  "input": {},
  "webhook": {
    "url": "https://your-app.example/hooks/rawswitch"
  }
}

6. スキーマ

入力#

フィールド型必須説明
promptstringはいThe change to make. Refer to the video as @Video1 and to images as @Image1, @Image2, …
video_urlstring (URL)はいThe video to edit: 3–30 seconds, 700–4553 px per side, aspect ratio between 0.4 and 2.5, 24–60 fps, up to 300 MB.
image_urlsstring[] (URL)—Up to 10 images to draw subjects or style from (@Image1, @Image2, …).最大10件。
image_urlstring (URL)—Optional first frame. Counts toward the image limit.
middle_image_urlsstring[] (URL)—Up to 8 frames to pass through between the start and the end, in order. They count toward the image limit.最大8件。
end_image_urlstring (URL)—Optional last frame. The video moves from the start image to this one.
keep_audioboolean—Keep the sound of the input video instead of generating new sound.デフォルトはfalse。
resolutionenum—Output resolution. Higher resolutions cost more per second.720p, 1080p, 4kのいずれか。デフォルトは"1080p"。
hdrboolean—10-bit HDR instead of SDR. Only at 1080p and 4k, billed per second on top of the base price.デフォルトはfalse。
aspect_ratioenum—Shape of the video frame. Leave empty to keep the shape of the input video; "auto" adapts it to the inputs.auto, 16:9, 9:16, 1:1, 4:3, 3:4, 21:9のいずれか。

出力#

生成された動画はoutput.videosに入ります。動画ごとにurl・content_type・bytesがあり、ファイルから読み取れる場合はwidth・height・duration_secondsも入ります。

フィールド型説明
videosarrayGenerated 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/kling-4.0-video-edit-0.mp4",
      "content_type": "video/mp4",
      "bytes": 4821933,
      "width": 1280,
      "height": 720,
      "duration_seconds": 5
    }
  ]
}

このモデルの経路:

  • partner/gateway — 提携ゲートウェイ (プライマリ)

7. エージェント

エージェントプロンプト#

コーディングエージェントに貼り付けてください。エンドポイント、スキーマ、このモデルを安全に呼び出すためのルールが入っています。

エージェントプロンプト · kling/kling-4.0-video-edit
You are adding the Rawswitch model `kling/kling-4.0-video-edit` (Kling 4.0 Video Edit — video edit) to this codebase.

## What it does
Edits a 3–30 second video from a written instruction at 720p, 1080p or 4k.
Price: $0.14805 per second (1080p, input + output seconds).

## 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": "kling/kling-4.0-video-edit",
  "input": {
    "prompt": "Make it snow in @Video1, keep the people and the camera move",
    "video_url": "https://files.rawswitch.example/samples/walk.mp4",
    "resolution": "1080p"
  }
}
```

## Input fields
- `prompt` (string, required): The change to make. Refer to the video as @Video1 and to images as @Image1, @Image2, …
- `video_url` (URL, required): The video to edit: 3–30 seconds, 700–4553 px per side, aspect ratio between 0.4 and 2.5, 24–60 fps, up to 300 MB.
- `image_urls` (array of URLs, at most 10 items): Up to 10 images to draw subjects or style from (@Image1, @Image2, …).
- `image_url` (URL): Optional first frame. Counts toward the image limit.
- `middle_image_urls` (array of URLs, at most 8 items): Up to 8 frames to pass through between the start and the end, in order. They count toward the image limit.
- `end_image_url` (URL): Optional last frame. The video moves from the start image to this one.
- `keep_audio` (boolean, default false): Keep the sound of the input video instead of generating new sound.
- `resolution` (string, one of "720p", "1080p", "4k", default "1080p"): Output resolution. Higher resolutions cost more per second.
- `hdr` (boolean, default false): 10-bit HDR instead of SDR. Only at 1080p and 4k, billed per second on top of the base price.
- `aspect_ratio` (string, one of "auto", "16:9", "9:16", "1:1", "4:3", "3:4", "21:9"): Shape of the video frame. Leave empty to keep the shape of the input video; "auto" adapts it to the inputs.

## 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/kling-4.0-video-edit-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は、ドメインが決まるまでの仮の値です。