Article summary — original

Gradio Introduces gr.Workflow for Visual AI Pipelines and APIs Gradio has integrated `gr.Workflow`, a tool that turns multi-step AI pipelines into interactive, drag-and-drop node graphs. Workflows display intermediate outputs, execute nodes in parallel, automatically generate REST API endpoints, and deploy to Hugging Face Spaces. Workflows are structured as graphs with references (inputs), operators (processing steps), and subjects (outputs). Operators support custom Python functions, Hugging Face Inference Providers, other Gradio Spaces, and Hub datasets. Functions can leverage GPU acceleration within Spaces using the @spaces.GPU decorator via ZeroGPU. Every workflow output automatically functions as a dedicated REST API endpoint callable via HTTP or the gradio_client library. Interactive Node-Based Pipelines Instead of requiring manual Python print-debugging to trace multi-step pipelines, `gr.Workflow` exposes pipelines through a drag-and-drop interface with typed ports. Each node can be run independently, allowing users to view intermediate values in place. Implementations range from single-node image editing to multi-branch pipelines executing fan-out operations, such as generating diverse image styles and titles in parallel or profiling dataset statistics simultaneously. Execution and Compute Flexibility Workflow operators can integrate diverse backends, connecting directly to Hugging Face Inference Providers or nesting external Gradio Spaces. For self-hosted model execution, an `fn` node running standard Python code can be decorated with `@spaces.GPU`. ZeroGPU allocates a GPU dynamically for the duration of the node call and releases it afterward without needing specific workflow configuration. Automated REST Endpoints and Code Integration Workflows automatically expose REST API endpoints named after their output labels without extra configuration. Developers can interact with individual pipeline steps or entire workflows programmatically using standard `curl` commands or the `gradio_client` Python library, using authentication tokens when connecting to secured Hugging Face Spaces or model providers.

Article summary — zh

Gradio 推出 gr.Workflow:可视化编排、运行并部署 AI 工作流 Gradio 推出了内置的 gr.Workflow 功能,将多步骤的 Python AI 流水线转化为支持拖拽操作的类型化节点图,可直观查看中间结果,并能自动生成 REST API 及一键部署至 Hugging Face Spaces。 gr.Workflow 将流水线抽象为包含输入(references)、算子(operators)和输出(subjects)的有向图,支持在画布上运行并实时查看每个节点的中间结果。 算子节点可支持本地 Python 函数、Hugging Face Inference Providers 模型、外部 Gradio Space 或 Hub 数据集,并能通过 @spaces.GPU 利用 ZeroGPU 运行 GPU 模型。 支持串联与扇出(fan-out)等并行模式,如多模型联动的媒体工作室或多任务并发的数据集分析。 工作流中的每个输出均自动暴露为对应的 REST API 端点,支持通过 gradio_client 或 curl 直接调用。 从代码调试到可视化工作流 传统 AI 应用通常需要将多个模型和处理步骤在 Python 中串联,调试时往往依赖繁琐的打印输出。gr.Workflow 直接将流水线转化为可视化界面,用户可通过类型化端口连线来构建流程图。工作流包含输入、算子和输出三种节点,每个节点均可独立运行并直接显示结果。 灵活的算子类型与并行能力 工作流算子能够直接调用 Hugging Face 的 Inference Providers 模型(如 Qwen-Image-Edit、FLUX)、连接其他 Gradio Space,或利用 Datasets Server API 并发分析数据集指标。此外,算子还可以是普通的 Python 函数,结合 @spaces.GPU 装饰器,ZeroGPU 能够在执行时动态申请并释放 GPU,从而在 Space 内直接运行类似 LTX-Video 的大模型。 免配置 API 与一键部署 构建的每个工作流图同时兼具 API 功能,各个输出节点会自动以其标签命名为独立的 REST 端点。用户无需打开 UI,即可通过 Python 的 gradio_client 客户端或 curl 发起请求;需要调用模型或私有 Space 的端点只需传入 Hugging Face Token 即可认证调用。用户亦可直接在 Hugging Face Spaces 上复制示例快速开始构建。

Saved original article

