File size: 6,571 Bytes
54ed165
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
# πŸš€ Vercel Deployment Guide

## βœ… Your Project is Ready for Vercel!

All files have been created and pushed to GitHub. You now have:
- βœ… Serverless API functions in `/api`
- βœ… Frontend with relative API calls
- βœ… Support for 5 AI models (including 10s videos!)
- βœ… package.json with dependencies

---

## πŸ“‹ Quick Deploy (5 minutes)

### Method 1: Vercel Dashboard (Easiest)

1. **Go to Vercel**
   - Visit: https://vercel.com
   - Sign in with GitHub

2. **Import Project**
   - Click "Add New" β†’ "Project"
   - Select "Import Git Repository"
   - Choose: `LakshmiSravya123/VideoAI`

3. **Configure Project**
   - **Root Directory:** `hailuo-clone` ⚠️ IMPORTANT!
   - **Framework Preset:** None
   - **Build Command:** (leave empty)
   - **Output Directory:** (leave empty)

4. **Add Environment Variable**
   - Click "Environment Variables"
   - Key: `REPLICATE_API_TOKEN`
   - Value: `r8_YOUR_TOKEN_HERE` (from https://replicate.com/account/api-tokens)
   - Apply to: Production, Preview, Development

5. **Deploy**
   - Click "Deploy"
   - Wait 1-2 minutes
   - You'll get a URL like: `https://video-ai-xyz.vercel.app`

6. **Test**
   - Visit: `https://your-url.vercel.app/index_enhanced.html`
   - Try generating a video!

---

### Method 2: Vercel CLI (Advanced)

```bash
# Install Vercel CLI
npm install -g vercel

# Navigate to project
cd /Users/sravyalu/VideoAI/hailuo-clone

# Deploy
vercel

# Follow prompts:
# - Link to existing project or create new
# - Confirm settings
# - Add REPLICATE_API_TOKEN when prompted

# Deploy to production
vercel --prod
```

---

## 🎬 Available Models After Deployment

Your deployed app will have:

1. **Runway Gen-3** - 10 seconds ⭐ (longest!)
2. **Hailuo Video-01** - 6 seconds (best quality/price)
3. **CogVideoX-5B** - 6 seconds (good balance)
4. **HunyuanVideo** - 5+ seconds (SOTA)
5. **Luma Dream Machine** - 5 seconds (cinematic)

---

## πŸ”§ Post-Deployment Setup

### 1. Set Custom Domain (Optional)
- Vercel Dashboard β†’ Your Project β†’ Settings β†’ Domains
- Add: `video.yourdomain.com`
- Update DNS as instructed

### 2. Make index_enhanced.html the Homepage
Option A: Rename file
```bash
cd /Users/sravyalu/VideoAI/hailuo-clone
mv index_enhanced.html index.html
git add -A && git commit -m "Make enhanced UI the homepage" && git push
```

Option B: Add vercel.json
```json
{
  "rewrites": [
    { "source": "/", "destination": "/index_enhanced.html" }
  ]
}
```

### 3. Enable Analytics (Optional)
- Vercel Dashboard β†’ Your Project β†’ Analytics
- Enable Web Analytics
- Track usage and performance

---

## πŸ“Š API Endpoints

Your deployed app will have:

- `GET /api/health` - Check API status
- `GET /api/models` - List available models
- `POST /api/generate-video` - Generate videos

### Example API Call:
```bash
curl -X POST https://your-url.vercel.app/api/generate-video \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "A golden retriever running through flowers at sunset",
    "model": "runway"
  }'
```

---

## πŸ’° Cost Estimation

### Vercel Costs:
- **Hobby Plan:** FREE
  - 100GB bandwidth/month
  - Unlimited requests
  - Serverless functions included

### Replicate Costs (per video):
- **Runway Gen-3 (10s):** ~$0.20
- **Hailuo (6s):** ~$0.08
- **CogVideoX (6s):** ~$0.05
- **HunyuanVideo (5s):** ~$0.10
- **Luma (5s):** ~$0.10

**Example Monthly Cost:**
- 100 videos with Hailuo: ~$8
- 100 videos with Runway: ~$20
- Vercel hosting: FREE

---

## πŸ› Troubleshooting

### Issue: 404 on /api/generate-video
**Solution:** 
- Ensure Root Directory is set to `hailuo-clone`
- Check that `package.json` exists in that directory
- Redeploy

### Issue: 500 "Missing REPLICATE_API_TOKEN"
**Solution:**
- Add environment variable in Vercel Dashboard
- Settings β†’ Environment Variables
- Redeploy after adding

### Issue: Functions timeout
**Solution:**
- Video generation can take 30-120 seconds
- Vercel Hobby: 10s timeout (may fail for long videos)
- Upgrade to Pro for 60s timeout
- Or use webhook/polling pattern

### Issue: CORS errors
**Solution:**
- Should not happen (same-origin)
- If using custom domain, ensure it's properly configured

### Issue: Slow first request
**Solution:**
- Cold start is normal (2-5 seconds)
- Subsequent requests are faster
- Consider keeping functions warm with cron job

---

## πŸ”’ Security Best Practices

### βœ… Already Implemented:
- API token in environment variables (not in code)
- .gitignore excludes .env files
- Serverless functions are isolated

### 🎯 Recommended:
1. **Rate Limiting:** Add rate limiting to prevent abuse
2. **Authentication:** Add user auth for production
3. **Input Validation:** Already implemented in API
4. **Monitoring:** Enable Vercel Analytics

---

## πŸ“ˆ Scaling

### Current Setup:
- βœ… Serverless (auto-scales)
- βœ… No server management
- βœ… Pay per use

### For High Traffic:
1. **Add Caching:** Cache model metadata
2. **Add Queue:** Use queue for video generation
3. **Add Database:** Store generation history
4. **Add CDN:** Serve videos via CDN

---

## 🎯 Next Steps After Deployment

1. **Test All Models**
   - Try each model (runway, hailuo, cogvideox, etc.)
   - Test different prompts
   - Verify video quality

2. **Share Your App**
   - Share the Vercel URL
   - Add to your portfolio
   - Share on social media

3. **Monitor Usage**
   - Check Vercel Analytics
   - Monitor Replicate costs
   - Track popular models

4. **Iterate**
   - Add more features
   - Improve UI
   - Add user accounts

---

## πŸ“ Deployment Checklist

Before deploying:
- [x] API functions created (`/api/*.js`)
- [x] package.json with dependencies
- [x] Frontend updated to use `/api` endpoints
- [x] .gitignore excludes sensitive files
- [x] All changes pushed to GitHub
- [ ] Replicate API token ready
- [ ] Vercel account created
- [ ] Project imported to Vercel
- [ ] Environment variable added
- [ ] Deployment successful
- [ ] Test video generation works

---

## πŸŽ‰ You're Ready!

Your project is fully prepared for Vercel deployment with:
- βœ… 5 AI models (up to 10s videos)
- βœ… Beautiful animated UI
- βœ… Serverless architecture
- βœ… Complete documentation
- βœ… GitHub repository

**Just deploy and start generating videos! πŸš€βœ¨**

---

## πŸ“ž Support

If you encounter issues:
1. Check this guide's troubleshooting section
2. Review Vercel logs in Dashboard
3. Check GitHub Issues
4. Vercel Discord: https://vercel.com/discord

**Your deployment URL will be:**
`https://video-ai-[random].vercel.app`

(You can customize this in Vercel settings)