Hugging Face's logo
Join the Hugging Face community

and get access to the augmented documentation experience

to get started

Spaces Overview

Hugging Face Spaces make it easy for you to create and deploy ML-powered demos in minutes. Watch the following video for a quick introduction to Spaces:

In the following sections, you’ll learn the basics of creating a Space, configuring it, and deploying your code to it.

Creating a new Space

To make a new Space, visit the Spaces main page and click on Create new Space. Along with choosing a name for your Space, selecting an optional license, and setting your Space’s visibility, you’ll be prompted to choose the SDK for your Space. The Hub offers four SDK options: Gradio, Streamlit, Docker and static HTML. If you select “Gradio” as your SDK, you’ll be navigated to a new repo showing the following page:

Under the hood, Spaces stores your code inside a git repository, just like the model and dataset repositories. Thanks to this, the same tools we use for all the other repositories on the Hub (git and git-lfs) also work for Spaces. Follow the same flow as in Getting Started with Repositories to add files to your Space. Each time a new commit is pushed, the Space will automatically rebuild and restart.

For step-by-step tutorials to creating your first Space, see the guides below:

Hardware resources

Each Spaces environment is limited to 16GB RAM, 2 CPU cores and 50Gb of (not persistent) disk space by default, which you can use free of charge. You can upgrade to better hardware, including a variety of GPU accelerators, for a competitive price. To request an upgrade, please click the Settings button in your Space and select your preferred hardware environment.

Hardware CPU Memory Disk Hourly Price
CPU Basic 2 vCPU 16 GB 50 GB Free!
CPU Upgrade 8 vCPU 32 GB 50 GB $0.03
Nvidia T4 - small 4 vCPU 15 GB 50 GB $0.06
Nvidia T4 - medium 8 vCPU 30 GB 100 GB $0.09
Nvidia A10G - small 4 vCPU 15 GB 110 GB $1.05
Nvidia A10G - large 12 vCPU 46 GB 200 GB $3.15
Nvidia A100 - large 12 vCPU 142 GB 1000 GB $4.13

Do you have an awesome Space but need help covering the GPU hardware upgrade costs? We love helping out those with an innovative Space so please feel free to apply for a community GPU grant using the link in the Settings tab of your Space and see if yours makes the cut!

Read more in Spaces GPU Upgrades.

Managing secrets

If your app requires secret keys or tokens, don’t hard-code them inside your app! Instead, go to the Settings page of your Space repository and enter your secrets there. The secrets will be exposed to your app with Streamlit Secrets Management if you use Streamlit, and as environment variables in other cases. For Docker Spaces, please check out secret management with Docker.

Networking

If your Space needs to make any network requests, you can make requests through the standard HTTP and HTTPS ports (80 and 443) along with port 8080. Any requests going to other ports will be blocked.

Lifecycle management

On free hardware, your Space will “go to sleep” and stop executing after a period of time if unused. If you wish for your Space to run indefinitely, consider upgrading to a paid hardware. You can also manually pause your Space from the Settings tab. A paused Space stops executing until manually restarted by its owner. Paused time is not billed.

Helper environment variables

In some cases, you might be interested in having programmatic access to the Space author or repository name. This feature is particularly useful when you expect users to duplicate your Space. To help with this, Spaces exposes different environment variables at runtime. Given a Space osanseviero/i-like-flan:

  • SPACE_AUTHOR_NAME: osanseviero
  • SPACE_REPO_NAME: i-like-flan
  • SPACE_TITLE: I Like Flan (specified in the README file)
  • SPACE_ID: osanseviero/i-like-flan