Most interesting AI apps are pipelines. You generate an image, then cut out its background if you want to, or edit it into something new. You write a script, then generate a voice for it, or swap the voice while keeping the script the same. We usually wire these steps together in Python, and the moment something looks off we go back to print-debugging to find which step produced the odd value. gr.Workflow , built right into Gradio, makes the pipeline the interface . You describe your steps as a graph of typed nodes, and Gradio serves a drag-and-drop canvas where every node is runnable and every intermediate result is visible. The same graph is also a REST API and a one-command deploy to Hugging Face Spaces. The best way to get the idea is to see a few workflows in action. Every app below is a live Huggingface Space you can open, run, and duplicate. Edit an Image Upload an image, type an edit ("turn it into a snowy winter scene", "add sunglasses", "make the car red"), and get the edited photo back. The whole app is a single node calling Qwen-Image-Edit on Hugging Face Inference Providers. 👉 Try the Image Editor Pipeline Chain real models into a media studio One graph, three pipelines. Start with a prompt and generate an image with FLUX , then pass it to a background-removal Gradio Space to turn it into a sticker. A topic becomes a voiceover through a text-to-speech Gradio Space , while the same topic becomes a catchy episode title through an LLM call. That’s one canvas, two model calls through Hugging Face Inference Providers , and two calls to Gradio Spaces. Since this is a workflow, each of the three outputs also gets its own REST endpoint: /sticker , /voiceover , and /episode_title . You can call any of them directly from code without opening the UI. See Call it from code below for a runnable example. 👉 Try the AI Media Studio Fan-out image generation in parallel Type in one idea, and it turns into a set of generated artwork all at once: a base image from FLUX, two AI re-imaginings of that image (a soft watercolor version and a neon cyberpunk take), and a gallery title written by an LLM. Each image is generated directly from the prompt by a model node using Inference Providers, while the title comes from an fn node that calls an LLM. This is the fan-out pattern in action: one idea can feed multiple operators simultaneously, all generating in parallel. 👉 Try the Generative Art Lab Profile a Hugging Face dataset Type in a Hugging Face dataset ID, such as stanfordnlp/imdb or mteb/tweet_sentiment_extraction , and a single input fans out to four operator nodes that analyze the dataset live using the Datasets Server API. You get an overview card, a preview of the first few rows, per-column statistics, and a distribution chart, all computed independently and in parallel. That’s the power of workflows! 👉 Try Data Detective Run your own GPU model Every node so far reaches out to Hugging Face. But an fn node is just Python, which means it can also run a model inside the Space on a GPU. Decorate the bound function with @spaces.GPU and, when the node runs, ZeroGPU grabs a GPU for that call, runs the model, and releases it. We don't always need to rely on Inference Providers or existing Gradio Spaces. Check out this demo that animates a still image using Lightricks/LTX-Video loaded through Diffusers, running entirely through one node. gr.Workflow doesn't need to know anything about your GPU setup. It simply calls the bound function. 👉 Try the ZeroGPU Animator How it works, in a nutshell Every workflow is a graph with three kinds of nodes: references (your inputs), operators (the steps that do work), and subjects (your outputs). An operator can be your own Python function, a model on Hugging Face Inference Providers, another Gradio Space, or a row from a Hub dataset. You connect them by dragging between typed ports, hit Run, and watch each result appear in place. Call it from code Every workflow you build is also an API, with no extra work. Each output becomes a REST endpoint named after its label, and you can call it from Python with the Gradio client. Here is a live, no-token example against the multi-endpoint demo Space, exactly as-is: from gradio_client import Client client = Client( "ysharma/gr-workflow-multi-endpoint-API" ) print (client.predict( "hello there friend" , api_name= "/word_count" )) # -> 3 print (client.predict( 20 , api_name= "/fahrenheit" )) # -> 68.0 Endpoints that call a model or a Space run under a Hugging Face token, so pass one when you create the client: from gradio_client import Client, handle_file client = Client( "ysharma/gr-workflow-image-editor" , token= "hf_..." ) edited = client.predict( handle_file( "dog.jpg" ), "turn it into a snowy winter scene" , api_name= "/edited_image" , ) Prefer plain HTTP? Every endpoint is reachable over curl too: curl -s https://ysharma-gr-workflow-multi-endpoint-API.hf.space/gradio_api/call/word_count \ -H "Content-Type: application/json" -d '{"data": ["hello there friend"]}' Build your own The fastest way in is to open any demo above, click Duplicate , and start rewiring. From Python, it is as short as: import gradio as gr def your_function ( text: str ) -> str : pass gr.Workflow(bind=[your_function]).launch() For the full walkthrough, the operator kinds, the JSON schema, and reusable patterns, see the official gr.Workflow guide in the Gradio docs. You can even build something as involved as AUTOMATIC1111 with gr.Workflow . Keep an eye out for our next post, where we walk through building it step by step. Here is a sneak peek 😉👇