Skip to main content

Build

Huggingface Gradio

Hugging FaceOfficialCertified

Build Gradio web UIs and demos in Python. Use when creating, modifying, debugging, or answering questions about Gradio and its capabilities, components, event listeners, or layouts.

  • New
  • v1.0.2
  • Reviewed Jul 21
  • No reviews yet

Capabilities

  • Guides

  • Core Patterns

    Interface (high-level): wraps a function with input/output components

  • Server Mode

    See the full guide and example in references/examples.md

Getting started

Full instructions

Install the skill, then ask your AI tool for the task in plain words. The full SKILL.md below shows what it covers.

Instructions: SKILL.mdv1.0.2

Gradio

Gradio is a Python library for building interactive web UIs and ML demos. This skill covers the core API, patterns, and examples.

References

  • references/examples.md - Illustrative examples showcasing the core Gradio API.
  • references/api-signatures.md - API signatures of commonly used components.
  • references/event-listeners.md - API signatures of events supported by each component.

Guides

Detailed guides on specific topics (read these when relevant):

  • Quickstart
  • The Interface Class
  • Blocks and Event Listeners
  • Controlling Layout
  • More Blocks Features
  • Custom CSS and JS
  • Streaming Outputs
  • Streaming Inputs
  • Sharing Your App
  • Custom HTML Components
  • Workflows
  • Server Mode
  • Building an MCP Server with Gradio
  • Getting Started with the Python Client
  • Getting Started with the JS Client

Core Patterns

Interface (high-level): wraps a function with input/output components.

python
import gradio as gr

def greet(name):
    return f"Hello {name}!"

gr.Interface(fn=greet, inputs="text", outputs="text").launch()

Blocks (low-level): flexible layout with explicit event wiring.

python
import gradio as gr

with gr.Blocks() as demo:
    name = gr.Textbox(label="Name")
    output = gr.Textbox(label="Greeting")
    btn = gr.Button("Greet")
    btn.click(fn=lambda n: f"Hello {n}!", inputs=name, outputs=output)

demo.launch()

ChatInterface: high-level wrapper for chatbot UIs.

python
import gradio as gr

def respond(message, history):
    return f"You said: {message}"

gr.ChatInterface(fn=respond).launch()

Workflow: builds a visual, node-based pipeline from Hugging Face Spaces,
models, datasets, and Python functions. gr.Workflow is a standalone app, so
do not create it inside a gr.Blocks context.

python
import gradio as gr

def clean(text: str) -> str:
    return text.strip().lower()

def tag(text: str) -> str:
    return f"[processed] {text}"

gr.Workflow(
    bind={"clean": clean, "tag": tag},
    edges=[("clean", "tag")],
).launch()

The graph is saved to workflow.json next to the script (or the path passed as
graph=), and you can write or edit that file directly to build workflows
programmatically. It has references (inputs), operators (processing steps)
and subjects (outputs), connected by edges between typed ports (image,
audio, video, text, number, boolean, gallery, file, json,
model3d, any). Operator kind is one of:

  • "space": a Gradio Space, with space_id and endpoint
  • "model": a Hugging Face model via Inference Providers, with model_id and an endpoint such as text_to_image
  • "dataset": one row of a Hub dataset per run, with dataset_id, dataset_config and dataset_split
  • "fn": a Python function, whose fn value matches a key in bind=

edges= only wires bound Python functions, and is ignored once the workflow file
exists. See the Workflows guide for
the full JSON format, deployment and ZeroGPU quotas.

Custom HTML Components

If a task requires significant customization of an existing component or a component that doesn't exist in Gradio, you can create one with gr.HTML. It supports html_template (with ${} JS expressions and {{}} Handlebars syntax), css_template for scoped styles, and js_on_load for interactivity — where props.value updates the component value and trigger('event_name') fires Gradio events. For reuse, subclass gr.HTML and define api_info() for API/MCP support.

See the full guide as well as example in references/examples.md

Server Mode

Use gr.Server instead of gr.Blocks when the users requests any of the following:

  • Completely custom UI (your own HTML, React, Svelte, etc.) powered by Gradio's backend.
  • Full control of FastAPI server (custom GET/POST routes, middleware, dependency injection) alongside Gradio API endpoints

See the full guide and example in references/examples.md.

