Gradio
Python library for building ML demo web apps. Current version is 6.10.0 (Mar 2026). Requires Python >=3.10. Three major breaking version bumps in rapid succession (3→4→5→6). The most common LLM footgun: gr.update() was removed in 4.0 — return component instances directly. Chatbot tuple format removed in 6.0 — must use messages dict format. LLMs trained before 2024 generate 3.x patterns that fail on 6.x.
Warnings
- breaking gr.update() was removed in Gradio 4.0. The entire pattern of returning gr.Textbox.update(value='x') or gr.update(visible=True) raises AttributeError. This is the #1 footgun from LLM-generated code using old Gradio docs.
- breaking Chatbot tuple format ([['user', 'assistant'], ...]) removed in Gradio 6.0. gr.Chatbot() and gr.ChatInterface() now require dict messages format: [{'role': 'user', 'content': '...'}, {'role': 'assistant', 'content': '...'}]
- breaking theme= parameter removed from gr.Blocks() in Gradio 6.0. TypeError: BlockContext.__init__() got an unexpected keyword argument 'theme'. Breaks all apps using gr.Blocks(theme=gr.themes.Soft()).
- breaking concurrency_count parameter removed in Gradio 4.0. Per-event concurrency_limit replaced it. queue=False also removed — use concurrency_limit=None instead.
- breaking In Gradio 5.0+, functions can only return files in the current working directory or temp directory. Returning absolute paths to arbitrary system files is blocked for security.
- gotcha Python 3.10 is now the minimum. Gradio 6.x will not install on Python 3.9.
- gotcha LLMs (including ChatGPT and Copilot) frequently generate Gradio 3.x code with gr.update() and tuple chatbot format that fails on 6.x. Always verify which Gradio version the generated code targets.
Install
-
pip install gradio
Imports
- gr.Interface
import gradio as gr # Simple Interface (gr.update() is gone — return values directly) def greet(name, intensity): return 'Hello, ' + name + '!' * intensity demo = gr.Interface( fn=greet, inputs=[gr.Textbox(label='Name'), gr.Slider(1, 10, value=3)], outputs=gr.Textbox(label='Greeting') ) demo.launch()
Quickstart
import gradio as gr
# Simple Interface
def classify_text(text):
return {'positive': 0.8, 'negative': 0.2}
gr.Interface(
fn=classify_text,
inputs=gr.Textbox(label='Input Text'),
outputs=gr.Label(label='Sentiment')
).launch()
# Blocks API (more flexible)
def chat(message, history):
# history is list of dicts: [{role, content}, ...]
response = f'Echo: {message}'
return response
with gr.Blocks() as demo:
gr.Markdown('# My Chatbot')
chatbot = gr.Chatbot(type='messages') # dict format required in 6.0
msg = gr.Textbox(label='Message')
btn = gr.Button('Send')
def respond(message, history):
history.append({'role': 'user', 'content': message})
history.append({'role': 'assistant', 'content': f'Echo: {message}'})
return '', history
btn.click(respond, [msg, chatbot], [msg, chatbot])
demo.launch(share=True)