Skip to main content

Wan 2.7 Ref2V

The flymyai/wan-2_7-ref2v model generates a video guided by one or more reference images and/or videos, optionally paired with reference audio/voice clips. This lets you condition generation on specific subjects, objects, or characters supplied via the references field, instead of (or in addition to) a text prompt.

Installation

pip install flymyai

Usage

# Install the FlyMyAI package
# pip install flymyai
from flymyai import client, FlyMyAIPredictException
import json

# Set secret api key. You can find your api key in the profile settings
apikey = "fly-***"

# Set the model name
model = "flymyai/wan-2_7-ref2v"

# Reference images/videos with optional reference voice/audio
references = [
{
"type": "reference_image",
"url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260408/sjuytr/wan-r2v-object-girl.jpg",
"reference_voice": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260408/gbqewz/wan-r2v-girl-voice.mp3"
},
{
"type": "reference_video",
"url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260129/qigswt/wan-r2v-role2.mp4",
"reference_voice": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260408/isllrq/wan-r2v-boy-voice.mp3"
},
{
"type": "reference_image",
"url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260129/rtjeqf/wan-r2v-object3.png"
},
{
"type": "reference_image",
"url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260129/qpzxps/wan-r2v-object4.png"
},
{
"type": "reference_image",
"url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260129/wfjikw/wan-r2v-backgroud5.png"
}
]

# Prepare the input data
payload = {
"prompt": "A cat attempts a daring jump across a gap, but hilariously miscalculates.",
"negative_prompt": None,
"duration": 5,
"shot_type": None,
"watermark": False,
"seed": 42,
"resolution": "1080P",
"references": json.dumps(references),
"enable_safety_checker": True
}

# Initialize the client
fma_client = client(apikey=apikey)
try:
response = fma_client.predict(
model=model,
payload=payload
)
# Process the output data
print(f"video_url: {response.output_data['video_url']}")
except FlyMyAIPredictException as e:
print(e)
raise e

Input parameters

ParameterTypeRequiredDescription
promptstringNoText description guiding the generated video.
negative_promptstringNoText describing what to avoid in the generated video.
durationintegerNoDuration of the generated video, in seconds.
shot_typestringNoCamera/shot type hint for generation.
watermarkbooleanNoWhether to add a watermark to the output video. Defaults to false.
seedintegerNoRandom seed for reproducible generation.
resolutionstringNoOutput video resolution, e.g. "1080P".
referencesstring (JSON-encoded array of objects)YesList of reference images/videos (and optional reference audio) used to condition generation. See references format below.
enable_safety_checkerbooleanNoWhether to run generated output through the safety checker. Defaults to true.
note

The references field must be passed as a JSON-encoded string, not a raw Python list/dict. Use json.dumps(...) when building the payload, as shown in the example above.

references format

references is a JSON array of objects, each describing a single reference asset:

FieldTypeRequiredDescription
typestringYesType of reference asset. One of "reference_image" or "reference_video".
urlstringYesPublicly accessible URL to the reference image or video file.
reference_voicestringNoPublicly accessible URL to a reference audio/voice clip (.mp3) associated with this reference.

Example:

[
{
"type": "reference_image",
"url": "https://example.com/girl.jpg",
"reference_voice": "https://example.com/girl-voice.mp3"
},
{
"type": "reference_video",
"url": "https://example.com/role2.mp4",
"reference_voice": "https://example.com/boy-voice.mp3"
},
{
"type": "reference_image",
"url": "https://example.com/object3.png"
}
]
  • You may mix reference_image and reference_video entries in the same list.
  • reference_voice is optional per-entry — omit it if no associated audio is needed for that reference.
  • At least one reference entry is required.

Output

FieldTypeDescription
video_urlstringURL of the generated video.
print(f"video_url: {response.output_data['video_url']}")