import requests
DEEPINFRA_TOKEN = "$DEEPINFRA_TOKEN"
MODEL = "Wan-AI/Wan2.2-T2V-A14B"
response = requests.post(
f"https://api.deepinfra.com/v1/inference/{MODEL}",
headers={
"Authorization": f"Bearer {DEEPINFRA_TOKEN}",
"Content-Type": "application/json",
},
json={
"prompt": "A serene mountain lake at sunrise, with mist rising from the water and pine trees reflected on the surface.",
},
)
result = response.json()
# video_url is a `data:video/mp4;base64,...` URI, not an HTTP link.
# Decode it to save the clip:
import base64
header, _, payload = result["video_url"].partition(",")
with open("video.mp4", "wb") as f:
f.write(base64.b64decode(payload))