Skip to main content

Build machine learning web apps — in Python

Gradio is an open-source Python package that allows you to quickly build a demo or web application for your machine learning model, API, or any arbitrary Python function. You can then share a link to your demo or web application in just a few seconds using Gradio’s built-in sharing features. No JavaScript, CSS, or web hosting experience needed.

Why Gradio?

Fast development

Build and deploy ML web apps in just a few lines of Python code

Easy sharing

Share your demos instantly with a public link — no hosting required

Rich components

Choose from 30+ built-in components for ML applications

Flexible layouts

Create custom UIs with Blocks or use the simple Interface class

Key features

Quick to build

It just takes a few lines of Python to create your own demo. Here’s a complete Gradio app:
import gradio as gr

def greet(name, intensity):
    return "Hello, " + name + "!" * int(intensity)

demo = gr.Interface(
    fn=greet,
    inputs=["text", "slider"],
    outputs=["text"],
)

demo.launch()
This creates a web interface that opens in your browser at http://localhost:7860.

Share instantly

Gradio lets you easily share your demo without hosting on a web server. Simply set share=True in launch(), and a publicly accessible URL will be created:
demo.launch(share=True)  # Creates a public URL
You’ll get a link like https://a23dsf231adb.gradio.live that anyone can access while your app runs locally.

Three ways to build

Interface

High-level API for quick demos with inputs and outputs

Blocks

Low-level API for custom layouts and complex data flows

ChatInterface

Specialized API for building chatbot UIs quickly

Interface class

The Interface class is designed for machine learning models that accept one or more inputs and return one or more outputs. Perfect for quick demos:
import gradio as gr

demo = gr.Interface(
    fn=greet,
    inputs=["text", "slider"],
    outputs=["text"],
)

Blocks class

The Blocks class offers a low-level approach for designing web apps with customizable layouts and data flows. You can control where components appear on the page, handle complex interactions, and update component properties dynamically:
import gradio as gr

def welcome(name):
    return f"Welcome to Gradio, {name}!"

with gr.Blocks() as demo:
    gr.Markdown("# Hello World!")
    inp = gr.Textbox(placeholder="What is your name?")
    out = gr.Textbox()
    inp.change(welcome, inp, out)
Complex applications like the popular Automatic1111 Web UI are built using Gradio Blocks.

ChatInterface class

The ChatInterface class is specifically designed to create chatbot UIs. Just provide a function and Gradio creates a fully working chatbot interface.

Rich ecosystem

Gradio is more than just a Python library — it’s an entire ecosystem:

Python Client

Query any Gradio app programmatically with gradio_client

JavaScript Client

Query any Gradio app from JavaScript with @gradio/client

Hugging Face Spaces

Host your Gradio apps for free on Hugging Face Spaces

Custom Components

Build and share your own custom Gradio components

Where to go next

Quickstart

Build your first Gradio app in minutes

Installation

Detailed installation instructions for all platforms
Gradio requires Python 3.10 or higher. You can run it in your favorite code editor, Jupyter notebook, Google Colab, or anywhere else you write Python.