Framework comparison
Streamlit vs Gradio: Choose by Workflow
Streamlit fits data dashboards; Gradio fits model demos with an API. A comparison grounded in two tested LoomCode runs and the official docs.
Choose Streamlit when the app is the analysis: a dashboard or data tool where people filter, chart, upload and download, and the page recomputes as they go. Choose Gradio when the app wraps a function, usually a model: inputs go in, outputs come out, and you want example inputs, a request queue, an API other programs can call, and an easy home on Hugging Face Spaces. Both are Python-only and both work in LoomCode AI. The rest of this page explains the difference with two real runs and the official documentation (Streamlit docs, Gradio docs).
What we actually ran
On 2026-11-22 we generated one app in each framework with GPT-6.2 Sol (gpt-6.2-sol) and tested both in Chrome. These were different tasks, chosen to suit each framework. They are not a head-to-head benchmark, and the timings below are single runs.
Full code, screenshots and caveats are in the two tutorials: Create a Streamlit data app and Build a Gradio ML demo.
The core difference: reruns vs events
The two generated apps show each framework's programming model in a few lines.
Streamlit reruns your script. Per its basic concepts guide, "when something must be updated on the screen, Streamlit reruns your entire Python script from top to bottom", including whenever a user interacts with a widget. Our dashboard reads widget values as ordinary variables:
selected_regions = st.sidebar.multiselect('Region', regions, default=regions)
filtered = orders.loc[orders['region'].isin(selected_regions) & orders['date'].between(start, end)]
cards[0].metric('Revenue', f'{revenue:,.2f}')
That's why it's natural for dashboards. Every filter change recomputes everything below it, and you write the page as a top-to-bottom script. The cost is that expensive work has to be cached, which is what the generated code's @st.cache_data decorators are for. Fragments let you rerun only part of a page.
Gradio binds functions to events. You lay out components, then connect a function to an event with its inputs and outputs. Per the Blocks and event listeners guide, only that function runs. From our demo:
classify.click(model.predict, inputs=sentence, outputs=[prediction, probabilities])
sentence.submit(model.predict, inputs=sentence, outputs=[prediction, probabilities])
That fits an inference function. The model loads once at startup and each click runs one prediction. The same function signature also becomes an API endpoint. Our Gradio preview showed a "Use via API" link in its footer.
Documented capabilities side by side
Checked against the official documentation on 2026-11-22. Versions change, so follow the source links before you depend on a detail.
| Topic | Streamlit | Gradio | Sources |
|---|---|---|---|
| How the code runs | Whole script reruns on each interaction; fragments can rerun part of a page | Only the function attached to an event runs | Streamlit concepts, Gradio Blocks |
| Quickest start | Write a script with st.* calls | gr.Interface(fn, inputs, outputs) wraps one function; gr.Blocks for custom layouts | Gradio Interface, Gradio Blocks |
| Layout | Sidebar, columns, tabs, containers | Rows, columns, tabs, accordions | st.columns, Gradio layout |
| Per-user state | st.session_state | gr.State and session state | st.session_state, Gradio state |
| Caching | st.cache_data for data, st.cache_resource for shared objects such as models | Example outputs can be cached with cache_examples | Streamlit caching, gr.Examples |
| Request queue | No per-event queue; see the execution model above | Built-in queue; each event listener handles one request at a time by default (concurrency_limit) | Gradio queuing |
| Calling the app from code | Experimental agent API (HTTP or MCP), off by default | Python and JavaScript clients can use any Gradio app as an API | Streamlit agent access, Gradio Python client |
| File input | st.file_uploader | gr.File and other file components | st.file_uploader, gr.File |
| Temporary public link | Not built in; deploy to share | share=True; links expire after 1 week | Gradio sharing |
| Sign-in | st.login() with OpenID Connect providers | auth= username/password on launch(); "Sign in with Hugging Face" on Spaces | Streamlit auth, Gradio sharing |
| Hosted option from the vendor ecosystem | Streamlit Community Cloud (from a GitHub repo) | Hugging Face Spaces (Gradio SDK) | Community Cloud, Spaces Gradio SDK |
Two notes. Streamlit's agent API is marked experimental in its docs, and the sandbox's Streamlit 1.49.1 may predate it. Gradio's 1-week share-link expiry is from the current docs, and older Gradio versions such as the sandbox's 4.44.1 may behave differently.
In the LoomCode sandbox
| Framework | Runtime | Key packages | Output | Observed in E2B |
|---|---|---|---|---|
| React | Node.js 22.23.5 | react 19.2.4, react-dom 19.2.4, vite 8.3.8, typescript 5.9.3 | web preview | Nov 23, 2026 |
| Next.js | Node.js 21.7.3 | next 14.2.20, react ^18, tailwindcss ^3.4.1, shadcn/ui components | web preview | Nov 22, 2026 |
| Vue / Nuxt | Node.js 21.7.3 | nuxt ^4.0.3, vue ^3.5.20, nuxi 3.28.0 | web preview | Nov 22, 2026 |
| Python (code interpreter) | Python 3.13 | pandas 2.2.3, matplotlib 3.11.2, plotly 6.0.1, seaborn 0.13.2 | notebook output | Nov 22, 2026 |
| Streamlit | Python 3.9.23 | streamlit 1.49.1, pandas 2.3.2, numpy 2.0.2, plotly 6.3.0 | web preview | Nov 22, 2026 |
| Gradio | Python 3.9.23 | gradio 4.44.1 | web preview | Nov 22, 2026 |
| PHP | PHP 8.2.29 | Composer 2.8.11, PDO (sqlite, mysql drivers) | web preview | Nov 22, 2026 |
| Laravel | PHP 8.2.29 | Laravel Framework 12.27.0, SQLite | web preview | Nov 22, 2026 |
Both sandboxes run Python 3.9.23 on CPU, and neither has ML libraries or model weights. The Streamlit sandbox includes pandas, numpy and Plotly, so data apps need no extra installs. The Gradio sandbox is good for building the interface of a model demo around a small pure-Python model or a hosted inference API. You'd swap in a real model later, outside the sandbox. Each preview runs for about 10 minutes. Share preview can extend it to 24 hours, but it isn't hosting.
Choose by workflow
Pick Streamlit if:
- People will explore data: filters, date ranges, charts, tables and KPIs that update together.
- Users bring their own files and want filtered results back (upload, then download).
- The app is a multi-section report or internal tool. Streamlit supports multipage apps.
- You think in pandas and want to write the page as one script.
Pick Gradio if:
- You're showing a model or function: text, image or audio goes in and a prediction comes out.
- You want clickable example inputs, a queue that protects limited hardware, or an API for the same function.
- You plan to publish on Hugging Face Spaces next to a model.
Either works for a small form-in, result-out tool. Pick the one your team already knows.
Neither is the right tool if you need a custom-designed product UI, complex client-side interactivity or a public multi-user product with accounts and billing. Look at the Next.js template and our SaaS prototype tutorial instead.
Try both with the tested prompts
Open the Streamlit prompt Open the Gradio promptSign in before generating. Your generated code will differ from ours. The quickstart covers plan limits, and the deployment guide covers exporting either app.
Related
- The Streamlit template and Gradio template pages list what each sandbox includes.
- ML demos covers model demos in more depth.
- AI app builder prompts collects these two prompts and eight others with their results.