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.
pip install --upgrade gradioWrite your first app
Create a file named app.py. Wrap a function with gr.Interface, choosing input and output components, then call launch().
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.
python app.pyShare a public link
Set share=True in launch() to generate a publicly accessible URL for your running demo, with no web server setup.
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.
| Tool | Stars | What it does |
|---|---|---|
| Streamlit | ★ 45k | A Python framework that turns scripts into interactive data and ML web apps with simple widget calls and no frontend code. |
| Gradio | ★ 43k | Build and share web demos for ML models in pure Python |
| Reflex | ★ 28.6k | A framework for building full-stack web apps entirely in Python, compiling component code to a React frontend and Python backend. |
| Dash | ★ 24.3k | A Python framework from Plotly for building analytical web dashboards and data apps with interactive charts and no JavaScript required. |
| marimo | ★ 21.5k | A reactive Python notebook stored as plain Python that can be run as a script or deployed as an interactive data app. |
| NiceGUI | ★ 15.9k | A backend-first Python UI framework built on FastAPI and Vue for creating web interfaces, dashboards, and internal tools. |
| Data Formulator | ★ 15.8k | A Microsoft Research tool that combines a UI with AI to help users create rich data visualizations through natural language and direct manipulation. |
| Mesop | ★ 6.6k | A Python UI framework, started at Google, for rapidly building AI demos and internal web apps using composable components. |