import os
import dashscope
from dashscope.v2 import DashScopeError
client = dashscope.Client(
api_key=os.getenv("DASHSCOPE_API_KEY"),
base_url="https://maas.qianwenaiapi.com/api/v1",
)
print('please wait...')
try:
# generate 为一步式调用(提交任务并等待完成),返回已完成的 Job
# shot_type 不在具名签名内,经 parameters 透传
job = client.videos.generate(
model='wan2.6-t2v',
prompt='A thrilling detective chase story with cinematic storytelling. Shot 1 [0–3 s]: Wide shot of a rainy New York street at night, neon lights flickering, a detective in a black trench coat walking briskly. Shot 2 [3–6 s]: Medium shot of the detective entering an old building, rain soaking his coat, the door closing slowly behind him. Shot 3 [6–9 s]: Close-up of the detective\'s focused, determined eyes as distant sirens wail and he frowns slightly in thought. Shot 4 [9–12 s]: Medium shot of the detective moving carefully down a dim hallway, his flashlight illuminating the path ahead. Shot 5 [12–15 s]: Close-up of the detective discovering a key clue, his face lighting up with sudden realization.',
size="1280*720",
duration=15,
prompt_extend=True,
watermark=False,
parameters={'shot_type': "multi"})
print(job)
print("video_url:", job.video_url)
except DashScopeError as e:
print(f"HTTP返回码:{e.status_code}")
print(f"错误码:{e.code}")
print(f"错误信息:{e.message}")
print("请参考文档:/api-reference/preparation/error-messages")