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
  • 웹훅

자료

  • 문서
  • 요청이 처리되는 순서
  • 파일

회사

  • 문의
  • API 키 받기
키 하나모든 모델
대기열 먼저버려지는 요청 없음
같은 모델로만 전환몰래 바꾸지 않음
보이는 라우팅served_by + attempts
서명된 웹훅Standard Webhooks
요청별 원가기록됨
© 2026 Rawswitch
이용약관개인정보 처리방침
미리보기 빌드

Kling 4.0 Reference to Video

Kling (Kuaishou)영상 → 영상운영 중
스키마API 문서
kling/kling-4.0-reference-to-video
영상 생성이미지 → 영상참조 → 영상영상 편집
$0.24675 / 초 · 1080p
상업적 이용 가능공급사 약관
플레이그라운드API

1. API 호출

  • API 키 받기
  • 요청 제출

2. 인증

  • API 키

3. 대기열

  • 요청이 처리되는 순서
  • 요청 상태 조회
  • 상태 스트림
  • 결과 받기
  • 요청 취소

4. 파일

  • 파일 올리기

5. 웹훅

  • 서명된 웹훅

6. 스키마

  • 입력
  • 출력

7. 에이전트

  • 에이전트 프롬프트

소개

Generates a 3–30 second video guided by reference images 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-reference-to-video",
    "input": {
      "prompt": "The person from @Image1 walks through a sunlit market holding the mug from @Image2",
      "image_urls": [
        "https://files.rawswitch.example/samples/model-front.jpg",
        "https://files.rawswitch.example/samples/mug.jpg"
      ],
      "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"
  }
}

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 를 보내고, 다시 시도할 때 같은 값을 쓰세요. 없으면 다시 시도한 요청이 한 번 더 실행되어 두 번 과금될 수 있습니다.

요청 상태 조회#

한 번의 호출로 상태를 받고, 끝났으면 결과도 함께 받습니다.

curl https://rawswitch.ai/v1/requests/req_01JDF3K8Q2 \
  -H "Authorization: Bearer $RAWSWITCH_API_KEY"

상태 스트림#

조회를 반복하는 대신 서버 전송 이벤트(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-reference-to-video",
  "status": "succeeded",
  "output": {
    "videos": [
      {
        "url": "https://files.rawswitch.example/req_01JDF3/kling-4.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"

4. 파일

파일 올리기#

입력은 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 을 넣으면 Rawswitch 가 끝난 요청을 그 URL 로 보냅니다. 전송에는 Standard Webhooks 방식의 서명이 붙고, 받는 쪽이 실패하면 다시 보냅니다.

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

6. 스키마

입력#

항목자료형필수설명
promptstring예What happens in the video. Refer to reference images as @Image1, @Image2, …
image_urlsstring[] (URL)—Up to 10 images whose subjects or look the video should keep, in order (@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.
durationinteger—Length of the video in seconds (3–30). Billed per second. 기본값 5.
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. "auto" follows the references. auto, 16:9, 9:16, 1:1, 4:3, 3:4, 21:9 중 하나. 기본값 "16: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-reference-to-video-0.mp4",
      "content_type": "video/mp4",
      "bytes": 4821933,
      "width": 1280,
      "height": 720,
      "duration_seconds": 5
    }
  ]
}

이 모델 뒤의 경로:

  • partner/gateway — 제휴 게이트웨이 (기본)

7. 에이전트

에이전트 프롬프트#

코딩 에이전트에 붙여 넣으세요. 엔드포인트 · 스키마 · 이 모델을 안전하게 부르는 규칙이 들어 있습니다.

에이전트 프롬프트 · kling/kling-4.0-reference-to-video
You are adding the Rawswitch model `kling/kling-4.0-reference-to-video` (Kling 4.0 Reference to Video — reference to video) to this codebase.

## What it does
Generates a 3–30 second video guided by reference images at 720p, 1080p or 4k.
Price: $0.24675 per second (1080p).

## 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-reference-to-video",
  "input": {
    "prompt": "The person from @Image1 walks through a sunlit market holding the mug from @Image2",
    "image_urls": [
      "https://files.rawswitch.example/samples/model-front.jpg",
      "https://files.rawswitch.example/samples/mug.jpg"
    ],
    "duration": 5
  }
}
```

## Input fields
- `prompt` (string, required): What happens in the video. Refer to reference images as @Image1, @Image2, …
- `image_urls` (array of URLs, at most 10 items): Up to 10 images whose subjects or look the video should keep, in order (@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.
- `duration` (integer, range 3–30, default 5): Length of the video in seconds (3–30). Billed per second.
- `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", default "16:9"): Shape of the video frame. "auto" follows the references.

## 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-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.

예시의 기본 주소 https://rawswitch.ai 는 도메인을 정하기 전까지 쓰는 임시 값입니다.