curl --request POST \
--url https://api.apiyi.com/v1/videos \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "grok-imagine-video-1.5-lite"
}
'import requests
url = "https://api.apiyi.com/v1/videos"
payload = { "model": "grok-imagine-video-1.5-lite" }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({model: 'grok-imagine-video-1.5-lite'})
};
fetch('https://api.apiyi.com/v1/videos', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.apiyi.com/v1/videos",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => 'grok-imagine-video-1.5-lite'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.apiyi.com/v1/videos"
payload := strings.NewReader("{\n \"model\": \"grok-imagine-video-1.5-lite\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.apiyi.com/v1/videos")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"grok-imagine-video-1.5-lite\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.apiyi.com/v1/videos")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"grok-imagine-video-1.5-lite\"\n}"
response = http.request(request)
puts response.read_body{
"id": "task_xxxxxxxxxxxxxxxx",
"object": "video",
"model": "grok-imagine-video-1.5-lite",
"status": "queued",
"progress": 0,
"seconds": "<string>",
"created_at": 123,
"completed_at": 123
}Grok Imagine 동영상 생성 API 레퍼런스
Grok Imagine 동영상 생성 API 레퍼런스 및 실시간 테스트 — 텍스트-동영상 / 이미지-동영상, 비동기 3단계 흐름, 1–15초, 480p / 720p / 1080p, 초당 xAI와 동일한 가격
curl --request POST \
--url https://api.apiyi.com/v1/videos \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "grok-imagine-video-1.5-lite"
}
'import requests
url = "https://api.apiyi.com/v1/videos"
payload = { "model": "grok-imagine-video-1.5-lite" }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({model: 'grok-imagine-video-1.5-lite'})
};
fetch('https://api.apiyi.com/v1/videos', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.apiyi.com/v1/videos",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => 'grok-imagine-video-1.5-lite'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.apiyi.com/v1/videos"
payload := strings.NewReader("{\n \"model\": \"grok-imagine-video-1.5-lite\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.apiyi.com/v1/videos")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"grok-imagine-video-1.5-lite\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.apiyi.com/v1/videos")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"grok-imagine-video-1.5-lite\"\n}"
response = http.request(request)
puts response.read_body{
"id": "task_xxxxxxxxxxxxxxxx",
"object": "video",
"model": "grok-imagine-video-1.5-lite",
"status": "queued",
"progress": 0,
"seconds": "<string>",
"created_at": 123,
"completed_at": 123
}GrokOfficial 그룹 필요: Grok Imagine Video는 Default 그룹에 포함되지 않습니다. 호출하려면 먼저 액세스를 요청해야 합니다(이 페이지의 플레이그라운드 포함). 액세스 권한이 없거나 요청당 결제 Token을 사용하는 경우 모든 호출이 503을 반환합니다. Grok Imagine Video 개요 - 그룹 설정을 참조하십시오.Bearer sk-xxx), model을 선택한 다음 prompt / seconds / size을 입력하고 전송하십시오. 이미지-동영상 변환을 사용하려면 input_reference을 추가하십시오. 플레이그라운드는 1단계(제출)만 수행합니다 — 작업 id을 받은 후 아래 설명에 따라 폴링하고 다운로드하십시오.size/seconds이 없으면 기본값은 480p 및 8초이며, 해당 설정으로 과금됩니다.grok-imagine-video에는 1080p가 없습니다:1920x1080은 400을 반환하므로 1080p에는-1.5또는-1.5-lite을 사용하십시오.- 콘텐츠 조정 차단도 과금됩니다: 차단된 작업도
completed을 반환하지만error.code: "moderation_blocked"을 포함하며 동영상은 없습니다.
- 1단계(이 페이지):
POST /v1/videos→ 작업id+status: "queued"반환 - 2단계:
status이"completed"또는"failed"이 될 때까지GET /v1/videos/{id}을 폴링 - 3단계:
GET /v1/videos/{id}/content에서 MP4 다운로드
코드 예제
파이썬 (텍스트-동영상, 모든 세 단계)
import os, time, requests
BASE = "https://api.apiyi.com/v1"
H = {"Authorization": f"Bearer {os.environ['APIYI_API_KEY']}"}
# Step 1: submit
task = requests.post(f"{BASE}/videos", headers=H, json={
"model": "grok-imagine-video-1.5",
"prompt": "A lighthouse on the coast at dusk, slow push-in, waves lapping the rocks, seabirds calling, cinematic lighting",
"seconds": "5",
"size": "1280x720", # 720p landscape; the default without it is 480p
}, timeout=60).json()
vid = task["id"]
# Step 2: poll
for _ in range(75): # about 10 minutes at most
time.sleep(8)
job = requests.get(f"{BASE}/videos/{vid}", headers=H, timeout=60).json()
if job["status"] in ("completed", "failed"):
break
if job["status"] != "completed" or job.get("error"):
# moderation_blocked: blocked by moderation, no video, but billed
raise RuntimeError(job.get("error"))
# Step 3: download and store right away
mp4 = requests.get(f"{BASE}/videos/{vid}/content", headers=H, timeout=300)
open("out.mp4", "wb").write(mp4.content)
파이썬 (이미지-동영상, base64 입력 이미지)
import base64, os, requests
H = {"Authorization": f"Bearer {os.environ['APIYI_API_KEY']}"}
img = base64.b64encode(open("first-frame.jpg", "rb").read()).decode()
task = requests.post("https://api.apiyi.com/v1/videos", headers=H, json={
"model": "grok-imagine-video",
"prompt": "the cat slowly turns its head and blinks",
"seconds": "3",
"input_reference": f"data:image/jpeg;base64,{img}", # a public image URL works too
}, timeout=60).json()
print(task["id"]) # then poll and download as above; the output frame follows the input image
cURL
# Step 1: submit text-to-video (1.5-lite, 2 seconds at 480p)
curl -X POST "https://api.apiyi.com/v1/videos" \
-H "Authorization: Bearer sk-your-api-key" \
-H "Content-Type: application/json" \
-d '{
"model": "grok-imagine-video-1.5-lite",
"prompt": "a red paper boat drifting on a calm lake, gentle ripples",
"seconds": "2",
"size": "854x480"
}'
# Image-to-video can also upload a local file with multipart
curl -X POST "https://api.apiyi.com/v1/videos" \
-H "Authorization: Bearer sk-your-api-key" \
-F "model=grok-imagine-video" \
-F "prompt=the cat slowly turns its head" \
-F "seconds=2" \
-F "input_reference=@first-frame.jpg"
# Step 2: check status
curl "https://api.apiyi.com/v1/videos/task_xxxxxxxx" \
-H "Authorization: Bearer sk-your-api-key"
# Step 3: download the video
curl -o out.mp4 "https://api.apiyi.com/v1/videos/task_xxxxxxxx/content" \
-H "Authorization: Bearer sk-your-api-key"
Node.js (fetch)
import fs from 'node:fs';
const BASE = 'https://api.apiyi.com/v1';
const H = { 'Authorization': `Bearer ${process.env.APIYI_API_KEY}`, 'Content-Type': 'application/json' };
const task = await fetch(`${BASE}/videos`, {
method: 'POST',
headers: H,
body: JSON.stringify({
model: 'grok-imagine-video-1.5-lite',
prompt: 'A serene Japanese garden with cherry blossoms drifting, koi pond, golden hour',
seconds: '4',
size: '720x1280' // 720p portrait
})
}).then(r => r.json());
let job;
for (let i = 0; i < 75; i++) {
await new Promise(r => setTimeout(r, 8000));
job = await fetch(`${BASE}/videos/${task.id}`, { headers: H }).then(r => r.json());
if (['completed', 'failed'].includes(job.status)) break;
}
if (job.status !== 'completed' || job.error) throw new Error(JSON.stringify(job.error));
const mp4 = await fetch(`${BASE}/videos/${task.id}/content`, { headers: H });
fs.writeFileSync('out.mp4', Buffer.from(await mp4.arrayBuffer()));
매개변수 빠른 참조
| 매개변수 | 유형 | 필수 여부 | 기본값 | 참고 |
|---|---|---|---|---|
model | 문자열 | ✅ | — | grok-imagine-video / grok-imagine-video-1.5 / grok-imagine-video-1.5-lite |
prompt | 문자열 | 텍스트-동영상 변환에 필수 | — | 장면, 피사체, 동작, 카메라, 조명 설명; 이미지-동영상 변환에서는 동작을 설명합니다 |
seconds | 문자열 / 정수 | ❌ | 8 | 1~15초; 범위를 벗어나면 400을 반환합니다 |
size | 문자열 | ❌ | 480p | WIDTHxHEIGHT 픽셀; 짧은 변이 해상도를 결정하고 가로세로 비율은 가장 가까운 값으로 맞춰집니다. 480p / 720p / 1080p도 사용할 수 있습니다 |
resolution / aspect_ratio | 문자열 | ❌ | — | xAI의 기본 필드입니다. size과 함께 전송하면 이 필드가 우선 적용됩니다 |
input_reference | 문자열 / 파일 | ❌ | — | 이미지-동영상 변환을 위한 입력 이미지: 공개 URL, 데이터 URI 또는 멀티파트 파일 |
| 모델 | 480p | 720p | 1080p | 입력 이미지 |
|---|---|---|---|---|
grok-imagine-video | $0.05 | $0.07 | 지원되지 않음 | $0.002 / 이미지 |
grok-imagine-video-1.5 | $0.08 | $0.14 | $0.25 | $0.01 / 이미지 |
grok-imagine-video-1.5-lite | $0.02 | $0.03 | $0.14 | $0.01 / 이미지 |
응답 예시
제출(1단계):{
"id": "task_xxxxxxxxxxxxxxxx",
"object": "video",
"model": "grok-imagine-video-1.5-lite",
"status": "queued",
"progress": 0,
"created_at": 1792320668
}
{
"id": "task_xxxxxxxxxxxxxxxx",
"object": "video",
"model": "grok-imagine-video-1.5-lite",
"status": "completed",
"progress": 100,
"seconds": "2",
"created_at": 1792320668,
"completed_at": 1792320715
}
status은(는) 여전히 completed이지만, 추가 error 필드가 있으며 다운로드할 동영상이 없습니다:
{
"id": "task_xxxxxxxxxxxxxxxx",
"status": "completed",
"error": { "code": "moderation_blocked", "message": "..." }
}
관련 문서
- Grok Imagine 동영상 개요 - 가격, 그룹 신청, 매개변수, 자주 묻는 질문
- Grok Imagine 공식 이미지 - 동일한 그룹의 이미지 생성
본문
Model ID (billed per second × resolution rate):
grok-imagine-video— 480p $0.05/s, 720p $0.07/s, no 1080pgrok-imagine-video-1.5— 480p $0.08, 720p $0.14, 1080p $0.25 per secondgrok-imagine-video-1.5-lite— 480p $0.02, 720p $0.03, 1080p $0.14 per second
grok-imagine-video, grok-imagine-video-1.5, grok-imagine-video-1.5-lite Output size in WIDTHxHEIGHT pixels: the shorter side sets the resolution (≥1080 is 1080p, ≥720 is 720p, otherwise 480p) and the aspect ratio snaps to the nearest supported one.
You can also pass 480p / 720p / 1080p directly. Without it, the default is 480p.
854x480— 480p landscape (measured 848×480)1280x720/720x1280— 720p landscape / portrait1920x1080/1080x1920— 1080p (1.5 / 1.5-lite only)
854x480, 480x854, 1280x720, 720x1280, 1920x1080, 1080x1920 Input image for image-to-video: a public image URL or a data:image/jpeg;base64,... data URI. Passing it makes the job image-to-video, and the output frame follows the input image.
Each input image costs an extra $0.002 (grok-imagine-video) or $0.01 (1.5 / 1.5-lite).
"https://example.com/first-frame.jpg"
응답
Task submitted; returns the task id and queued status
이 페이지가 도움이 되었나요?