C.W.K.
Stream
Lesson 04 of 04 · published

Secrets, Hardware Tiers, and Persistent Storage

~24 min · spaces, ops, secrets

Level 0Scout
0 XP0/50 lessons0/10 achievements
0/120 XP to next level120 XP to go0% complete

Secrets are environment variables

The Space settings page has a "Secrets" panel. Anything you put there is exposed as an environment variable in the running container — available via os.environ['HF_TOKEN'], os.environ['OPENAI_API_KEY'], etc. They're encrypted at rest, masked in logs, and never appear in the repo.

Hardware tiers

TierHardwareUse case
CPU Basic (free)2 vCPU, 16GB RAMDemos, small Transformers, classical ML.
CPU Upgrade8 vCPU, 32GB RAMBigger CPU workloads.
T4 small1 T4 (16GB)1-3B inference, simple Stable Diffusion.
A10G1 A10 (24GB)7B inference, SDXL, Whisper-large.
A100 / H1001 A100 (80GB) / 1 H100 (80GB)30-70B inference (with quantization), training jobs.

Persistent storage

Free tier: scratch only — the container's filesystem evaporates on rebuild. Paid tiers (Persistent Storage Small/Medium/Large): a real disk at /data. Use it for: model caches, user uploads, fine-tune outputs you want to survive a redeploy.

Code

Use a secret in app code·python
import os
from huggingface_hub import InferenceClient

# 'HF_TOKEN' set in Space settings → Secrets
client = InferenceClient(token=os.environ["HF_TOKEN"])
Hardware + persistent storage in manifest·yaml
---
title: My Big Demo
sdk: docker
app_port: 7860
hardware: a10g-small
storage: small
---

External links

Exercise

Add a secret to one of your Spaces and verify it works in code. Upgrade a Space to T4 or A10G hardware (briefly — paid). Add persistent storage. Push a small model snapshot to /data. Restart the Space and verify the snapshot survives.

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.