File size: 3,721 Bytes
dfbb2da
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# 🚀 Deploying to Hugging Face Spaces

This guide will help you deploy the YouTube Summarizer API to Hugging Face Spaces for FREE cloud hosting.

## Prerequisites

1. A [Hugging Face account](https://huggingface.co/join)
2. Git installed on your system
3. Your Groq API key (from https://console.groq.com)

---

## Step 1: Create a Hugging Face Space

1. Go to [huggingface.co/new-space](https://huggingface.co/new-space)

2. Fill in the form:
   - **Owner**: Select your username
   - **Space name**: `youtube-summarizer-api`
   - **License**: MIT
   - **SDK**: Select **Docker**
   - **Hardware**: CPU basic (Free)
   - Leave other options as default

3. Click **"Create Space"**

---

## Step 2: Clone and Push

Open PowerShell/Terminal and run:

```powershell
# Navigate to the deploy folder
cd "c:\Users\Krishna\Desktop\Updated Yt summarizer\backend\deploy"

# Initialize git repository
git init

# Add Hugging Face as remote (replace YOUR_USERNAME with your HF username)
git remote add origin https://huggingface.co/spaces/YOUR_USERNAME/youtube-summarizer-api

# Add all files
git add .

# Commit
git commit -m "Initial deployment"

# Push to Hugging Face (you'll be prompted for credentials)
git push -u origin main
```

**For authentication**, you'll need to use:
- Username: Your Hugging Face username
- Password: Your Hugging Face Access Token (create one at Settings → Access Tokens)

---

## Step 3: Add Your Groq API Key

1. Go to your Space: `https://huggingface.co/spaces/YOUR_USERNAME/youtube-summarizer-api`

2. Click **Settings** (gear icon)

3. Scroll to **Variables and secrets**

4. Click **"New secret"** and add:
   - **Name**: `GROQ_API_KEY`
   - **Value**: Your Groq API key

5. Click **Save**

---

## Step 4: Wait for Build

The first build takes **10-15 minutes** because it:
1. Builds the Docker image
2. Installs all dependencies
3. Sets up the environment

You can watch the build progress in the "Logs" tab of your Space.

---

## Step 5: Test Your API

Once the status shows **"Running"**, your API is live!

### Test health check:
```bash
curl https://YOUR_USERNAME-youtube-summarizer-api.hf.space/api/health
```

### Test full pipeline:
```bash
curl -X POST https://YOUR_USERNAME-youtube-summarizer-api.hf.space/api/process \
  -H "Content-Type: application/json" \
  -d '{"url": "https://www.youtube.com/watch?v=jNQXAC9IVRw", "summary_type": "general"}'
```

---

## Step 6: Update Your Frontend

Update your frontend `.env` file:

```env
VITE_API_URL=https://YOUR_USERNAME-youtube-summarizer-api.hf.space
```

Then restart your frontend dev server.

---

## Troubleshooting

### Build Failed?
- Check the "Logs" tab for error messages
- Make sure all files are properly committed

### API Not Responding?
- The Space may be sleeping (wakes up on first request, takes ~30s)
- Check if GROQ_API_KEY secret is set

### Out of Memory?
- The free tier has 16GB RAM, which should be enough
- Consider upgrading to paid tier if needed

---

## API Endpoints Summary

| Endpoint | Method | Description |
|----------|--------|-------------|
| `/` | GET | Health check |
| `/api/health` | GET | Detailed status |
| `/api/languages` | GET | Supported languages |
| `/api/transcript` | POST | Extract transcript |
| `/api/translate` | POST | Translate text |
| `/api/summarize` | POST | Generate summary |
| `/api/process` | POST | Full pipeline |

---

## Cost

| Tier | Cost | RAM | GPU |
|------|------|-----|-----|
| **Free** | $0 | 16GB | CPU only |
| Upgraded | $0.60/hr | 16GB | GPU |

The free tier is sufficient for this application!

---

## Need Help?

- Hugging Face Docs: https://huggingface.co/docs/hub/spaces
- Docker Spaces: https://huggingface.co/docs/hub/spaces-sdks-docker