Gradio

6.10.0 · active · verified Fri Mar 27

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

Install

Imports

Quickstart

6.x API. Use type='messages' for gr.Chatbot. Return component instances, not gr.update().

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)

view raw JSON →