메인 콘텐츠로 건너뛰기
POST
Text-to-video: submit a generation task from text prompt
오른쪽의 대화형 Playground는 실시간 디버깅을 지원합니다. 인증 아래에 API Key를 입력하고(형식 Bearer sk-xxx), prompt를 입력한 다음 model / seconds / metadata.resolution을 선택하고 전송하십시오. Default 그룹도 작동합니다 — 전용 그룹 전환은 필요하지 않습니다.
범위: 이 페이지는 “텍스트만으로 동영상 생성”을 다룹니다 — input_reference, application/json body는 없습니다. 참조 이미지로 생성하려면 Image-to-Video 엔드포인트를 사용하십시오(동일한 엔드포인트 + input_reference 업로드).
⚠️ 가장 흔한 세 가지 함정
  1. length 필드의 이름은 seconds(duration가 아님)이며 문자열이어야 합니다 "4" / "6" / "8". 이를 duration로 지정하면 조용히 무시되며 → 길이는 기본 4초로 되돌아갑니다(“8s를 보냈는데 4s를 받은” 함정); 숫자를 전달하면 parse_request_failed: cannot unmarshal number into Go struct field ... duration of type string로 실패합니다
  2. generateAudio를 전달하지 마십시오 — 상위 시스템이 INVALID_ARGUMENT를 반환합니다. 오디오 의도(ambient, dialogue, BGM)는 대신 prompt에 표현하십시오
  3. 1080p / 4k에서는 seconds가 "8"여야 합니다 — "4" / "6"는 상위 시스템에서 거부됩니다
3단계 비동기 흐름 — 이 페이지는 Step 1(제출)만 다룹니다
  • Step 1 (이 페이지): POST /v1/videos → task_id + status: "queued"를 반환합니다
  • Step 2: GET /v1/videos/{task_id}를 status: "completed"이 될 때까지 폴링합니다
  • Step 3: MP4를 다운로드하는 GET /v1/videos/{task_id}/content
POST 제출 자체는 1초 미만이며 생성이 완료될 때까지 기다리지 않습니다. 전체 흐름은 아래 Python 샘플에 나와 있습니다.

코드 예시

Python (OpenAI SDK · 저수준 client.post)

Python (requests)

cURL

Node.js (native fetch)

Browser JavaScript

이미 task_id가 있으신가요? 바로 복사하여 사용하는 cURL 명령어 2개

이미 task_id를 보유하고 계신 경우(작업 제출 시 반환되었거나 콘솔 로그에서 확인 가능), 아래의 두 자리표시자만 변경하여 실행하시면 됩니다:
  • sk-your-api-key → 사용자의 APIYI 키
  • task_xxxxxxxxxxxxxxxx → 사용자의 task ID

1. 작업 상태 확인

JSON 응답에 status: "completed"가 표시되면 다운로드할 수 있으며, in_progress가 표시되면 몇 초간 대기한 후 다시 확인하십시오.

2. 동영상 다운로드 (output.mp4로 저장)

/content 엔드포인트에는 Authorization 헤더가 필요합니다. 브라우저 주소창에서 URL을 직접 열면 401이 반환됩니다. -f --retry 7 --retry-delay 4 --retry-all-errors는 status가 completed(으)로 변경된 직후(최대 약 20초)에 발생하는 400을 처리합니다. -f이 없으면 curl은 400을 성공으로 간주하고 오류 JSON을 output.mp4에 기록하며, --retry-all-errors이 없으면 --retry는 400을 전혀 재시도하지 않습니다(curl 7.71+ 필요).

매개변수 참조

generateAudio 필드를 전달하지 마십시오! Veo 3.1은 기본적으로 오디오를 지원합니다. 이 매개변수를 전달하면 INVALID_ARGUMENT이 반환됩니다. 오디오를 제어하려면, 의도를 prompt에 작성하십시오: "waves, distant seabirds, low wind sounds".
매개변수 우선순위:
  • 길이: metadata.durationSeconds > seconds > 8(seconds를 전송하십시오; duration은 인식되지 않습니다)
  • 해상도: metadata.resolution > size > 720p
  • 화면 비율: 명시적 metadata.aspectRatio > 크기에서 추론 > 16:9

응답 형식

1단계 - 제출 직후

2단계 - 폴링 응답 (진행 중)

2단계 - 폴링 응답 (완료됨)

