File size: 4,788 Bytes
d37ebe0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270

# Video Generation API Guide

This document explains how to use the video generation API endpoint to create animated outputs in **GIF**, **WebM**, or **ZIP (PNG frames)** format. It includes request structure, parameter explanations, and copy‑paste curl commands for testing.

---

## Base Endpoint

```
https://cyjm1rsdzy6la31w.us-east-1.aws.endpoints.huggingface.cloud
```

---

## Authentication

All requests require a Hugging Face access token.

Add this header to every request:

```
Authorization: Bearer YOUR_HF_TOKEN
```

---

## Request Structure

Requests must be wrapped inside an `"inputs"` object:

```json
{
  "inputs": {
    "prompt": "your prompt here",
    "outputs": ["gif"]
  }
}
```

---

## Core Request Parameters

| Parameter | Type | Default | Description |
|----------|------|---------|-------------|
| `prompt` | string | required | Text description of the video. |
| `negative_prompt` | string | "" | What to avoid in the output. |
| `num_frames` | int | 32 | Total frames generated. |
| `fps` | int | 12 | Playback speed (GIF/WebM). |
| `height` | int | 512 | Frame height. |
| `width` | int | 512 | Frame width. |
| `seed` | int | null | Reproducibility. |
| `outputs` | array | ["gif"] | Any of: `"gif"`, `"webm"`, `"zip"`. |
| `return_base64` | bool | true | Returns base64 file data in JSON. |
| `num_inference_steps` | int | 30 | Quality vs speed tradeoff. |
| `guidance_scale` | float | 7.5 | Prompt adherence strength. |

---

## Output Configuration

### GIF Options

```json
"gif": {
  "fps": 10
}
```

### WebM Options

```json
"webm": {
  "fps": 24,
  "quality": "good"
}
```

Quality levels:

- `"fast"` — fastest encoding
- `"good"` — balanced (recommended)
- `"best"` — highest quality, slower

### ZIP Output

ZIP always contains PNG frames:

```
frame_000000.png
frame_000001.png
...
```

---

## Response Format

Successful response:

```json
{
  "ok": true,
  "outputs": {
    "gif_base64": "...",
    "webm_base64": "...",
    "zip_base64": "..."
  }
}
```

Error response:

```json
{
  "ok": false,
  "error": "message"
}
```

---

## Best Practices

- Use `jq -er` when decoding base64 to prevent corrupted files
- Start with 16–32 frames for fast testing
- Use WebM for high quality playback
- Use ZIP when post‑processing frames externally

---

# Example curl Commands

These commands save files **directly** without storing JSON.

Replace `YOUR_HF_TOKEN`.

---

## GIF Test

```bash
curl -sS -X POST "https://cyjm1rsdzy6la31w.us-east-1.aws.endpoints.huggingface.cloud" \
  -H "Authorization: Bearer YOUR_HF_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "inputs": {
      "prompt": "cinematic sunset over mountains",
      "num_frames": 20,
      "fps": 10,
      "outputs": ["gif"]
    }
  }' \
| jq -er '.outputs.gif_base64' \
| base64 --decode > output.gif
```

---

## WebM Test

```bash
curl -sS -X POST "https://cyjm1rsdzy6la31w.us-east-1.aws.endpoints.huggingface.cloud" \
  -H "Authorization: Bearer YOUR_HF_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "inputs": {
      "prompt": "drone flying through clouds",
      "num_frames": 32,
      "fps": 24,
      "outputs": ["webm"],
      "webm": { "quality": "good" }
    }
  }' \
| jq -er '.outputs.webm_base64' \
| base64 --decode > output.webm
```

---

## ZIP Frames Test

```bash
curl -sS -X POST "https://cyjm1rsdzy6la31w.us-east-1.aws.endpoints.huggingface.cloud" \
  -H "Authorization: Bearer YOUR_HF_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "inputs": {
      "prompt": "ocean waves crashing",
      "num_frames": 16,
      "outputs": ["zip"]
    }
  }' \
| jq -er '.outputs.zip_base64' \
| base64 --decode > frames.zip
```

Unzip:

```bash
unzip frames.zip
```

---

## Multiple Outputs Test

```bash
curl -sS -X POST "https://cyjm1rsdzy6la31w.us-east-1.aws.endpoints.huggingface.cloud" \
  -H "Authorization: Bearer YOUR_HF_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "inputs": {
      "prompt": "cinematic space nebula",
      "num_frames": 24,
      "fps": 12,
      "outputs": ["gif", "webm", "zip"],
      "webm": { "quality": "good" }
    }
  }' \
  -o response.json
```

Extract:

```bash
jq -er '.outputs.gif_base64' response.json | base64 --decode > output.gif
jq -er '.outputs.webm_base64' response.json | base64 --decode > output.webm
jq -er '.outputs.zip_base64' response.json | base64 --decode > frames.zip
```

---

## Troubleshooting

### Corrupted Files

Inspect JSON first:

```bash
jq . response.json
```

Ensure:

```
"ok": true
```

### Large Outputs

Reduce:

- `num_frames`
- resolution

Or upload files to cloud storage and return a download URL.

---

## Suggested Defaults

```
num_frames: 24–32
fps: 12 (GIF) / 24 (WebM)
resolution: 512x512
quality: "good"
```