인기 모델
영상 생성은 일반적으로 이미지 생성보다 오래 걸립니다. 영상 길이와 품질 설정에 따라 더 긴 처리 시간이 소요될 수 있음을 감안하세요.
1단계: 영상 생성하기
프롬프트와 영상 파라미터를 담아/generate/video/kling/kling-2.5로 POST 요청을 보냅니다. API는 즉시 작업 ID를 반환합니다.
// npm install @krea-ai/sdk
import { Krea } from "@krea-ai/sdk";
const krea = new Krea({ apiKey: process.env.KREA_API_KEY });
const job = await krea.video("kling/kling-2.5", {
prompt: "a majestic eagle soaring over snow-capped mountains at sunrise",
duration: 5,
aspect_ratio: "16:9"
});
console.log(`Job ID: ${job.job_id}`);
curl -X POST https://api.krea.ai/generate/video/kling/kling-2.5 \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"prompt": "a majestic eagle soaring over snow-capped mountains at sunrise",
"duration": 5,
"aspect_ratio": "16:9"
}'
import requests
API_BASE = "https://api.krea.ai"
API_TOKEN = "YOUR_API_TOKEN"
response = requests.post(
f"{API_BASE}/generate/video/kling/kling-2.5",
headers={
"Authorization": f"Bearer {API_TOKEN}",
"Content-Type": "application/json"
},
json={
"prompt": "a majestic eagle soaring over snow-capped mountains at sunrise",
"duration": 5,
"aspect_ratio": "16:9"
}
)
job = response.json()
print(f"Job ID: {job['job_id']}")
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
)
func main() {
apiBase := "https://api.krea.ai"
apiToken := "YOUR_API_TOKEN"
payload := map[string]interface{}{
"prompt": "a majestic eagle soaring over snow-capped mountains at sunrise",
"duration": 5,
"aspect_ratio": "16:9",
}
jsonData, _ := json.Marshal(payload)
req, _ := http.NewRequest("POST", apiBase+"/generate/video/kling/kling-2.5", bytes.NewBuffer(jsonData))
req.Header.Set("Authorization", "Bearer "+apiToken)
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
var job map[string]interface{}
json.NewDecoder(resp.Body).Decode(&job)
fmt.Printf("Job ID: %s\n", job["job_id"])
}
API 토큰으로 교체하세요위 예시의 YOUR_API_TOKEN 플레이스홀더를 교체하려면 krea.ai/settings/api-tokens에서 API 토큰을 생성해야 합니다. 도움이 필요하다면 API Keys & Billing 페이지의 안내를 따르세요.
{
"job_id": "550e8400-e29b-41d4-a716-446655440000",
"status": "queued",
"created_at": "2025-01-15T10:30:00.000Z",
"estimated_time": "60-120 seconds"
}
2단계: 결과 폴링하기
영상 생성은 이미지 생성보다 오래 걸립니다. 진행 상황을 확인하려면/jobs/{job_id}를 5초마다 폴링하세요.
웹훅을 사용할 수 있습니다!작업이 완료될 때 알림을 받으려면 웹훅을 설정하세요. 시작하려면 Webhooks 가이드를 참고하세요.
// npm install @krea-ai/sdk
import { Krea } from "@krea-ai/sdk";
const krea = new Krea({ apiKey: process.env.KREA_API_KEY });
async function waitForVideo(jobId) {
const completed = await krea.jobs.wait(jobId, { intervalMs: 5000 });
return completed.result.urls[0];
}
const videoUrl = await waitForVideo(job.job_id);
console.log(`Video ready: ${videoUrl}`);
curl -X GET https://api.krea.ai/jobs/YOUR_JOB_ID \
-H "Authorization: Bearer YOUR_API_TOKEN"
import time
def wait_for_video(job_id):
while True:
response = requests.get(
f"{API_BASE}/jobs/{job_id}",
headers={"Authorization": f"Bearer {API_TOKEN}"}
)
job = response.json()
if job["status"] == "completed":
return job["result"]["urls"][0]
if job["status"] in ("failed", "cancelled"):
raise Exception(f"Job failed: {job['status']}")
# Show progress if available
if "progress" in job:
print(f"Progress: {job['progress']}%")
else:
print(f"Status: {job['status']}")
time.sleep(5)
video_url = wait_for_video(job["job_id"])
print(f"Video ready: {video_url}")
func waitForVideo(jobID string) (string, error) {
for {
req, _ := http.NewRequest("GET", apiBase+"/jobs/"+jobID, nil)
req.Header.Set("Authorization", "Bearer "+apiToken)
resp, _ := client.Do(req)
var job map[string]interface{}
json.NewDecoder(resp.Body).Decode(&job)
resp.Body.Close()
switch job["status"] {
case "completed":
result := job["result"].(map[string]interface{})
urls := result["urls"].([]interface{})
return urls[0].(string), nil
case "failed", "cancelled":
return "", fmt.Errorf("job failed: %s", job["status"])
}
// Show progress if available
if progress, ok := job["progress"]; ok {
fmt.Printf("Progress: %.0f%%\n", progress)
} else {
fmt.Printf("Status: %s\n", job["status"])
}
time.Sleep(5 * time.Second)
}
}
{
"job_id": "550e8400-e29b-41d4-a716-446655440000",
"status": "completed",
"created_at": "2025-01-15T10:30:00.000Z",
"completed_at": "2025-01-15T10:31:45.000Z",
"result": {
"urls": ["https://gen.krea.ai/videos/your-video.mp4"]
}
}
웹훅을 사용할 수 있습니다!작업이 완료될 때 알림을 받으려면 웹훅을 설정하세요. 시작하려면 Webhooks 가이드를 참고하세요.
공통 파라미터
모든 모델의 자세한 파라미터 목록은 Model APIs 페이지를 확인하세요.
| 파라미터 | 타입 | 설명 |
|---|---|---|
prompt | string | 영상 내용에 대한 상세 설명 |
duration | number | 영상 길이(초). 지원 값은 모델에 따라 다릅니다. |
aspect_ratio | string | 16:9, 9:16, 1:1 등 영상 화면 비율 |
start_image | string | 이미지-투-비디오 모델을 위한 선택적 원본 이미지 URL |
end_image | string | 지원되는 모델을 위한 선택적 종료 프레임 URL |
mode | string | 지원하는 모델을 위한 선택적 품질 모드 |
model | string | 사용할 영상 생성 모델 |
더 나은 영상을 위한 프롬프트 팁:
- 모션과 카메라 움직임을 구체적으로 명시하세요
- 장면, 조명, 분위기를 묘사하세요
- 타이밍을 언급하세요 (예: “천천히 팬”, “빠른 줌”)
- 스타일 참조를 포함하세요 (예: “시네마틱”, “다큐멘터리 스타일”)
영상 생성은 이미지 생성보다 비용이 큽니다. 모델별 가격과 API 잔액 충전 방법은 API Keys & Billing을 참고하세요.