Subscribe
AI
3 min read

Hugging Face Introduces gr.Workflow to Turn AI Pipelines into Visual Graphs and REST APIs

Hugging Face released gr.Workflow to turn complex AI pipelines into visual node graphs and REST APIs. This native Gradio extension simplifies orchestration by formalizing sequences as computational DAGs, exposing intermediate outputs via auto-generated endpoints without manual glue code.

Hugging Face gr.Workflow interface showing visual nodes for an AI pipeline connected to REST API endpoints
Hugging Face gr.Workflow interface showing visual nodes for an AI pipeline connected to REST API endpoints

Hugging Face has released gr.Workflow, a native Gradio extension that transforms multi-stage artificial intelligence pipelines into interactive visual node graphs and deployable REST APIs. It eliminates the need for sequential Python glue code by formalizing data dependencies as directed acyclic graphs (DAGs) composed of references, operators, and subjects.

Hugging Face has released gr.Workflow, a native extension to the Gradio framework designed to convert multi-stage artificial intelligence pipelines into interactive node graphs, visual user interfaces, and deployable REST APIs.

Modern machine learning applications increasingly rely on compound pipelines that chain heterogeneous models: generating text via large language models, feeding prompts into diffusion systems, processing outputs through background removal or audio synthesis models, and applying downstream formatting. Traditionally, developers orchestrate these chains using sequential Python glue code, where inspecting intermediate outputs or exposing individual pipeline stages as separate endpoints requires dedicated routing and debugging scaffolding.

gr.Workflow formalizes these sequences as computational graphs composed of three primary node primitives: references, operators, and subjects.

Visual representation of node graph architecture and modular endpoints in Gradio Workflow

Core Architecture and Node Types

The workflow engine models data dependencies explicitly through typed connections:

  • References: Input nodes that capture incoming data, such as prompt strings, uploaded images, audio clips, or configuration parameters.
  • Operators: Execution units that process data. Operators can represent arbitrary Python functions, remote models hosted on Hugging Face Inference Providers, external Gradio Spaces, or queries against Hub datasets.
  • Subjects: Terminal and intermediate output artifacts displayed in the visual canvas and exposed via the network interface.

By structuring the application as a directed acyclic graph (DAG), Gradio renders an interactive canvas where each node can be run independently, intermediate artifacts remain visible for inspection, and errors can be isolated to specific pipeline stages without re-running preceding computations.

Automatic REST Routing and Client Access

A primary feature of gr.Workflow is the automatic generation of granular API endpoints. Every output subject defined in the graph generates a dedicated REST route named after its label.

For example, a multi-modal pipeline that generates an image, creates an audio voiceover, and summarizes metadata simultaneously exposes separate routes (such as /sticker, /voiceover, and /episode_title). Developers can query these sub-pipelines directly via standard HTTP requests or using the gradio_client Python package:

from gradio_client import Client, handle_file

client = Client("username/custom-ai-pipeline", token="hf_...")

result = client.predict(
    handle_file("input_sample.jpg"),
    "apply studio lighting and remove background",
    api_name="/processed_asset",
)

Direct HTTP clients can query identical endpoints via curl against the generated /gradio_api/call/<endpoint> path with JSON payloads.

Infrastructure Integration and ZeroGPU Execution

Workflows can execute entirely in memory on local hardware or leverage cloud-hosted inference. When defining Python function nodes, developers can bind compute-intensive operations to dynamic hardware allocators using Hugging Face ZeroGPU.

By applying the @spaces.GPU decorator to a function node, the runtime provisions an isolated GPU instance during execution and releases the hardware immediately upon completion. This enables the integration of local PyTorch and Diffusers models alongside hosted Inference Providers without managing dedicated GPU infrastructure.

Availability

gr.Workflow is available in current versions of Gradio and supports direct deployment to Hugging Face Spaces.

Sources

Frequently asked questions

What are the three primary node types in gr.Workflow?

The workflow engine uses References (input nodes), Operators (execution units like Python functions or remote models), and Subjects (output artifacts displayed visually or exposed via network interfaces).

How does gr.Workflow handle REST API generation?

It automatically generates granular API endpoints where every output subject defined in the graph creates a dedicated REST route named after its label, accessible via HTTP requests or the gradio_client package.

Can I use local hardware with gr.Workflow?

Yes, workflows can execute entirely in memory on local hardware, or developers can bind compute-intensive operations to dynamic cloud GPU instances using Hugging Face ZeroGPU with the @spaces.GPU decorator.

AIToolingHugging FaceGradioMachine Learning