Night city street after rain, seen from a slow forward dolly shot at low height: wet asphalt reflecting colorful lights, light trails from passing cars, soft steam rising from a street grate, light drizzle. Generic modern architecture. No people, no readable text, signs, logos, license plates, flags or recognizable landmarks. Cinematic, realistic.
공통 비동기 API: 견적 → 생성 → 상태 확인 → 다운로드. 모델을 전환하고 지원하는 매개변수를 사용하세요.
개발자 빠른 시작
Kling API 키를 받고 첫 호출 실행하기
견적을 조회하고 작업을 생성한 다음, 상태를 확인해 완성된 영상을 다운로드하세요.생성 요청을 다시 시도할 때는 같은 멱등성 키를 사용하세요. 접수된 작업은 아직 처리 중입니다. 완료된 뒤에만 다운로드하세요.최소한의 예제입니다. 운영 환경에서는 재시작 후 이어서 처리할 수 있도록 Idempotency-Key와 작업 ID를 영구 저장하세요.
AI 에이전트 지침 보기
사용자 앱에 BetterToken 동영상 API를 연동하세요.
BETTERTOKEN_API_KEY는 환경 변수에서만 읽으세요. 코드에 넣거나 로그에 기록하거나 분석 서비스에 보내지 마세요.
기본 URL: https://bettertoken.ai/v1
모델: kling-3.0.
프롬프트: A rainy city street at night, slow forward camera move
아래 요청 JSON을 그대로 사용하고 선택한 모델의 지원 필드와 한도를 따르세요.
같은 요청으로 POST /videos/quote를 호출하면 잔액 예약 없이 예상 비용을 확인할 수 있습니다. 인증이 필요하며 공개 가격 엔드포인트가 아닙니다.
POST /videos 전에 새 Idempotency-Key와 정확한 요청 본문을 프로세스 밖에 영구 저장하세요. 재시작 후 저장 상태를 불러오거나 접수된 작업의 저장된 ID로 이어서 처리하세요. 응답이 불확실하면 같은 키와 본문을 재사용하세요. 타임아웃만으로 새 유료 작업을 만들지 마세요.
/videos에서 202로 접수되면(호환 경로는 200) id를 저장하고 5초마다 GET /videos/{id}를 조회하세요. queued, in_progress, completed, failed, canceled를 처리하세요. 전송 결과가 불확실한 작업은 stage=reconciliation인 in_progress 상태로 유지됩니다. 대체 작업을 만들지 마세요. 429에서는 Retry-After를 따르세요. 5초 간격으로 최대 360회 조회하며 네트워크 지연과 제한 대기로 전체 시간이 늘어날 수 있습니다. 조회를 멈출 때도 ID를 보관하세요. 조회 중단은 작업 취소나 재생성이 아닙니다.
completed 후 소유자의 허용된 API 키로 GET /videos/{id}/content를 요청하세요. 만료된 파일은 410 video_artifact_expired를 반환합니다. 콘텐츠는 비공개입니다. 다운로드 실패나 만료는 생성 실패와 별도로 처리하세요.
최종 청구는 결제 내역에서 확인하세요. 생성 실패나 취소가 확인되면 재무 처리를 통해 원래 자금 출처로 예약금이 해제되거나 반환됩니다. 작업 상태만으로 환불 완료를 판단할 수 없습니다. 전송 결과 불명과 생성 후 전달 문제도 별도로 처리하세요.
relay 오류는 error에 있습니다. 402 video_insufficient_balance, 409 video_idempotency_conflict/video_acceptance_pending, 422는 잘못된 매개변수, 503은 접수 불확실 또는 이용 불가입니다. 응답이 불확실하면 원래 키와 본문을 유지하세요. 웹 구독이나 페이지 내 생성 UI를 추가하지 마세요.
{
"model": "kling-3.0",
"operation": "text_to_video",
"prompt": "A rainy city street at night, slow forward camera move",
"duration": {
"mode": "fixed",
"seconds": 5
},
"output": {
"format": "mp4",
"aspect_ratio": "16:9"
},
"provider_options": {
"kling": {
"mode": "std"
}
},
"audio": {
"mode": "off"
}
}
# Minimal example: persist the Idempotency-Key and task ID in production.
# Requires curl, jq and BETTERTOKEN_API_KEY in your environment.
BASE=https://bettertoken.ai/v1
IDEM="$(uuidgen)"
cat > request.json <<'JSON'
{
"model": "kling-3.0",
"operation": "text_to_video",
"prompt": "A rainy city street at night, slow forward camera move",
"duration": {
"mode": "fixed",
"seconds": 5
},
"output": {
"format": "mp4",
"aspect_ratio": "16:9"
},
"provider_options": {
"kling": {
"mode": "std"
}
},
"audio": {
"mode": "off"
}
}
JSON
curl --fail-with-body "$BASE/videos/quote" \
-H "Authorization: Bearer $BETTERTOKEN_API_KEY" \
-H 'Content-Type: application/json' --data-binary @request.json || exit 1
TASK=$(curl --fail-with-body "$BASE/videos" \
-H "Authorization: Bearer $BETTERTOKEN_API_KEY" \
-H "Idempotency-Key: $IDEM" \
-H 'Content-Type: application/json' --data-binary @request.json) || exit 1
ID=$(printf '%s' "$TASK" | jq -er '.id') || exit 1
# Poll up to 360 times, waiting 5 seconds between requests.
# Network delays can extend the total time.
for attempt in $(seq 1 360); do
TASK=$(curl --fail-with-body "$BASE/videos/$ID" \
-H "Authorization: Bearer $BETTERTOKEN_API_KEY") || exit 1
STATUS=$(printf '%s' "$TASK" | jq -r '.status')
case "$STATUS" in
completed) break ;;
failed|canceled) printf '%s\n' "$TASK"; exit 1 ;;
esac
sleep 5
done
[ "$STATUS" = completed ] || { echo "Resume polling task: $ID"; exit 1; }
curl --fail-with-body "$BASE/videos/$ID/content" \
-H "Authorization: Bearer $BETTERTOKEN_API_KEY" -o video.mp4
맞춤 숏: 전체 요청 본문+
최대 6개 숏, 각 1초 이상, 각 프롬프트 512자 이하입니다. 숏 길이의 합은 총 길이와 같아야 합니다. shots 사용 시 최상위 prompt를 생략하세요. 마지막 프레임과 함께 사용할 수 없습니다.
{
"model": "kling-3.0",
"operation": "text_to_video",
"duration": {
"mode": "fixed",
"seconds": 12
},
"output": {
"aspect_ratio": "16:9",
"format": "mp4"
},
"audio": {
"mode": "off"
},
"provider_options": {
"kling": {
"mode": "std"
}
},
"shots": [
{
"prompt": "Wide shot of a ceramic mug on a wooden table in morning light.",
"duration_seconds": 2
},
{
"prompt": "Close-up of steam rising above the rim.",
"duration_seconds": 2
},
{
"prompt": "Side view revealing the curved handle.",
"duration_seconds": 2
},
{
"prompt": "Close-up of the textured ceramic glaze.",
"duration_seconds": 2
},
{
"prompt": "Top view of coffee in the mug.",
"duration_seconds": 2
},
{
"prompt": "Wide closing shot of the mug by a sunlit window.",
"duration_seconds": 2
}
]
}
Kling API 매개변수 및 모델 ID
kling-3.0를 사용하세요. 출력 품질은 provider_options.kling.mode로 선택하며 output.resolution은 보내지 마세요.
매개변수
값 및 제한
model
kling-3.0
operation
text_to_video / image_to_video
provider_options.kling.mode
std = Standard 720p · pro = Pro 1080p · 4k = 4K
audio.mode
off / on
duration.seconds
정수 3~15초, duration.mode = fixed
shots[{prompt,duration_seconds}]
최대 6개, 각 1초 이상, 합계는 duration.seconds, 프롬프트당 512자 이하, 마지막 프레임과 병용 불가.
output.aspect_ratio
16:9 / 9:16 / 1:1은 텍스트 기반 생성만 지원. 프레임 입력 시 생략하세요.
media
첫 프레임 또는 첫 프레임과 마지막 프레임. 출력은 입력 이미지를 따릅니다.
자주 묻는 질문
Kling API 질문
오디오를 끄면 Standard 720p는 US$0.099/초, Pro 1080p는 US$0.128/초, 4K는 US$0.471/초부터입니다. 위의 등급·오디오별 요금 6개를 확인하세요. 실제 출력 초로 청구합니다.
가로, 세로, 정사각형의 3~15초 동영상을 정수 초로 요청하세요. 16:9, 9:16, 1:1은 텍스트 기반 생성에만 적용하며 프레임 입력은 입력 이미지를 따릅니다. 네. Standard 720p, Pro 1080p 또는 4K를 선택하세요. provider_options.kling.mode를 std, pro 또는 4k로 설정하고 output.resolution은 보내지 마세요.
확인된 생성 실패에는 요금이 부과되지 않습니다. 실패 또는 취소가 확인되면 예약된 금액을 해제하거나 원래 잔액 또는 한도로 반환합니다. 작업 실패만으로 환불이 끝났다는 뜻은 아닙니다. 요청이 접수되었는지 불분명하면 먼저 확인합니다. 성공한 영상의 다운로드 문제나 파일 만료는 별도로 처리합니다. 작업의 결제 상세 정보를 확인하세요.