bskrishna2006
Initial backend deployment
dfbb2da

πŸš€ 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
  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

  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:

# 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:

curl https://YOUR_USERNAME-youtube-summarizer-api.hf.space/api/health

Test full pipeline:

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:

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?