Hugging Face Hub Storage Setup Guide
⚠️ Important Limitations
Hugging Face Hub will NOT solve Vercel's 2GB upload limit because:
- Files still go through Vercel serverless functions
- Vercel has a 4.5MB (free) / 50MB (Pro) request body limit
- Vercel has a 10-second (Hobby) / 60-second (Pro) timeout
For true 2GB uploads, you need:
- Direct client uploads (bypassing Vercel)
- Services like AWS S3, Cloudflare R2, or Backblaze B2 with pre-signed URLs
Setup Instructions
1. Create Hugging Face Account
- Go to https://huggingface.co/join
- Create a free account
2. Create a Repository
- Go to https://huggingface.co/new-dataset (or https://huggingface.co/new-model)
- Choose:
- Name:
voltedge-storage(or your preferred name) - Type: Dataset (recommended) or Model
- Visibility: Public (free unlimited) or Private (limited storage)
- Name:
- Click "Create repository"
3. Generate Access Token
- Go to https://huggingface.co/settings/tokens
- Click "New token"
- Set:
- Name:
VoltEdge Storage - Type: Write (needed for uploads)
- Name:
- Copy the token (you'll only see it once!)
4. Configure Environment Variables
Add to your .env.local or Vercel environment variables:
# Hugging Face Hub Configuration
HF_TOKEN=your_huggingface_token_here
HF_REPO_ID=your-username/voltedge-storage
HF_REPO_TYPE=dataset
USE_HF_STORAGE=true
Variables:
HF_TOKEN: Your Hugging Face access token (from step 3)HF_REPO_ID: Your repository ID (format:username/repo-name)HF_REPO_TYPE: Eitherdatasetormodel(default:dataset)USE_HF_STORAGE: Set totrueto enable HF Hub,falseto use Telegram
5. Deploy
After setting environment variables, redeploy your Vercel app. The system will:
- Use HF Hub if
USE_HF_STORAGE=trueand credentials are set - Fall back to Telegram if HF Hub fails or is not configured
How It Works
Upload Flow:
Client → Vercel API → HF Hub API → File stored in HF repositoryFile Access:
Client → Vercel API → HF CDN URL → File served from HF CDNStorage Location:
- Files are stored in:
files/{fileId}.{ext} - Accessible via:
https://cdn.huggingface.co/{repo-id}/main/files/{fileId}.{ext}
- Files are stored in:
Testing
- Set
USE_HF_STORAGE=truein your environment - Upload a small file (< 50MB) via the web interface
- Check your HF repository to see the uploaded file
- Access the file via the generated URL
Troubleshooting
Error: "Hugging Face credentials not configured"
- Check that
HF_TOKENandHF_REPO_IDare set - Verify the token has "Write" permissions
Error: "Repository not found"
- Check
HF_REPO_IDformat:username/repo-name - Ensure the repository exists and is accessible
Upload fails for large files
- This is expected! Vercel limits apply
- Files > 50MB will fail on Vercel
- Consider using direct client uploads (S3, R2, etc.)
Files not appearing in repository
- Check HF Hub API rate limits
- Verify token permissions
- Check repository visibility settings
Rate Limits
- Free Tier: ~1000 API calls/hour
- Bandwidth: ~10GB/month download
- Upload: No hard limit, but rate-limited
Alternative: Direct Client Uploads
For true 2GB support, consider:
- Cloudflare R2: Free tier, S3-compatible, pre-signed URLs
- AWS S3: Industry standard, pre-signed URLs
- Backblaze B2: Cheap, S3-compatible
These allow direct client uploads, bypassing Vercel completely.