LoomCode AI

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.

Updated Nov 22, 20267 min readtested

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.

TopicStreamlitGradioSources
How the code runsWhole script reruns on each interaction; fragments can rerun part of a pageOnly the function attached to an event runsStreamlit concepts, Gradio Blocks
Quickest startWrite a script with st.* callsgr.Interface(fn, inputs, outputs) wraps one function; gr.Blocks for custom layoutsGradio Interface, Gradio Blocks
LayoutSidebar, columns, tabs, containersRows, columns, tabs, accordionsst.columns, Gradio layout
Per-user statest.session_stategr.State and session statest.session_state, Gradio state
Cachingst.cache_data for data, st.cache_resource for shared objects such as modelsExample outputs can be cached with cache_examplesStreamlit caching, gr.Examples
Request queueNo per-event queue; see the execution model aboveBuilt-in queue; each event listener handles one request at a time by default (concurrency_limit)Gradio queuing
Calling the app from codeExperimental agent API (HTTP or MCP), off by defaultPython and JavaScript clients can use any Gradio app as an APIStreamlit agent access, Gradio Python client
File inputst.file_uploadergr.File and other file componentsst.file_uploader, gr.File
Temporary public linkNot built in; deploy to shareshare=True; links expire after 1 weekGradio sharing
Sign-inst.login() with OpenID Connect providersauth= username/password on launch(); "Sign in with Hugging Face" on SpacesStreamlit auth, Gradio sharing
Hosted option from the vendor ecosystemStreamlit 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

Sandbox runtime versions
FrameworkRuntimeKey packagesOutputObserved in E2B
ReactNode.js 22.23.5react 19.2.4, react-dom 19.2.4, vite 8.3.8, typescript 5.9.3web previewNov 23, 2026
Next.jsNode.js 21.7.3next 14.2.20, react ^18, tailwindcss ^3.4.1, shadcn/ui componentsweb previewNov 22, 2026
Vue / NuxtNode.js 21.7.3nuxt ^4.0.3, vue ^3.5.20, nuxi 3.28.0web previewNov 22, 2026
Python (code interpreter)Python 3.13pandas 2.2.3, matplotlib 3.11.2, plotly 6.0.1, seaborn 0.13.2notebook outputNov 22, 2026
StreamlitPython 3.9.23streamlit 1.49.1, pandas 2.3.2, numpy 2.0.2, plotly 6.3.0web previewNov 22, 2026
GradioPython 3.9.23gradio 4.44.1web previewNov 22, 2026
PHPPHP 8.2.29Composer 2.8.11, PDO (sqlite, mysql drivers)web previewNov 22, 2026
LaravelPHP 8.2.29Laravel Framework 12.27.0, SQLiteweb previewNov 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 prompt

Sign in before generating. Your generated code will differ from ours. The quickstart covers plan limits, and the deployment guide covers exporting either app.