⚠️ 응답 필드 주의사항
  • 태스크 ID는 id에서 가져오십시오: 제출 응답에는 task_id(동일한 값)도 포함될 수 있지만, 폴링 응답에는 id만 포함됩니다. 안전한 패턴은 resp.get("task_id") or resp["id"]입니다(위의 샘플 코드에 이미 적용되어 있습니다).
  • 다운로드는 /content를 기준으로 삼으십시오: GET /v1/videos/{task_id}/content는 MP4 바이너리 스트림을 반환하며(인증 헤더 필요), 모든 태스크에서 정상 작동합니다. 완료된 응답에는 video_url(인증이 필요 없는 직접 링크)와 expires_at(약 24시간 후 만료)가 포함될 수도 있습니다. 그러나 이는 모든 태스크에서 보장되는 것은 아니며, 임시 미리보기에만 적합합니다. 프론트엔드에서 /content에 직접 접근할 수 없으므로, 서버 측에서 다운로드한 후 자체 OSS / CDN에 다시 호스팅하십시오.
  • progress 값은 정밀하지 않으며 몇 가지 고정된 단계 사이를 건너뛰기만 하므로, 백분율 진행률 표시에 사용하지 마십시오.
  • status: "failed"에는 일반적으로 error.message에 사유(콘텐츠 검토, 매개변수 오류 또는 생성된 파일을 가져올 수 없음 등)가 함께 전달됩니다. 실패한 태스크는 과금되지 않으며 차감된 금액은 자동으로 환불됩니다. prompt를 조정한 후 다시 시도하십시오.
  • status 상태가 completed(으)로 전환된 직후 /content에서 일시적으로 400 오류가 반환될 수 있습니다. 4초 후 다시 시도하십시오(위의 모든 코드 샘플에 이미 반영되어 있습니다).
이 엔드포인트는 비동기 태스크 진입점입니다. 과금은 태스크가 completed 상태에 도달할 때 모델 이름에 따라 요청당 부과됩니다(fast $0.3 / standard $1.2, 요금 안내 참조). POST 제출, 폴링 및 다운로드 자체는 과금되지 않으며, 실패한 태스크 역시 과금되지 않습니다.

인증

Authorization
string
header
필수

API Key from APIYI console (Default group + Pay-per-request or Pay-as-you-go Priority Token; pure Pay-as-you-go not supported)

본문

application/json
model
enum<string>
기본값:veo-3.1-fast-generate-preview
필수

Model ID (per-request billing, duration / resolution do not affect price):

  • veo-3.1-fast-generate-preview — $0.3/request, top pick for iteration / batch generation
  • veo-3.1-generate-preview — $1.2/request, for final delivery / 4K scenarios
사용 가능한 옵션:
veo-3.1-fast-generate-preview,
veo-3.1-generate-preview
prompt
string
필수

Video generation prompt; describe in detail: scene + subject + action + camera + lighting + style.

Audio intent also goes in the prompt (e.g. "waves, distant seabirds, low wind sounds"). Do not pass generateAudio — upstream rejects with INVALID_ARGUMENT.

예시:

"A coastal lighthouse at dusk, slow push-in, waves lapping the rocks, distant seabirds, cinematic lighting, steady camera"

seconds
enum<string>
기본값:8

Video length. The field name is seconds (not duration), a string enum (not number):

  • "4" — 4 sec, 720p only
  • "6" — 6 sec, 720p only
  • "8" — 8 sec (default), required at 1080p / 4k

Sending duration instead is silently ignored → length falls back to the default 4 sec (720p returns no error but only outputs 4 sec; 1080p/4k errors with ... but got 4). Passing a number (8) returns parse_request_failed: cannot unmarshal number into Go struct field ... duration of type string.

사용 가능한 옵션:
4,
6,
8
size
enum<string>
기본값:1280x720

Output pixel dimensions; lower precedence than metadata.resolution:

  • 1280x720 / 720x1280 — 720p (default)
  • 1920x1080 / 1080x1920 — 1080p (seconds must be "8")
  • 3840x2160 / 2160x3840 — 4k (seconds must be "8", 4–6× slower render)
사용 가능한 옵션:
1280x720,
720x1280,
1920x1080,
1080x1920,
3840x2160,
2160x3840
metadata
object

Wrapper for fine-grained generation parameters. Higher precedence than the top-level size etc.:

  • Duration resolution order: metadata.durationSeconds > seconds > 8 (send seconds; duration is not recognized)
  • Resolution resolution order: metadata.resolution > size > 720p

응답

Task submitted; returns task_id and queued status

id
string

Task ID (matches task_id; downstream should standardize on task_id)

예시:

"task_xxxxxxxxxxxxxxxx"

task_id
string

Task ID for subsequent polling and download

예시:

"task_xxxxxxxxxxxxxxxx"

object
string

Object type, fixed to video

예시:

"video"

model
string

Model ID used for this task

예시:

"veo-3.1-fast-generate-preview"

status
enum<string>

Task status:

  • queued — submitted, awaiting processing
  • in_progress — generating
  • completed — done, downloadable (/v1/videos/{task_id}/content)
  • failed — failed (not billed), retry possible
사용 가능한 옵션:
queued,
in_progress,
completed,
failed
예시:

"queued"

progress
integer

Generation progress (coarse-grained, jumps only between 0 / 50 / 100, do not use for percentage bars)

예시:

0

created_at
integer

Task creation Unix timestamp (seconds)

예시:

1775025000

completed_at
integer

Task completion Unix timestamp (seconds); only present for completed status

예시:

1775025090