Five years ago, Stanford researchers launched Gradio as a simple Python library to make demo computer vision models easier to use the web interface.
Currently, Gradio is used by over 1 million developers each month to build and share AI web apps. This includes some of the most popular open source projects of all time, including Automatic1111, Oobabooga’s Text Generation WebUI, Dall-E Mini, and Llama-Factory.
How did you get here? How has Gradio continued to grow in the highly crowded field of open source Python libraries? I receive this question a lot from people who are building their own open source libraries. In this post I distill some of the lessons I have learned over the past few years.
The only roadmap focusing on the niche that embeds virals directly into the library (grows) rather than a high-level abstraction that invests in good primitives, is to maximize the way users can consume the output of the library
1. Invest in great primitives rather than high-level abstractions
When I first launched Gradio, I only provided one high-level class (Gr.Interface) and created a complete web app from a single Python function. We quickly realised that developers wanted to create other types of apps (such as multi-step workflows, chatbots, streaming applications), but when we started listing the apps our users wanted to build, we achieved what we needed to do.
Instead of building many high-level classes to support a variety of use cases, we have built a low-level API called Gradioblocks that allows applications to be built from modular components, events and layouts. Despite the large amount of work that is commonly used, Gr.Blocks today represents 80% of gradient usage. This includes the very popular apps mentioned above.
In a small team, focusing on low-level abstractions necessarily meant that they were unable to pursue many attractive, high-level abstractions. But this focus saved us from two general pitfalls:
Customized Maintenance Traps: High-level abstractions are easy to use, but users will require additional parameters to customize them. This increases the maintenance burden as all abstractions and parameters need to be implemented, maintained, and tested to avoid bugs.
Illusion of Productivity: Using a high level of abstraction seems like less work until the user needs unsupported features (which can be difficult to predict at the start of a project), and forcing developers to do expensive rewrites.
The first issue is wasting time as a grade maintainer, while the second issue is wasting time for the user. To this day, Gradio only includes two high-level abstractions (Gr.Interface and Gr.Chatinterface) built with blocks.
The benefits of having good primitives are even more dramatic in the age of AI-assisted coding. Here we see that LLM is generally good at examining the documentation and building complex applications from primitives (see, for example, all games built with 3.JS). If AI is writing code for you, it doesn’t take much extra time to write low-level code.
2. Focus on the (growing) niche
The best ambassador for your library isn’t you, it’s a passionate user. Therefore, you need to find a way for users to share the library or its products as part of their workflow. Gradio’s early growth was driven by the “Share Links” feature (creating temporary public links to Gradio apps in a single codeline). Instead of worrying about packaging and hosting on a web server with the right kind of calculation, Gradio users can quickly share their apps with their colleagues.
After attending the hug, we also benefited from being a standard UI for hugging face spaces in preparation for being used in the machine learning research community. Most viral spaces attract millions of visitors and expose developers to Grade Gradio, sharing and building grade apps, using them as a resource to learn how to use gradients using the same space (where the code was published).
3. Build for (growth) niche use cases
Early on, we faced a key decision. Should gradients be a generic Python web framework or should we focus on building machine learning web apps? I chose the latter, but this made all the difference.
In the crowded ecosystem of Python web libraries, people often get asked, “How is Gradio different from X?” Our Concise Answer – Grades are optimized for machine learning web apps, but are memorable and essentially accurate. Each Gradio app has features that are particularly suitable for ML workflows, such as built-in queues that allow you to efficiently manage long-term ML tasks, even when you have thousands of concurrent users. The components you design are specifically tailored to your ML use case. Meanwhile, for a long time, Gradio didn’t even include features like link buttons. By focusing on it, Gradio quickly became a go-to choice among machine learning developers. This is the default “AI UI”.
Of course, we have benefited greatly from choosing a niche that is growing in itself. The recent headwinds that pushed everything AI-related have benefited us a lot, and if we had focused on, for example, data science and dashboards, we would not have experienced the same kind of growth.
4. Your only roadmap should be a quick iteration
Unlike some other libraries, Gradio does not publish a roadmap. Instead, they track emerging machine learning trends and ship accordingly. In open source software in general, and AI, delivery capabilities based on community needs (and features that denounce unwanted features) in particular are key to continuous growth. As a concrete example, early versions of Gradio built specific features to allow developers to “interpret” the machine learning model. This was a very popular use case around 2020-21. As interest in interpretation faded, we removed this and instead worked on audio/video streaming and chat-related features.
Our internal processes are also decentralized. Each of the 11 engineers and developers on the Grade Team is encouraged to identify impactful ideas, quickly identify prototypes, and engage directly with the open source community via GitHub, Hugging Face and Social Media. Each team member will bring these ideas back to the team and continually build and restructure consensus on which ideas will have an impact as they continue to grow in the most impactful direction.
5. Maximize the way users can consume library output
When I create a Gradio App and create “launch()”, I am running a web application in my browser. However, that’s not all. It also retrieves the API endpoints for each Python function and the automated documentation for each endpoint. These endpoints can be used via team-built Python or JavaScript clients, or directly using Curl.
The reason we do this is because we want every minute that developers spend on Gradio to be the most useful. A single Gradio app can run locally, deploy without code changes on facespaces or servers, programmatically integrate into larger applications, or even be utilized by AI agents via MCPS (more details soon!). By focusing on maximum usability, we hope that developers can continue to acquire more and more from the Graden library.
Towards 10 million people!