Skip to content

Back to the catalog

Wire It, Run It, Deploy It: AI Workflows in Gradio
huggingface.coarticle

Wire It, Run It, Deploy It: AI Workflows in Gradio

This Hugging Face blog post introduces gr.Workflow, a Gradio primitive that lets developers describe an AI pipeline as a graph of typed nodes (references for inputs, operators for steps, subjects for outputs) and get a runnable drag-and-drop canvas, an auto-generated REST API per output, and one-command deployment to Hugging Face Spaces from the same definition. Operator nodes can call Hugging Face Inference Providers, other Gradio Spaces, Hub dataset rows, or plain Python functions decorated with @spaces.GPU for in-Space GPU inference via ZeroGPU. Worked examples include an image-editing pipeline using Qwen-Image-Edit, a multi-model media studio chaining FLUX, background removal, and TTS, a parallel fan-out image-generation demo, a Hugging Face dataset profiler using the Datasets Server API, and a GPU-based image animator using Lightricks/LTX-Video via Diffusers.

TL;DR Gradio's new gr.Workflow turns an AI pipeline graph into a drag-and-drop UI, a REST API, and a one-click Hugging Face Spaces deploy, all from the same node definition.
Document

What it claims

gr.Workflow is part of Gradio itself. You do not install a separate package. A workflow can be as small as one bound Python function, and every output node automatically gets an API endpoint, with no extra code. The demos run as live, duplicable Spaces under ysharma/. The post also says you could build something as involved as AUTOMATIC1111 with it, but that build is only teased for a later post.

How it works

  • Endpoint names come from the output's label. For example, the media studio's three outputs are served as /sticker, /voiceover and /episode_title.
  • Two kinds of operator. A model operator calls Inference Providers directly; in the fan-out demo, each image comes from one. An fn operator is plain Python; it can call an LLM itself, or run a model in-process.
  • GPU nodes. If you decorate a bound function with @spaces.GPU, ZeroGPU acquires a GPU for that single call and releases it afterwards. The post says gr.Workflow needs no knowledge of your GPU setup and simply calls the function.
  • Parallelism. When one reference feeds several operators, those operators run in parallel.

How to use it

Minimal definition, as given:

import gradio as gr
def your_function(text: str) -> str:
  pass
gr.Workflow(bind=[your_function]).launch()

Calling endpoints that do pure Python needs no token:

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 another 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",
)

Plain HTTP:

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"]}'

The quickest way to start is to click Duplicate on a demo Space and rewire it. The post defers the operator kinds, the JSON graph schema and reusable patterns to the official gr.Workflow guide in the Gradio docs.

Limits

  • Missing details. The post does not state a minimum Gradio version or any pricing or quota for Inference Providers or ZeroGPU. It also lists no limitations or failure modes.
  • Billing. Model-calling and Space-calling nodes need an HF token, so usage is attributed to that account.
  • The curl example shows only the initial POST. The post does not show how to retrieve the result.
  • Missing workflow details. Error handling, retries, and how a failed node affects downstream nodes are not covered.
  • Unshown claims. The AUTOMATIC1111-scale claim is not demonstrated in this post.

Organisations named here

  • Hugging Face
  • AUTOMATIC1111
  • Diffusers
  • FLUX
  • Gradio

Technologies named here

  • Qwen-Image-Edit
  • gr.Workflow
  • Gradio
  • FLUX
  • Hugging Face Inference Providers
  • Lightricks/LTX-Video
  • Hugging Face Spaces
  • gradio_client
  • ZeroGPU
  • Diffusers
  • Datasets Server API
  • curl
  • Hugging Face
  • Qwen
  • Python

Techniques named here

  • Fan-out pattern
  • @spaces.GPU decorator with ZeroGPU
  • Workflow graph nodes