HuggingFace 503: Model is Currently Loading
The free-tier Inference API cold-starts models on demand. You will see a 503 Service Unavailable with "Model is currently loading" every time a model has been idle. Here is how to handle it properly.
HuggingFace Inference API — live status
Updated every 5 minutes · Full incident history →
What the error looks like
When you hit the HuggingFace Inference API and the model is not yet loaded, you get a HTTP 503 with a JSON body:
HTTP/1.1 503 Service Unavailable
{
"error": "Model meta-llama/Llama-3-8b-hf is currently loading",
"estimated_time": 47.3
} The key field is estimated_time — it is the number of seconds until the model is ready. This is not an outage. It is a normal cold-start on the shared free tier. The fix is to wait and retry.
Step 1 — Poll until ready with estimated_time
Do not retry immediately — it will still be loading. Read estimated_time, sleep that many seconds, then retry. Cap at 10 attempts for large models that take several minutes.
import requests
import time
API_URL = "https://api-inference.huggingface.co/models/meta-llama/Llama-3-8b-hf"
HEADERS = {"Authorization": "Bearer hf_YOUR_TOKEN"}
def query_with_retry(payload, max_retries=10):
for attempt in range(max_retries):
response = requests.post(API_URL, headers=HEADERS, json=payload)
if response.status_code == 200:
return response.json()
if response.status_code == 503:
data = response.json()
wait_seconds = data.get("estimated_time", 20)
print(f"Model loading, waiting {wait_seconds:.0f}s (attempt {attempt + 1}/{max_retries})...")
time.sleep(wait_seconds + 2) # add 2s buffer
continue
# Other errors (401, 429, etc.) — raise immediately
response.raise_for_status()
raise TimeoutError("Model did not load after max retries")
result = query_with_retry({"inputs": "Hello, how are you?"})
print(result) The + 2 buffer accounts for the estimate being slightly optimistic. For models over 30B, set max_retries=20 since loading can take 5–10 minutes.
Step 2 — Use wait_for_model to skip polling code
HuggingFace's huggingface_hub Python library and the raw HTTP API both support a parameter that tells the server to block until the model is ready instead of returning 503 immediately:
from huggingface_hub import InferenceClient
client = InferenceClient(
model="meta-llama/Llama-3-8b-hf",
token="hf_YOUR_TOKEN"
)
# wait_for_model=True blocks until the model is warm (up to ~10 min)
result = client.text_generation(
"Explain transformers in one sentence.",
wait_for_model=True,
timeout=600
)
print(result) For raw HTTP, pass the parameter in the request body:
payload = {
"inputs": "Explain transformers in one sentence.",
"options": {"wait_for_model": True}
}
response = requests.post(API_URL, headers=HEADERS, json=payload, timeout=600) Step 3 — Know loading times by model size
Loading time is dominated by how long it takes to move weights from storage into GPU VRAM. Rough estimates on the free shared tier:
| Model size | Approx. weight size | Typical cold-start | Example models |
|---|---|---|---|
| Under 1B | <2 GB | 10–30 s | distilbert, gpt2, flan-t5-small |
| 1B–7B | 2–14 GB | 30–90 s | Llama-3-8B, Mistral-7B, Phi-3-mini |
| 13B–34B | 14–70 GB | 2–5 min | CodeLlama-34B, Llama-2-13B |
| 70B+ | 140+ GB | 5–10 min | Llama-3-70B, Mixtral 8x22B |
For 70B+ models on the free shared API, cold starts are impractical for production use. See Step 5 for dedicated alternatives.
Step 4 — Pick always-warm models to avoid 503 entirely
HuggingFace keeps a set of high-traffic models warm at all times on the free tier. These never return a loading 503:
distilbert-base-uncased Classification / NER
sentence-transformers/all-MiniLM-L6-v2 Embeddings
facebook/bart-large-mnli Zero-shot classification
openai-community/gpt2 Text generation
google/flan-t5-xxl Instruction following
black-forest-labs/FLUX.1-schnell Image generation (sometimes warm)
To verify a model is hosted on the free API: open its model card on huggingface.co and look for the "Hosted inference API" panel on the right sidebar. If it shows an interactive widget, the model is available. If it says "This model is not currently available via the Inference API", it must be self-hosted or used via Endpoints.
Step 5 — Inference API vs Inference Endpoints: which to use
| Shared Inference API (free) | Inference Endpoints (dedicated) | |
|---|---|---|
| Cold starts | Yes — 503 on idle models | No — model stays warm |
| Cost | Free (rate limited) | $0.06–$4.50/hr per instance |
| SLA | None | 99.9% uptime guarantee |
| Autoscaling | Shared pool | Scale to 0 or N replicas |
| Model support | Curated subset | Any HF model |
Create a Dedicated Endpoint at ui.endpoints.huggingface.co. The endpoint URL is https://[id].us-east-1.aws.endpoints.huggingface.cloud/ — use it identically to the shared API, but with no 503 cold starts.
Step 6 — Use Groq or Together.ai for zero-latency open model inference
For Llama 3, Mistral, Mixtral, and Gemma, third-party hosted inference providers eliminate cold starts entirely and are often faster than HuggingFace Endpoints:
Groq — fastest inference
Custom LPU hardware. 500–750 tokens/sec on 70B models. No cold starts. OpenAI-compatible API.
Supported: Llama 3.3 70B, Llama 3.1 8B, Mixtral 8x7B, Gemma 2 9B, Whisper large-v3
Together.ai — widest model selection
100+ open models, dedicated fine-tune deployments, competitive pricing. OpenAI-compatible.
Supported: Llama 3, Mistral, Mixtral, Falcon, Qwen, DBRX, and many more
Both use the OpenAI SDK — just swap the base URL and API key:
# Groq — drop-in replacement for HuggingFace Inference API
from groq import Groq
client = Groq(api_key="gsk_YOUR_GROQ_KEY")
response = client.chat.completions.create(
model="llama-3.3-70b-versatile",
messages=[{"role": "user", "content": "Explain transformers"}]
)
print(response.choices[0].message.content) # Together.ai — same OpenAI-compatible interface
from openai import OpenAI
client = OpenAI(
api_key="YOUR_TOGETHER_KEY",
base_url="https://api.together.xyz/v1"
)
response = client.chat.completions.create(
model="meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo",
messages=[{"role": "user", "content": "Explain transformers"}]
)
print(response.choices[0].message.content) Get an email the next time Hugging Face goes down
Outage alerts for Hugging Face, straight to your inbox. No account needed, unsubscribe in every email.
Watching more than one service? A free account covers 5 services + a daily digest — and Pro is currently free.
Frequently asked questions
Why does HuggingFace Inference API return 503 Model is currently loading?
The free shared Inference API loads models on demand and unloads them when idle to share GPU capacity across users. When you send a request to a model that is not currently loaded, the API returns 503 with an estimated_time field telling you how many seconds to wait. This is normal behavior, not an outage.
How long does HuggingFace model loading take?
Small models (under 1B) load in 10–30 seconds. Medium 7B models take 30–90 seconds. Large 70B models can take 5–10 minutes. The 503 response body includes estimated_time in seconds — use that value plus a 2-second buffer as your sleep duration before retrying.
Which HuggingFace models are always warm on the free tier?
distilbert-base-uncased, sentence-transformers/all-MiniLM-L6-v2, facebook/bart-large-mnli, openai-community/gpt2, and google/flan-t5-xxl are reliably warm. Check a model card's right sidebar for the "Hosted inference API" interactive widget — if the widget is present, the model is available (though may still cold-start if rarely used).
What is the difference between HuggingFace Inference API and Inference Endpoints?
The shared Inference API (free) cold-starts models on demand — you get 503 on idle models. Inference Endpoints are dedicated GPU instances you provision: the model stays warm 24/7, you control instance type and autoscaling, but pay per hour. Use Endpoints for production workloads where cold-start latency is unacceptable.