Gradio Cheatsheet
Gradio is the fastest way to build ML/AI demo interfaces in Python. Launch a web UI with one line, supports drag-and-drop component composition, one-click sharing via public links, and deployment to HuggingFace Spaces. Also features a built-in CLI chat interface (gradio cc).
Quick Start
``bash
# Install
pip install gradio
# Run an app (dev mode with hot reload) gradio app.py
# Create a public share link gradio app.py --share
# CLI chat with AI gradio cc --model gpt-4o
# Deploy to HuggingFace Spaces
gradio deploy
`
App Development
Create a Python file with a Gradio interface function. The gradio CLI runs it in development mode with auto-reload. Supports text, image, audio, video, and many other input/output component types.
Sharing
--share creates a public URL via Gradio Share tunnel (valid for 72 hours). Perfect for sharing demos with clients or collaborators without deploying anywhere.
HuggingFace Spaces
gradio deploy handles the full deployment workflow: creates a Space repo on HuggingFace, uploads your code, sets up the environment, and provides a permanent URL. Spaces support GPU acceleration for model inference.
CLI Chat
gradio cc` provides a terminal-based chat interface. Supports various AI models via API backends. Useful for quick testing without building a full UI.
Startup & Modes(9)
| Command | Level | ||
|---|---|---|---|
gradio --helpShow Gradio CLI help | Basic | gradio --help | |
gradio app.pyRun Gradio app (dev mode, hot reload) | Basic | gradio app.py | |
gradio app.py --portSpecify the port to run on | Basic | gradio app.py --port 7861 | |
gradio app.py --shareCreate public share link (Gradio Share) | Basic | gradio app.py --share | |
pip install gradioInstall Gradio | Basic | pip install gradio | |
gradio ccCommand-line chat interface (talk to AI models) | Basic | gradio cc --model gpt-4o | |
gradio cc --modelSpecify model in CLI chat | Basic | gradio cc --model claude-sonnet-4 | |
gradio demoCreate reference demo template | Basic | gradio demo | |
gradio app.py --analytics-enabledDisable usage analytics | Basic | gradio app.py --analytics-enabled false |
ai-server(7)
| Command | Level | ||
|---|---|---|---|
gradio deployDeploy to HuggingFace Spaces | Intermediate | gradio deploy | |
gradio deploy --titleSpecify Space title | Intermediate | gradio deploy --title 'My Demo App' | |
gradio deploy --app-fileSpecify app entry file | Intermediate | gradio deploy --app-file demo.py | |
gradio space createCreate a HuggingFace Space | Intermediate | gradio space create my-demo | |
gradio space deleteDelete a HuggingFace Space | Intermediate | gradio space delete my-demo | |
gradio app.py --root-pathSet app root path (for reverse proxy) | Intermediate | gradio app.py --root-path /my-app | |
gradio app.py --authEnable username/password authentication | Intermediate | gradio app.py --auth admin:password123 |