Generate

API Reference

The request, configuration, and response models shared by the REST API and the Python client.

These models define the generation request body, its configuration objects, and the status response. They are identical across the REST API and the Python client.

TaskInput

The JSON body of POST /api/v0/generate (and the argument to the client's submit_task). model and task_type are required; the rest depend on the task type.

How is size determined?

For image/video sizing config, VideoConfig and ImageConfig take 3 optional params: width, height and aspect_ratio. The following strategy will be followed:

  1. If both width and height are specified, they take precedence over aspect_ratio.
  2. If aspect_ratio is missing, for image it defaults to 1:1 and for video it defaults to 16:9.
  3. If only height is specified, the width will be calculated based on aspect_ratio (and rounded up if needed).
  4. Other cases are considered invalid and rejected.

Some models accept only a fixed set of explicit width×height sizes and do not use the height + aspect_ratio derivation above; for those, pass one of the model's supported sizes. height is required for all documented image and video task types.

FieldTypeRequiredDefaultDescription
modelstrYes-Model id, e.g. 'Wan2.2-A14B', 'Kling-v3'.
task_typestrYes-one of T2I, I2I, T2V, I2V, R2V
promptstrYes-Text prompt driving generation.
enhance_promptbool | None-NoneWhether prompt enhancement should be enabled. Enabling this would slow down generation but would improve quality. By default, if this is not explicitly set we will let the model determine the default behavior. Users can still explicitly force it to enable/disable by setting this field based on the requirement.
video_configVideoConfig | None-NoneRequired for video task types.
image_configImageConfig | None-NoneRequired for image task types.
seedint | None-NoneSeed for reproducible generation. If not specified, a random seed will be used.
src_image_urlslist[str] | None-NoneSource / reference image URLs. Only needed for tasks that require input images like I2I, I2V, R2V. Refer to the API docs for concrete examples of how to use this and what inputs are allowed. For I2V, entry 0 is the start frame and an optional entry 1 is the end frame on models that support it (Seedance-2.0, Kling-v3, LTX-2.3-Pro, Vidu-Q3-Turbo, Vidu-Q3-Pro); a second image returns 400 elsewhere.
src_video_urlslist[str] | None-NoneReference video URLs. Only supported for Seedance-2.0 R2V, which accepts up to 3 clips of 2-15s each (15s combined).
src_audio_urlslist[str] | None-NoneReference audio URLs. Only supported for Seedance-2.0 R2V, which accepts up to 3 clips totalling 15s. Audio may not be the only reference - at least one image or video is required.
subject_to_image_idsdict[str, list[int]] | None-NoneR2V only: maps a subject name to the indices of its reference images in src_image_urls, e.g. {'alice': [0, 1], 'bob': [2]}. The prompt may address a subject via '@name'. Honored by vendors with named subjects (Vidu reference2video).
subject_to_video_idsdict[str, list[int]] | None-NoneR2V only: subject_to_image_ids for src_video_urls. A name may appear in only one of the three subject maps. Seedance-2.0 only.
subject_to_audio_idsdict[str, list[int]] | None-NoneR2V only: subject_to_image_ids for src_audio_urls. A name may appear in only one of the three subject maps. Seedance-2.0 only.
moderatebool-TrueWhether this request is screened by content moderation.

VideoConfig

Required for video task types (T2V, I2V, R2V).

FieldTypeRequiredDefaultDescription
fpsint | None-NoneVideo frames per second. If omitted the default FPS would be used based on the model.
duration_secsintYes-Video duration in seconds.
heightint | None-NoneOutput height in pixels. Required for generation (a missing height is rejected at submit).
widthint | None-NoneOutput width in pixels.
aspect_ratiostr | None-NoneOutput aspect ratio. The default is 16:9 if omitted. The width of the output will be updated to match the height based on the aspect ratio, rounded up to the nearest integer.
bitrate_modestr | None-NoneEncode quality for the delivered video: 'standard' or 'high'. Only supported for Seedance-2.0. Omitted -> the vendor default.
infer_stepsint | None-NoneNumber of denoising / inference steps. Higher values trade more compute for potentially finer detail. This is a best-effort match: if the model does not support it the model default is used.
audiobool | None-NoneWhether the video should include audio. Note: some models do not support audio, or the audio is always on (e.g. Veo 3.1). In those cases this field has no effect.
guidance_scalelist[float] | None-NoneClassifier-free guidance scale(s). Controls how strongly the output adheres to the prompt: higher values follow the prompt more closely at the cost of diversity. If the model supports multiple guidance scales, these will be applied in a sequence (e.g. per stage or per denoising phase). This is a best-effort match: if the model does not support it, or does not support the number of scales provided, the model default is used.
multi_promptlist[str] | None-NonePer-shot text prompts for Kling-v3 multi-shot video (shot_type 'customize'). 1-6 shots, paired 1:1 with shot_durations. The top-level prompt is ignored when this is set.
shot_typestr | None-NoneEnables Kling-v3 multi-shot (T2V / I2V). 'customize' splits the video into the shots given by multi_prompt + shot_durations; 'intelligence' derives the shots from the single prompt. Omitted -> single-shot.
shot_durationslist[int] | None-NonePer-shot durations in seconds for shot_type 'customize'; one per multi_prompt entry, each >= 1, summing to duration_secs.
negative_promptstr | None-NoneWhat the video should avoid. Kling-v3 only. Omitted -> the vendor default ('blur, distort, and low quality').
element_idslist[int] | None-NoneKling-v3 only: ordered Kling element library ids (<=3) to include. The prompt references them via @handle (see element_handles), rewritten to Kling's positional \<\<\<element_N>>> at submit.
element_handleslist[str] | None-NoneKling-v3 only: the @handle for each element_ids entry (same order). Each @handle in the prompt is rewritten to \<\<\<element_N>>> for the vendor while the stored prompt keeps it.

ImageConfig

Required for image task types (T2I, I2I).

FieldTypeRequiredDefaultDescription
heightint | None-NoneOutput height in pixels. Required for generation (a missing height is rejected at submit).
widthint | None-NoneOutput width in pixels.
aspect_ratiostr | None-NoneOutput aspect ratio. The default is 1:1 if omitted. The width of the output will be updated to match the height based on the aspect ratio, rounded up to the nearest integer.
infer_stepsint | None-NoneNumber of denoising / inference steps. Higher values trade more compute for potentially finer detail. This is a best-effort match: if the model does not support it the model default is used.
guidance_scalelist[float] | None-NoneClassifier-free guidance scale(s). Controls how strongly the output adheres to the prompt: higher values follow the prompt more closely at the cost of diversity. If the model supports multiple guidance scales, these will be applied in a sequence (e.g. per stage or per denoising phase). This is a best-effort match: if the model does not support it, or does not support the number of scales provided, the model default is used.

TaskStatusResponse

Returned by GET /api/v0/tasks/{task_id} (and by the client's get_task_state and wait).

FieldTypeRequiredDefaultDescription
task_idstrYes-Server-assigned id; poll status and download the asset with it.
metadataTaskMetadataYes-Echo of the resolved task parameters.
task_outputdict[TaskOutputType, str] | None-NonePer output-type asset locators, as they become available.
moderationModerationResult | None-NoneStructured moderation verdict when the task failed or was blocked by moderation.
statusTaskStatusYes-Current task status.
error_msgstr | None-NoneFailure reason, set when status is FAILED.
generation_time_secsfloat | None-NoneTime spent on actual generation.
upload_time_secsfloat | None-NoneTime spent uploading the asset after generation.
queue_time_secsfloat | None-NoneTime spent waiting in the queue for generation to begin.
execution_providerstr | None-NoneActual provider of the terminal execution trial.
overflow_convertedbool-FalseWhether long queuing moved this task off self-hosted capacity to an on-demand provider. Readable before the task finishes.