Model details
View repositoryExample usage
Generate a video from a text prompt. The response contains a base64-encoded video.
Input
1import requests
2import base64
3import os
4
5# Supported video sizes:
6# 720x1280, 1280x720, 480x832, 832x480,
7# 704x1280, 1280x704, 1024x704, 704x1024
8
9res = requests.post(
10 "https://model-{MODEL_ID}.api.baseten.co/production/predict",
11 headers={"Authorization": f"Api-Key {os.environ['BASETEN_API_KEY']}"},
12 json={
13 "prompt": "A cat playing piano in a jazz club, cinematic lighting",
14 "size": "1280x720",
15 "sampling_steps": 40,
16 "guide_scale": [3.0, 4.0],
17 "seed": 42,
18 },
19)
20
21# Save the base64-encoded video to an mp4 file
22video_data = base64.b64decode(res.json()["video"])
23with open("wan2_output.mp4", "wb") as f:
24 f.write(video_data)
25JSON output
1{
2 "video": "AAAAIGZ0eXBpc29tAAACAGlzb21pc28yYXZj..."
3}