Quick answer: Hugging Face Spaces gives you free, no-credit-card hosting for AI demos: a public *.hf.space URL, Git-push deploys, a 2 vCPU / 16 GB CPU container, and — via ZeroGPU — time-sliced access to a shared Nvidia A100 80GB. Free CPU is unmetered; free GPU is quota-capped in seconds per day. No other consumer host hands you a real datacenter GPU for $0.
Spaces is the most under-used free platform in AI hosting. The catch: it’s built for one job — hosting an interactive AI demo. It’s not a generic VPS, a 24/7 backend, or a place for a multi-page Next.js app. Used in its lane, it replaces a pipeline that would cost $20-50/month on Render or Railway.
Free Tier at a Glance
| Resource | Free Tier Includes | Notes |
|---|---|---|
| Hardware | CPU Basic: 2 vCPU, 16 GB RAM | Default; no payment method required |
| Storage | ~50 GB ephemeral disk | Wiped on each rebuild; use the Hub for weights |
| Bandwidth | Unmetered (fair use) | No published hard cap |
| Build minutes | Unmetered | Triggered by every Git push |
| Sleep policy | Sleeps after 48 hours idle | First visit wakes it; cold start ~30-90s |
| GPU access | ZeroGPU — Nvidia A100 80GB | Free, shared, time-sliced via @spaces.GPU
|
| ZeroGPU quota (free) | Limited daily seconds | Visible in account settings; resets daily |
| ZeroGPU quota (Pro $9/mo) | ~8x higher daily seconds | Same hardware, more time |
| Region | Not user-selectable | Free Spaces run on Hugging Face’s managed infrastructure; no region picker — check current docs |
| Commercial use | Allowed | No non-commercial clause, but the free tier gives no uptime guarantee |
| Custom domain | Paid Pro feature | Free Spaces serve from *.hf.space only |
| Private Spaces | Paid Pro feature | Free Spaces are public by default |
| SDKs supported | Gradio, Streamlit, Docker, Static, JupyterLab | All work on free CPU; ZeroGPU is Gradio + Docker |
The short version: free CPU is unlimited and unmetered; free GPU is shared and quota-capped. For a hobby demo run a few times a day, the free tier is genuinely free forever.
How Spaces Works
Every Space is a Git repo on huggingface.co. You push code, the Hub builds a Docker image, and a container starts behind a public hf.space URL. Two design decisions make it unusual:
-
Git is the deploy interface. No
deployCLI, no build panel — push tomainand the Space rebuilds, the way Vercel, Netlify, and Cloudflare Pages work, except Hugging Face hosts the Git remote itself. -
Weights live on the Hub, not in your image. A 7B model is 14 GB. Instead of bundling it, the SDK pulls weights at runtime via
huggingface_hub, cached on a shared layer so rebuilds don’t re-download.
The result fits the shape of an AI demo, not a generic web app.
The ZeroGPU System
ZeroGPU is what makes Spaces different from every other free host. You don’t reserve a GPU; your Space declares which functions need one, and a scheduler allocates a pooled A100 for the duration of that call:
- Your Space runs on the CPU container by default.
- Functions decorated with
@spaces.GPUget pulled into a GPU worker when invoked. - Each call counts against your daily quota, measured in seconds of actual GPU time.
- Cold-start to an A100 worker is typically under 5 seconds, often under 2.
- Free accounts get a smaller daily quota than Pro ($9/mo), but ZeroGPU is not paywalled.
This works because AI demos are bursty — a model runs inference for a few seconds, then sits idle while a human reads the output. ZeroGPU multiplexes those bursts across many Spaces, charging quota only for compute seconds. For a hobbyist, that means a real image-gen demo, a Whisper tool, or a fine-tuned 7B chatbot on a public A100-backed URL, at no cost.
Pick an SDK
- Gradio — the default for ~90% of Spaces. Built by Hugging Face, deepest ZeroGPU integration (one-line decorator), best for demos with sliders, image/audio inputs, or a chat UI.
- Streamlit — best for data-heavy dashboards over a DataFrame. Does not officially support ZeroGPU; prefer Gradio for inference demos.
-
Docker — for anything the framework SDKs can’t do: FastAPI backend, custom React frontend, non-Python runtime. Must listen on port 7860. Supports ZeroGPU via the
spacespackage. - Static — a single-page HTML demo with no server (transformers.js, WebGPU). No container, no cold start, no quota.
- JupyterLab — a hosted notebook on a public URL. Less used, since Colab and Kaggle cover the same niche with free GPUs.
Deploy Your First Space (Gradio)
Create a free account at huggingface.co/join, choose New Space, pick Gradio + CPU Basic — Free + Public. You now have a Git repo. Clone it and add code:
git clone https://huggingface.co/spaces/your-name/your-space
cd your-space
app.py:
import gradio as gr
from transformers import pipeline
pipe = pipeline("sentiment-analysis", model="distilbert-base-uncased-finetuned-sst-2-english")
def classify(text):
result = pipe(text)[0]
return f"{result['label']} ({result['score']:.2%})"
demo = gr.Interface(
fn=classify,
inputs=gr.Textbox(label="Your text"),
outputs=gr.Textbox(label="Sentiment"),
title="Sentiment Analysis Demo",
examples=["I loved this movie.", "The plot was a mess."],
)
if __name__ == "__main__":
demo.launch()
requirements.txt:
gradio
transformers
torch
Then push:
git add app.py requirements.txt
git commit -m "Initial sentiment demo"
git push
Within 30-60 seconds the Space builds and your demo is live at your-name-your-space.hf.space. The Hub generates a TLS URL, pulls the weights automatically, and serves the app behind a queue. Every subsequent git push redeploys. No dashboard, no DNS step.
Using ZeroGPU: One Decorator, One Setting
DistilBERT runs fine on free CPU. ZeroGPU earns its keep on models that need a GPU — Stable Diffusion, Whisper, Llama 3, Flux. To enable it: switch hardware to ZeroGPU in settings, add the spaces package to requirements.txt, and decorate the heavy function:
import gradio as gr
import spaces
import torch
from diffusers import StableDiffusionPipeline
pipe = StableDiffusionPipeline.from_pretrained(
"runwayml/stable-diffusion-v1-5",
torch_dtype=torch.float16,
).to("cuda")
@spaces.GPU(duration=60)
def generate(prompt: str):
image = pipe(prompt, num_inference_steps=25).images[0]
return image
demo = gr.Interface(
fn=generate,
inputs=gr.Textbox(label="Prompt"),
outputs=gr.Image(label="Generated"),
)
demo.launch()
Three things to notice:
-
duration=60is the max seconds the call may hold the GPU (default 60). Set it lower for fast functions so quota accounting is accurate, higher for slow ones to avoid timeouts. - The pipeline loads at module level, outside the decorated function — ZeroGPU moves the loaded model to the GPU worker on call, then back. Load once, dispatch many times.
- Quota is consumed in seconds of actual runtime: a 4-second generation costs 4 seconds, not 60. Free quota resets every 24 hours.
Limits and Gotchas
- Sleep after 48h idle. The next visitor triggers a 30-90s cold start. Fine for personal demos; there’s no free “always-on” setting.
- Storage is ephemeral. The ~50 GB disk is wiped on every rebuild. For persistent state, pay $5/mo for the Persistent Storage add-on or use an external store (Supabase, Neon, S3, a Hub dataset). Hub-pulled weights are cached and not re-downloaded.
-
Port 7860 is hardcoded. Gradio/Streamlit do this by default; Docker Spaces must
EXPOSE 7860. - Public repos by default. Never hardcode keys — use Settings → Secrets, which injects them as env vars at runtime without committing them.
- Quota is a per-account pool shared across all your ZeroGPU Spaces. One busy Space starves the others. Pro’s ~8x quota is the main reason heavy demo-shippers upgrade.
-
No custom domain on free. You get
username-spacename.hf.space. Custom domains are Pro-only.
Spaces vs Alternatives
- vs Google Colab — Colab gives an interactive T4 notebook, but no public URL others can hit. Use Colab to experiment; use Spaces to share the result.
- vs Replicate — Replicate serves a model as a per-second API with no UI (and no free tier). Spaces ships the UI; Replicate ships the API.
- vs Modal — Modal is Python-native serverless GPU with monthly free credits and no built-in UI. Spaces is “AI demo on a GPU”; Modal is “Python function on a GPU.”
- vs Ollama — Ollama runs models locally, fully private, on your own hardware. Use it for local/private work; use Spaces when you need a public URL.
- vs Cloudflare Workers AI — Workers AI serves a fixed catalog of pre-deployed models; you can’t upload a fine-tune. For your own trained model, Spaces is the only option of the two.
Decision tree
- Share an AI demo with a public URL? → Spaces
- Private API endpoint billed per call? → Replicate or Modal
- 24/7 production backend with custom domain + SLA? → Render, Railway, or a real cloud
- Free GPU for personal experimentation only? → Google Colab or Kaggle
- Keep weights and inference private? → Ollama on your own hardware
What the Free Tier Comfortably Handles
-
Demo a fine-tuned model — a 50-line Gradio chat +
@spaces.GPU= a public 7B chatbot in 20 minutes. -
Image generation — Stable Diffusion, Flux, Kandinsky: pipeline at module level,
@spaces.GPUon generate,gr.Imageoutput. -
Whisper transcription —
openai/whisper-large-v3; the free A100 does ~30 min of audio in ~30s. Pairs with the free Whisper APIs we benchmarked. - RAG Q&A — a free embedding model + in-memory Chroma + a free LLM, chunks held in RAM. See our free vector database guide for production alternatives.
- Side-by-side model comparison — two pipelines, one input, two columns.
For anything past toy demos, instrument with a free tracing layer like Langfuse — a few import lines wrap every model call for prompt, completion, latency, and cost.
Frequently Asked Questions
Do I need a credit card?
No. Free CPU Basic and ZeroGPU access work on accounts with no payment method. You only add a card to upgrade to a paid GPU tier or Pro plan.
Is ZeroGPU really free, and what GPU is it?
Yes — a daily quota measured in seconds of GPU time, on a time-sliced Nvidia A100 80GB. Free accounts get a smaller quota than Pro ($9/mo), but there’s no signup credit that runs out; the quota resets every 24 hours indefinitely. You don’t pick the GPU — the scheduler assigns one when your @spaces.GPU function is invoked.
Can I use Spaces as a backend API?
Sort of. A Gradio app exposes a REST endpoint at /api/predict, and a Docker Space can expose any FastAPI route — but the free tier gives no uptime guarantee. If customers pay to call this API, host on Replicate, Modal, or a real cloud.
How do I add an API key without leaking it?
Space → Settings → Variables and secrets → New secret. It’s exposed as an environment variable at runtime and never enters the Git repo. This is how you wire in OpenRouter, Together AI, or any paid API.
Getting Started
- Sign up for Hugging Face — 60 seconds.
- Create a new Gradio Space on the free CPU tier.
- Push the sentiment snippet above and watch it deploy. Add
@spaces.GPUwhen you need the A100. The price stays zero.
Related Reads
- 7 Best Free Web Hosting Platforms for Developers in 2026
- Render Free Hosting Review 2026: Deploy Web Apps, Databases, and Cron Jobs for Free
- Vercel vs Netlify vs Cloudflare Pages: Free Frontend Hosting Compared
- Ollama: Run AI Models Locally for Free
- Langfuse: Free Open-Source LLM Observability
Originally published at toolfreebie.com.
Top comments (0)