If the user's use case can be handled by Gradio's built-in components or customizable HTML components, prefer not to use gr.Server.

MCP Server

Any Gradio app can also be an MCP server: demo.launch(mcp_server=True) (requires pip install "gradio[mcp]"). Each API endpoint becomes an MCP tool, served at /gradio_api/mcp/, with the tool description and argument schema taken from the function's docstring and type hints, so write both carefully.

See the full guide.

Explore more skills

Browse all
This skill doesn’t include stateful context yet, instructions only. Learn about stateful skills.

Security

Loading security scan...

Reviews (0)

More from Hugging Face

View source →
hugging-face-vision-trainerTrains and fine-tunes vision models for object detection (D-FINE, RT-DETR v2, DETR, YOLOS), image classification (timm models — MobileNetV3, MobileViT, ResNet, ViT/DINOv3 — plus any Transformers classifier), and SAM/SAM2 segmentation using…2 installshuggingface-bestUse when the user asks about finding the best, top, or recommended model for a task, wants to know what AI model to use, or wants to compare models by benchmark scores. Triggers on: "best model for X", "what model should I use for", "top…1 installstransformers-jsUse Transformers.js to run state-of-the-art machine learning models directly in JavaScript/TypeScript. Supports NLP (text classification, translation, summarization), computer vision (image classification, object detection), audio (speech…1 installshugging-face-paper-pagesLook up and read Hugging Face paper pages in markdown, and use the papers API for structured metadata such as authors, linked models/datasets/spaces, Github repo and project page. Use when the user shares a Hugging Face paper page URL, an…0 installshuggingface-community-evalsRun evaluations for Hugging Face Hub models using inspect-ai and lighteval on local hardware. Use for backend selection, local GPU evals, and choosing between vLLM / Transformers / accelerate. Not for HF Jobs orchestration, model-card PRs,…0 installshf-cloud-sagemaker-deployment-plannerPlan and coordinate the deployment of a model to Amazon SageMaker AI. Use this skill whenever the user wants to deploy, host, serve, or expose a model on SageMaker or AWS — including phrases like "deploy a model", "host this LLM on AWS",…0 installs

Frequently asked questions about huggingface-gradio

What does the huggingface-gradio skill do?

Build Gradio web UIs and demos in Python. Use when creating, modifying, debugging, or answering questions about Gradio and its capabilities, components, event listeners, or layouts. It's a reusable SKILL.md instruction set that loads into your AI coding assistant on demand, no prompt engineering, no copy-pasting every session.

How do I install the huggingface-gradio skill?

Run `npx @skills-hub-ai/cli install huggingface-gradio` from your terminal. The CLI writes the SKILL.md to the correct location for your AI tool (e.g. ~/.claude/skills/huggingface-gradio/ for Claude Code or ~/.cursor/skills/ for Cursor with --target cursor) and adds it to your project's .skills.json lockfile.

Which AI tools does huggingface-gradio work with?

huggingface-gradio runs in Claude Code. It follows the open Agent Skills standard (SKILL.md), so the same skill works in every supported tool without modification.

Is the huggingface-gradio skill free?

Yes. Every skill on skills-hub.ai is free and open-source. There are no premium tiers, paywalls, or usage limits. You only pay for whatever AI assistant you're already using.

How do I use huggingface-gradio after installing it?

In Claude Code, type `/huggingface-gradio` (or whatever slash command the skill registers) and the AI follows the skill's instructions immediately. You can also reference it by name in natural language, your AI loads the skill into context when relevant.

Can I share the huggingface-gradio skill with my team?

Yes. Commit your project's .skills.json lockfile and teammates run `npx @skills-hub-ai/cli install` (no args) to install every skill at the exact version you pinned. Organization-scoped installs work via skills-hub.ai organizations.

Badge for your README

Show that this skill is on Skills Hub. The badge links back to this page and shows the live install count.

Install on Skills Hub badge preview
Markdown
[![Install on Skills Hub](https://skills-hub.ai/api/badges/skill/huggingface-gradio)](https://skills-hub.ai/skills/huggingface-gradio)
HTML
<a href="https://skills-hub.ai/skills/huggingface-gradio"><img src="https://skills-hub.ai/api/badges/skill/huggingface-gradio" alt="Install on Skills Hub"></a>

More options in the badge docs.