# Gradio

> Build and share web demos for ML models in pure Python

- Category: App UIs & Builders / Data App Builders
- Language: Python
- Repository: https://github.com/gradio-app/gradio
- Website: https://gradio.app
- Canonical page: https://ai-tldr.dev/tools/gradio/

## In short

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 sits in the Data App Builders category of the App UIs & Builders tools and is open-source, written in 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.

1. Install Gradio

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

```bash
pip install --upgrade gradio
```

2. Write your first app

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

```python
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()
```

3. 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.

```bash
python app.py
```

4. Share a public link

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

```python
demo.launch(share=True)
```

## 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
