AI/TLDR

Gradio

Build and share web demos for ML models in pure Python

Overview

Gradio is an open-source Python package that lets you build a demo or web app for a machine learning model, an API, or any Python function. It takes only a few lines of code, and you don't need any JavaScript, CSS, or web hosting experience.

It's aimed at ML engineers, researchers, and developers who want to put a UI in front of a function so others can try it. You wrap your function with a Gradio interface, pick input and output components, and Gradio renders the full web page for you.

As a data app builder, Gradio focuses on quick, model-facing demos. It ships more than 30 built-in components for common ML inputs and outputs (text, images, audio, and more) and includes a built-in sharing feature that creates a public link for your running app.

What it does

  • Wrap any Python function in a web UI with the gr.Interface class
  • Over 30 built-in components for inputs and outputs, including Textbox, Image, and HTML
  • One-line public sharing: set share=True in launch() to get a public URL
  • Runs anywhere you write Python: code editor, Jupyter notebook, or Google Colab
  • Hot reload mode: run with the gradio command instead of python to auto-reload on file changes
  • No JavaScript, CSS, or web hosting experience required

Getting started

Install Gradio with pip, then write a short Python script that wraps a function in an Interface and launches it.

Install Gradio

Gradio requires Python 3.10 or higher. Installing inside a virtual environment is recommended.

bashbash
pip install --upgrade gradio

Write your first app

Create a file named app.py. Wrap a function with gr.Interface, choosing input and output components, then call launch().

pythonpython
import gradio as gr

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

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

demo.launch()

Run it

Run the file with Python. The demo opens in your browser at http://localhost:7860. Use the gradio command instead for hot reload mode.

bashbash
python app.py

Share a public link

Set share=True in launch() to generate a publicly accessible URL for your running demo, with no web server setup.

pythonpython
demo.launch(share=True)

Commands and code are distilled from the project's own documentation — always check the official repo for the latest.

When to use it

  • Put an interactive demo in front of a machine learning model so non-developers can try it in a browser
  • Share a quick prototype with collaborators or reviewers using a temporary public link
  • Build a simple UI for an API or any Python function without writing frontend code
  • Demo a model inside a Jupyter notebook or Google Colab for teaching or experimentation

How Gradio compares

Gradio alongside other open-source data app builders tools AI/TLDR tracks, ranked by GitHub stars.

ToolStarsWhat it does
Streamlit★ 45kA Python framework that turns scripts into interactive data and ML web apps with simple widget calls and no frontend code.
Gradio★ 43kBuild and share web demos for ML models in pure Python
Reflex★ 28.6kA framework for building full-stack web apps entirely in Python, compiling component code to a React frontend and Python backend.
Dash★ 24.3kA Python framework from Plotly for building analytical web dashboards and data apps with interactive charts and no JavaScript required.
marimo★ 21.5kA reactive Python notebook stored as plain Python that can be run as a script or deployed as an interactive data app.
NiceGUI★ 15.9kA backend-first Python UI framework built on FastAPI and Vue for creating web interfaces, dashboards, and internal tools.
Data Formulator★ 15.8kA Microsoft Research tool that combines a UI with AI to help users create rich data visualizations through natural language and direct manipulation.
Mesop★ 6.6kA Python UI framework, started at Google, for rapidly building AI demos and internal web apps using composable components.