{
  "@context": "https://schema.org",
  "@id": "https://aggr.aymericbeaumet.com/items/huggingface-co/2026-08-25-wire-it-run-it-deploy-it-ai-workflows-in-gradio/#webpage",
  "@type": [
    "WebPage",
    "ArchiveComponent"
  ],
  "articleBody": "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.\n\n**`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.\n\nThe 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.\n\n## Edit an Image\n\nUpload 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](https://huggingface.co/Qwen/Qwen-Image-Edit) on Hugging Face Inference Providers.\n\n👉 **[Try the Image Editor Pipeline](https://huggingface.co/spaces/ysharma/gr-workflow-image-editor)**\n\n## Chain real models into a media studio\n\nOne graph, three pipelines. Start with a prompt and generate an image with [FLUX](https://huggingface.co/black-forest-labs/FLUX.1-schnell), then pass it to a [background-removal Gradio Space](https://huggingface.co/spaces/not-lain/background-removal) to turn it into a sticker. A topic becomes a voiceover through a [text-to-speech Gradio Space](https://huggingface.co/spaces/mrfakename/MeloTTS), while the same topic becomes a catchy episode title through an [LLM](https://huggingface.co/Qwen/Qwen2.5-7B-Instruct) call.\n\nThat’s one canvas, two model calls through Hugging Face [Inference Providers](https://huggingface.co/docs/inference-providers/en/index), and two calls to Gradio Spaces.\n\nSince 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](https://huggingface.co/blog/gradio-workflow-guide#call-it-from-code) below for a runnable example.\n\n👉 **[Try the AI Media Studio](https://huggingface.co/spaces/ysharma/gr-workflow-04-ai-media-studio)**\n\n## Fan-out image generation in parallel\n\nType 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.\n\nEach 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.\n\n👉 **[Try the Generative Art Lab](https://huggingface.co/spaces/ysharma/gr-workflow-01-generative-art-lab)**\n\n## Profile a Hugging Face dataset\n\nType 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](https://huggingface.co/docs/dataset-viewer) API.\n\nYou 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!\n\n👉 **[Try Data Detective](https://huggingface.co/spaces/ysharma/gr-workflow-03-data-detective)**\n\n## Run your own GPU model\n\nEvery 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.\n\nDecorate the bound function with `@spaces.GPU` and, when the node runs, [ZeroGPU](https://huggingface.co/docs/hub/spaces-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.\n\nCheck out this demo that animates a still image using [Lightricks/LTX-Video](https://huggingface.co/Lightricks/LTX-Video-0.9.7-distilled) 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.\n\n👉 **[Try the ZeroGPU Animator](https://huggingface.co/spaces/ysharma/gr-workflow-zerogpu-animate)**\n\n## How it works, in a nutshell\n\nEvery 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.\n\n## Call it from code\n\nEvery 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:\n\n```python\nfrom gradio_client import Client\n\nclient = Client(\"ysharma/gr-workflow-multi-endpoint-API\")\n\nprint(client.predict(\"hello there friend\", api_name=\"/word_count\"))  # -> 3\nprint(client.predict(20, api_name=\"/fahrenheit\"))                    # -> 68.0\n```\n\nEndpoints that call a model or a Space run under a Hugging Face token, so pass one when you create the client:\n\n```python\nfrom gradio_client import Client, handle_file\n\nclient = Client(\"ysharma/gr-workflow-image-editor\", token=\"hf_...\")\n\nedited = client.predict(\n    handle_file(\"dog.jpg\"),\n    \"turn it into a snowy winter scene\",\n    api_name=\"/edited_image\",\n)\n```\n\nPrefer plain HTTP? Every endpoint is reachable over `curl` too:\n\n```bash\ncurl -s https://ysharma-gr-workflow-multi-endpoint-API.hf.space/gradio_api/call/word_count \\\n  -H \"Content-Type: application/json\" -d '{\"data\": [\"hello there friend\"]}'\n```\n\n## Build your own\n\nThe fastest way in is to open any demo above, click **Duplicate**, and start rewiring. From Python, it is as short as:\n\n```python\nimport gradio as gr\n\ndef your_function(text: str) -> str:\n  pass\n\ngr.Workflow(bind=[your_function]).launch()\n```\n\nFor the full walkthrough, the operator kinds, the JSON schema, and reusable patterns, see the official [gr.Workflow guide](https://gradio.app/guides/workflows) in the Gradio docs.\n\nYou can even build something as involved as [AUTOMATIC1111](https://github.com/automatic1111/stable-diffusion-webui) 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 😉👇\n",
  "authors": [],
  "captured_at": "2026-10-19T01:26:53.998049939+00:00",
  "category": "ai",
  "content_html": "<p>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.</p>\n<p><strong><code>gr.Workflow</code></strong>, built right into Gradio, makes the pipeline <em>the interface</em>. 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.</p>\n<p>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.</p>\n<h2>Edit an Image</h2>\n<p>Upload an image, type an edit (&quot;turn it into a snowy winter scene&quot;, &quot;add sunglasses&quot;, &quot;make the car red&quot;), and get the edited photo back. The whole app is a single node calling <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://huggingface.co/Qwen/Qwen-Image-Edit\">Qwen-Image-Edit</a> on Hugging Face Inference Providers.</p>\n<p>👉 <strong><a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://huggingface.co/spaces/ysharma/gr-workflow-image-editor\">Try the Image Editor Pipeline</a></strong></p>\n<h2>Chain real models into a media studio</h2>\n<p>One graph, three pipelines. Start with a prompt and generate an image with <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://huggingface.co/black-forest-labs/FLUX.1-schnell\">FLUX</a>, then pass it to a <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://huggingface.co/spaces/not-lain/background-removal\">background-removal Gradio Space</a> to turn it into a sticker. A topic becomes a voiceover through a <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://huggingface.co/spaces/mrfakename/MeloTTS\">text-to-speech Gradio Space</a>, while the same topic becomes a catchy episode title through an <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://huggingface.co/Qwen/Qwen2.5-7B-Instruct\">LLM</a> call.</p>\n<p>That’s one canvas, two model calls through Hugging Face <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://huggingface.co/docs/inference-providers/en/index\">Inference Providers</a>, and two calls to Gradio Spaces.</p>\n<p>Since this is a workflow, each of the three outputs also gets its own REST endpoint: <code>/sticker</code>, <code>/voiceover</code>, and <code>/episode_title</code>. You can call any of them directly from code without opening the UI. See <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://huggingface.co/blog/gradio-workflow-guide#call-it-from-code\">Call it from code</a> below for a runnable example.</p>\n<p>👉 <strong><a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://huggingface.co/spaces/ysharma/gr-workflow-04-ai-media-studio\">Try the AI Media Studio</a></strong></p>\n<h2>Fan-out image generation in parallel</h2>\n<p>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.</p>\n<p>Each image is generated directly from the prompt by a model node using Inference Providers, while the title comes from an <code>fn</code> node that calls an LLM. This is the fan-out pattern in action: one idea can feed multiple operators simultaneously, all generating in parallel.</p>\n<p>👉 <strong><a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://huggingface.co/spaces/ysharma/gr-workflow-01-generative-art-lab\">Try the Generative Art Lab</a></strong></p>\n<h2>Profile a Hugging Face dataset</h2>\n<p>Type in a Hugging Face dataset ID, such as <code>stanfordnlp/imdb</code> or <code>mteb/tweet_sentiment_extraction</code>, and a single input fans out to four operator nodes that analyze the dataset live using the <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://huggingface.co/docs/dataset-viewer\">Datasets Server</a> API.</p>\n<p>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!</p>\n<p>👉 <strong><a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://huggingface.co/spaces/ysharma/gr-workflow-03-data-detective\">Try Data Detective</a></strong></p>\n<h2>Run your own GPU model</h2>\n<p>Every node so far reaches out to Hugging Face. But an <code>fn</code> node is just Python, which means it can also run a model inside the Space on a GPU.</p>\n<p>Decorate the bound function with <code>@spaces.GPU</code> and, when the node runs, <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://huggingface.co/docs/hub/spaces-zerogpu\">ZeroGPU</a> 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.</p>\n<p>Check out this demo that animates a still image using <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://huggingface.co/Lightricks/LTX-Video-0.9.7-distilled\">Lightricks/LTX-Video</a> loaded through Diffusers, running entirely through one node. <code>gr.Workflow</code> doesn't need to know anything about your GPU setup. It simply calls the bound function.</p>\n<p>👉 <strong><a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://huggingface.co/spaces/ysharma/gr-workflow-zerogpu-animate\">Try the ZeroGPU Animator</a></strong></p>\n<h2>How it works, in a nutshell</h2>\n<p>Every workflow is a graph with three kinds of nodes: <strong>references</strong> (your inputs), <strong>operators</strong> (the steps that do work), and <strong>subjects</strong> (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.</p>\n<h2>Call it from code</h2>\n<p>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:</p>\n<pre><code class=\"language-python\"><span class=\"code-snippet\" data-language=\"Python\"><span class=\"syntax-source syntax-python\"><span class=\"syntax-meta syntax-statement syntax-import syntax-python\"><span class=\"syntax-keyword syntax-control syntax-import syntax-from syntax-python\">from</span></span><span class=\"syntax-meta syntax-statement syntax-import syntax-python\"><span class=\"syntax-meta syntax-import-source syntax-python\"> <span class=\"syntax-meta syntax-import-path syntax-python\"><span class=\"syntax-meta syntax-import-name syntax-python\">gradio_client</span></span> <span class=\"syntax-meta syntax-statement syntax-import syntax-python\"><span class=\"syntax-keyword syntax-control syntax-import syntax-python\">import</span></span></span></span><span class=\"syntax-meta syntax-statement syntax-import syntax-python\"></span><span class=\"syntax-meta syntax-statement syntax-import syntax-python\"> <span class=\"syntax-meta syntax-generic-name syntax-python\">Client</span></span>\n\n<span class=\"syntax-meta syntax-qualified-name syntax-python\"><span class=\"syntax-meta syntax-generic-name syntax-python\">client</span></span> <span class=\"syntax-keyword syntax-operator syntax-assignment syntax-python\">=</span> <span class=\"syntax-meta syntax-function-call syntax-python\"><span class=\"syntax-meta syntax-qualified-name syntax-python\"><span class=\"syntax-variable syntax-function syntax-python\">Client</span></span><span class=\"syntax-punctuation syntax-section syntax-arguments syntax-begin syntax-python\">(</span><span class=\"syntax-meta syntax-function-call syntax-arguments syntax-python\"><span class=\"syntax-meta syntax-string syntax-python\"><span class=\"syntax-string syntax-quoted syntax-double syntax-python\"><span class=\"syntax-punctuation syntax-definition syntax-string syntax-begin syntax-python\">&quot;</span></span></span><span class=\"syntax-meta syntax-string syntax-python\"><span class=\"syntax-string syntax-quoted syntax-double syntax-python\">ysharma/gr-workflow-multi-endpoint-API<span class=\"syntax-punctuation syntax-definition syntax-string syntax-end syntax-python\">&quot;</span></span></span></span><span class=\"syntax-punctuation syntax-section syntax-arguments syntax-end syntax-python\">)</span></span>\n\n<span class=\"syntax-meta syntax-function-call syntax-python\"><span class=\"syntax-meta syntax-qualified-name syntax-python\"><span class=\"syntax-support syntax-function syntax-builtin syntax-python\">print</span></span><span class=\"syntax-punctuation syntax-section syntax-arguments syntax-begin syntax-python\">(</span><span class=\"syntax-meta syntax-function-call syntax-arguments syntax-python\"><span class=\"syntax-meta syntax-function-call syntax-python\"><span class=\"syntax-meta syntax-qualified-name syntax-python\"><span class=\"syntax-meta syntax-generic-name syntax-python\">client</span><span class=\"syntax-punctuation syntax-accessor syntax-dot syntax-python\">.</span></span><span class=\"syntax-meta syntax-qualified-name syntax-python\"><span class=\"syntax-variable syntax-function syntax-python\">predict</span></span><span class=\"syntax-punctuation syntax-section syntax-arguments syntax-begin syntax-python\">(</span><span class=\"syntax-meta syntax-function-call syntax-arguments syntax-python\"><span class=\"syntax-meta syntax-string syntax-python\"><span class=\"syntax-string syntax-quoted syntax-double syntax-python\"><span class=\"syntax-punctuation syntax-definition syntax-string syntax-begin syntax-python\">&quot;</span></span></span><span class=\"syntax-meta syntax-string syntax-python\"><span class=\"syntax-string syntax-quoted syntax-double syntax-python\">hello there friend<span class=\"syntax-punctuation syntax-definition syntax-string syntax-end syntax-python\">&quot;</span></span></span><span class=\"syntax-punctuation syntax-separator syntax-arguments syntax-python\">,</span> <span class=\"syntax-variable syntax-parameter syntax-python\">api_name</span><span class=\"syntax-keyword syntax-operator syntax-assignment syntax-python\">=</span><span class=\"syntax-meta syntax-string syntax-python\"><span class=\"syntax-string syntax-quoted syntax-double syntax-python\"><span class=\"syntax-punctuation syntax-definition syntax-string syntax-begin syntax-python\">&quot;</span></span></span><span class=\"syntax-meta syntax-string syntax-python\"><span class=\"syntax-string syntax-quoted syntax-double syntax-python\">/word_count<span class=\"syntax-punctuation syntax-definition syntax-string syntax-end syntax-python\">&quot;</span></span></span></span><span class=\"syntax-punctuation syntax-section syntax-arguments syntax-end syntax-python\">)</span></span></span><span class=\"syntax-punctuation syntax-section syntax-arguments syntax-end syntax-python\">)</span></span>  <span class=\"syntax-comment syntax-line syntax-number-sign syntax-python\"><span class=\"syntax-punctuation syntax-definition syntax-comment syntax-python\">#</span> -&gt; 3\n</span><span class=\"syntax-meta syntax-function-call syntax-python\"><span class=\"syntax-meta syntax-qualified-name syntax-python\"><span class=\"syntax-support syntax-function syntax-builtin syntax-python\">print</span></span><span class=\"syntax-punctuation syntax-section syntax-arguments syntax-begin syntax-python\">(</span><span class=\"syntax-meta syntax-function-call syntax-arguments syntax-python\"><span class=\"syntax-meta syntax-function-call syntax-python\"><span class=\"syntax-meta syntax-qualified-name syntax-python\"><span class=\"syntax-meta syntax-generic-name syntax-python\">client</span><span class=\"syntax-punctuation syntax-accessor syntax-dot syntax-python\">.</span></span><span class=\"syntax-meta syntax-qualified-name syntax-python\"><span class=\"syntax-variable syntax-function syntax-python\">predict</span></span><span class=\"syntax-punctuation syntax-section syntax-arguments syntax-begin syntax-python\">(</span><span class=\"syntax-meta syntax-function-call syntax-arguments syntax-python\"><span class=\"syntax-constant syntax-numeric syntax-integer syntax-decimal syntax-python\">20</span><span class=\"syntax-punctuation syntax-separator syntax-arguments syntax-python\">,</span> <span class=\"syntax-variable syntax-parameter syntax-python\">api_name</span><span class=\"syntax-keyword syntax-operator syntax-assignment syntax-python\">=</span><span class=\"syntax-meta syntax-string syntax-python\"><span class=\"syntax-string syntax-quoted syntax-double syntax-python\"><span class=\"syntax-punctuation syntax-definition syntax-string syntax-begin syntax-python\">&quot;</span></span></span><span class=\"syntax-meta syntax-string syntax-python\"><span class=\"syntax-string syntax-quoted syntax-double syntax-python\">/fahrenheit<span class=\"syntax-punctuation syntax-definition syntax-string syntax-end syntax-python\">&quot;</span></span></span></span><span class=\"syntax-punctuation syntax-section syntax-arguments syntax-end syntax-python\">)</span></span></span><span class=\"syntax-punctuation syntax-section syntax-arguments syntax-end syntax-python\">)</span></span>                    <span class=\"syntax-comment syntax-line syntax-number-sign syntax-python\"><span class=\"syntax-punctuation syntax-definition syntax-comment syntax-python\">#</span> -&gt; 68.0\n</span></span></span></code></pre>\n<p>Endpoints that call a model or a Space run under a Hugging Face token, so pass one when you create the client:</p>\n<pre><code class=\"language-python\"><span class=\"code-snippet\" data-language=\"Python\"><span class=\"syntax-source syntax-python\"><span class=\"syntax-meta syntax-statement syntax-import syntax-python\"><span class=\"syntax-keyword syntax-control syntax-import syntax-from syntax-python\">from</span></span><span class=\"syntax-meta syntax-statement syntax-import syntax-python\"><span class=\"syntax-meta syntax-import-source syntax-python\"> <span class=\"syntax-meta syntax-import-path syntax-python\"><span class=\"syntax-meta syntax-import-name syntax-python\">gradio_client</span></span> <span class=\"syntax-meta syntax-statement syntax-import syntax-python\"><span class=\"syntax-keyword syntax-control syntax-import syntax-python\">import</span></span></span></span><span class=\"syntax-meta syntax-statement syntax-import syntax-python\"></span><span class=\"syntax-meta syntax-statement syntax-import syntax-python\"> <span class=\"syntax-meta syntax-generic-name syntax-python\">Client</span><span class=\"syntax-punctuation syntax-separator syntax-import-list syntax-python\">,</span> <span class=\"syntax-meta syntax-generic-name syntax-python\">handle_file</span></span>\n\n<span class=\"syntax-meta syntax-qualified-name syntax-python\"><span class=\"syntax-meta syntax-generic-name syntax-python\">client</span></span> <span class=\"syntax-keyword syntax-operator syntax-assignment syntax-python\">=</span> <span class=\"syntax-meta syntax-function-call syntax-python\"><span class=\"syntax-meta syntax-qualified-name syntax-python\"><span class=\"syntax-variable syntax-function syntax-python\">Client</span></span><span class=\"syntax-punctuation syntax-section syntax-arguments syntax-begin syntax-python\">(</span><span class=\"syntax-meta syntax-function-call syntax-arguments syntax-python\"><span class=\"syntax-meta syntax-string syntax-python\"><span class=\"syntax-string syntax-quoted syntax-double syntax-python\"><span class=\"syntax-punctuation syntax-definition syntax-string syntax-begin syntax-python\">&quot;</span></span></span><span class=\"syntax-meta syntax-string syntax-python\"><span class=\"syntax-string syntax-quoted syntax-double syntax-python\">ysharma/gr-workflow-image-editor<span class=\"syntax-punctuation syntax-definition syntax-string syntax-end syntax-python\">&quot;</span></span></span><span class=\"syntax-punctuation syntax-separator syntax-arguments syntax-python\">,</span> <span class=\"syntax-variable syntax-parameter syntax-python\">token</span><span class=\"syntax-keyword syntax-operator syntax-assignment syntax-python\">=</span><span class=\"syntax-meta syntax-string syntax-python\"><span class=\"syntax-string syntax-quoted syntax-double syntax-python\"><span class=\"syntax-punctuation syntax-definition syntax-string syntax-begin syntax-python\">&quot;</span></span></span><span class=\"syntax-meta syntax-string syntax-python\"><span class=\"syntax-string syntax-quoted syntax-double syntax-python\">hf_...<span class=\"syntax-punctuation syntax-definition syntax-string syntax-end syntax-python\">&quot;</span></span></span></span><span class=\"syntax-punctuation syntax-section syntax-arguments syntax-end syntax-python\">)</span></span>\n\n<span class=\"syntax-meta syntax-qualified-name syntax-python\"><span class=\"syntax-meta syntax-generic-name syntax-python\">edited</span></span> <span class=\"syntax-keyword syntax-operator syntax-assignment syntax-python\">=</span> <span class=\"syntax-meta syntax-function-call syntax-python\"><span class=\"syntax-meta syntax-qualified-name syntax-python\"><span class=\"syntax-meta syntax-generic-name syntax-python\">client</span><span class=\"syntax-punctuation syntax-accessor syntax-dot syntax-python\">.</span></span><span class=\"syntax-meta syntax-qualified-name syntax-python\"><span class=\"syntax-variable syntax-function syntax-python\">predict</span></span><span class=\"syntax-punctuation syntax-section syntax-arguments syntax-begin syntax-python\">(</span><span class=\"syntax-meta syntax-function-call syntax-arguments syntax-python\">\n    <span class=\"syntax-meta syntax-function-call syntax-python\"><span class=\"syntax-meta syntax-qualified-name syntax-python\"><span class=\"syntax-variable syntax-function syntax-python\">handle_file</span></span><span class=\"syntax-punctuation syntax-section syntax-arguments syntax-begin syntax-python\">(</span><span class=\"syntax-meta syntax-function-call syntax-arguments syntax-python\"><span class=\"syntax-meta syntax-string syntax-python\"><span class=\"syntax-string syntax-quoted syntax-double syntax-python\"><span class=\"syntax-punctuation syntax-definition syntax-string syntax-begin syntax-python\">&quot;</span></span></span><span class=\"syntax-meta syntax-string syntax-python\"><span class=\"syntax-string syntax-quoted syntax-double syntax-python\">dog.jpg<span class=\"syntax-punctuation syntax-definition syntax-string syntax-end syntax-python\">&quot;</span></span></span></span><span class=\"syntax-punctuation syntax-section syntax-arguments syntax-end syntax-python\">)</span></span><span class=\"syntax-punctuation syntax-separator syntax-arguments syntax-python\">,</span>\n    <span class=\"syntax-meta syntax-string syntax-python\"><span class=\"syntax-string syntax-quoted syntax-double syntax-python\"><span class=\"syntax-punctuation syntax-definition syntax-string syntax-begin syntax-python\">&quot;</span></span></span><span class=\"syntax-meta syntax-string syntax-python\"><span class=\"syntax-string syntax-quoted syntax-double syntax-python\">turn it into a snowy winter scene<span class=\"syntax-punctuation syntax-definition syntax-string syntax-end syntax-python\">&quot;</span></span></span><span class=\"syntax-punctuation syntax-separator syntax-arguments syntax-python\">,</span>\n    <span class=\"syntax-variable syntax-parameter syntax-python\">api_name</span><span class=\"syntax-keyword syntax-operator syntax-assignment syntax-python\">=</span><span class=\"syntax-meta syntax-string syntax-python\"><span class=\"syntax-string syntax-quoted syntax-double syntax-python\"><span class=\"syntax-punctuation syntax-definition syntax-string syntax-begin syntax-python\">&quot;</span></span></span><span class=\"syntax-meta syntax-string syntax-python\"><span class=\"syntax-string syntax-quoted syntax-double syntax-python\">/edited_image<span class=\"syntax-punctuation syntax-definition syntax-string syntax-end syntax-python\">&quot;</span></span></span><span class=\"syntax-punctuation syntax-separator syntax-arguments syntax-python\">,</span>\n</span><span class=\"syntax-punctuation syntax-section syntax-arguments syntax-end syntax-python\">)</span></span>\n</span></span></code></pre>\n<p>Prefer plain HTTP? Every endpoint is reachable over <code>curl</code> too:</p>\n<pre><code class=\"language-bash\"><span class=\"code-snippet\" data-language=\"Shell\"><span class=\"syntax-source syntax-shell syntax-bash\"><span class=\"syntax-meta syntax-function-call syntax-shell\"><span class=\"syntax-variable syntax-function syntax-shell\">curl</span></span><span class=\"syntax-meta syntax-function-call syntax-arguments syntax-shell\"><span class=\"syntax-variable syntax-parameter syntax-option syntax-shell\"><span class=\"syntax-punctuation syntax-definition syntax-parameter syntax-shell\"> -</span>s</span> https://ysharma-gr-workflow-multi-endpoint-API.hf.space/gradio_api/call/word_count <span class=\"syntax-punctuation syntax-separator syntax-continuation syntax-line syntax-shell\">\\\n</span><span class=\"syntax-variable syntax-parameter syntax-option syntax-shell\"><span class=\"syntax-punctuation syntax-definition syntax-parameter syntax-shell\">  -</span>H</span> <span class=\"syntax-string syntax-quoted syntax-double syntax-shell\"><span class=\"syntax-punctuation syntax-definition syntax-string syntax-begin syntax-shell\">&quot;</span>Content-Type: application/json<span class=\"syntax-punctuation syntax-definition syntax-string syntax-end syntax-shell\">&quot;</span></span><span class=\"syntax-variable syntax-parameter syntax-option syntax-shell\"><span class=\"syntax-punctuation syntax-definition syntax-parameter syntax-shell\"> -</span>d</span> <span class=\"syntax-string syntax-quoted syntax-single syntax-shell\"><span class=\"syntax-punctuation syntax-definition syntax-string syntax-begin syntax-shell\">&#39;</span>{&quot;data&quot;: [&quot;hello there friend&quot;]}<span class=\"syntax-punctuation syntax-definition syntax-string syntax-end syntax-shell\">&#39;</span></span></span>\n</span></span></code></pre>\n<h2>Build your own</h2>\n<p>The fastest way in is to open any demo above, click <strong>Duplicate</strong>, and start rewiring. From Python, it is as short as:</p>\n<pre><code class=\"language-python\"><span class=\"code-snippet\" data-language=\"Python\"><span class=\"syntax-source syntax-python\"><span class=\"syntax-meta syntax-statement syntax-import syntax-python\"><span class=\"syntax-keyword syntax-control syntax-import syntax-python\">import</span> <span class=\"syntax-meta syntax-qualified-name syntax-python\"><span class=\"syntax-meta syntax-generic-name syntax-python\">gradio</span></span> <span class=\"syntax-keyword syntax-control syntax-import syntax-as syntax-python\">as</span> <span class=\"syntax-meta syntax-qualified-name syntax-python\"><span class=\"syntax-meta syntax-generic-name syntax-python\">gr</span></span></span>\n\n<span class=\"syntax-meta syntax-function syntax-python\"><span class=\"syntax-storage syntax-type syntax-function syntax-python\">def</span> <span class=\"syntax-entity syntax-name syntax-function syntax-python\"><span class=\"syntax-meta syntax-generic-name syntax-python\">your_function</span></span></span><span class=\"syntax-meta syntax-function syntax-parameters syntax-python\"><span class=\"syntax-punctuation syntax-section syntax-parameters syntax-begin syntax-python\">(</span></span><span class=\"syntax-meta syntax-function syntax-parameters syntax-python\"><span class=\"syntax-variable syntax-parameter syntax-python\">text</span></span><span class=\"syntax-meta syntax-function syntax-parameters syntax-annotation syntax-python\"><span class=\"syntax-punctuation syntax-separator syntax-annotation syntax-parameter syntax-python\">:</span> <span class=\"syntax-meta syntax-qualified-name syntax-python\"><span class=\"syntax-support syntax-type syntax-python\">str</span></span></span><span class=\"syntax-meta syntax-function syntax-parameters syntax-python\"><span class=\"syntax-punctuation syntax-section syntax-parameters syntax-end syntax-python\">)</span></span><span class=\"syntax-meta syntax-function syntax-python\"> </span><span class=\"syntax-meta syntax-function syntax-annotation syntax-return syntax-python\"><span class=\"syntax-punctuation syntax-separator syntax-annotation syntax-return syntax-python\">-&gt;</span> <span class=\"syntax-meta syntax-qualified-name syntax-python\"><span class=\"syntax-support syntax-type syntax-python\">str</span></span></span><span class=\"syntax-meta syntax-function syntax-python\"><span class=\"syntax-punctuation syntax-section syntax-function syntax-begin syntax-python\">:</span></span>\n  <span class=\"syntax-keyword syntax-control syntax-flow syntax-python\">pass</span>\n\n<span class=\"syntax-meta syntax-function-call syntax-python\"><span class=\"syntax-meta syntax-qualified-name syntax-python\"><span class=\"syntax-meta syntax-generic-name syntax-python\">gr</span><span class=\"syntax-punctuation syntax-accessor syntax-dot syntax-python\">.</span></span><span class=\"syntax-meta syntax-qualified-name syntax-python\"><span class=\"syntax-variable syntax-function syntax-python\">Workflow</span></span><span class=\"syntax-punctuation syntax-section syntax-arguments syntax-begin syntax-python\">(</span><span class=\"syntax-meta syntax-function-call syntax-arguments syntax-python\"><span class=\"syntax-variable syntax-parameter syntax-python\">bind</span><span class=\"syntax-keyword syntax-operator syntax-assignment syntax-python\">=</span><span class=\"syntax-meta syntax-structure syntax-list syntax-python\"><span class=\"syntax-punctuation syntax-section syntax-list syntax-begin syntax-python\">[</span><span class=\"syntax-meta syntax-qualified-name syntax-python\"><span class=\"syntax-meta syntax-generic-name syntax-python\">your_function</span></span><span class=\"syntax-punctuation syntax-section syntax-list syntax-end syntax-python\">]</span></span></span><span class=\"syntax-punctuation syntax-section syntax-arguments syntax-end syntax-python\">)</span></span><span class=\"syntax-meta syntax-function-call syntax-python\"><span class=\"syntax-meta syntax-qualified-name syntax-python\"><span class=\"syntax-punctuation syntax-accessor syntax-dot syntax-python\">.</span></span><span class=\"syntax-meta syntax-qualified-name syntax-python\"><span class=\"syntax-variable syntax-function syntax-python\">launch</span></span><span class=\"syntax-punctuation syntax-section syntax-arguments syntax-begin syntax-python\">(</span><span class=\"syntax-punctuation syntax-section syntax-arguments syntax-end syntax-python\">)</span></span>\n</span></span></code></pre>\n<p>For the full walkthrough, the operator kinds, the JSON schema, and reusable patterns, see the official <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://gradio.app/guides/workflows\">gr.Workflow guide</a> in the Gradio docs.</p>\n<p>You can even build something as involved as <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://github.com/automatic1111/stable-diffusion-webui\">AUTOMATIC1111</a> with <code>gr.Workflow</code>. Keep an eye out for our next post, where we walk through building it step by step. Here is a sneak peek 😉👇</p>\n",
  "content_markdown": "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.\n\n**`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.\n\nThe 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.\n\n## Edit an Image\n\nUpload 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](https://huggingface.co/Qwen/Qwen-Image-Edit) on Hugging Face Inference Providers.\n\n👉 **[Try the Image Editor Pipeline](https://huggingface.co/spaces/ysharma/gr-workflow-image-editor)**\n\n## Chain real models into a media studio\n\nOne graph, three pipelines. Start with a prompt and generate an image with [FLUX](https://huggingface.co/black-forest-labs/FLUX.1-schnell), then pass it to a [background-removal Gradio Space](https://huggingface.co/spaces/not-lain/background-removal) to turn it into a sticker. A topic becomes a voiceover through a [text-to-speech Gradio Space](https://huggingface.co/spaces/mrfakename/MeloTTS), while the same topic becomes a catchy episode title through an [LLM](https://huggingface.co/Qwen/Qwen2.5-7B-Instruct) call.\n\nThat’s one canvas, two model calls through Hugging Face [Inference Providers](https://huggingface.co/docs/inference-providers/en/index), and two calls to Gradio Spaces.\n\nSince 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](https://huggingface.co/blog/gradio-workflow-guide#call-it-from-code) below for a runnable example.\n\n👉 **[Try the AI Media Studio](https://huggingface.co/spaces/ysharma/gr-workflow-04-ai-media-studio)**\n\n## Fan-out image generation in parallel\n\nType 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.\n\nEach 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.\n\n👉 **[Try the Generative Art Lab](https://huggingface.co/spaces/ysharma/gr-workflow-01-generative-art-lab)**\n\n## Profile a Hugging Face dataset\n\nType 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](https://huggingface.co/docs/dataset-viewer) API.\n\nYou 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!\n\n👉 **[Try Data Detective](https://huggingface.co/spaces/ysharma/gr-workflow-03-data-detective)**\n\n## Run your own GPU model\n\nEvery 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.\n\nDecorate the bound function with `@spaces.GPU` and, when the node runs, [ZeroGPU](https://huggingface.co/docs/hub/spaces-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.\n\nCheck out this demo that animates a still image using [Lightricks/LTX-Video](https://huggingface.co/Lightricks/LTX-Video-0.9.7-distilled) 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.\n\n👉 **[Try the ZeroGPU Animator](https://huggingface.co/spaces/ysharma/gr-workflow-zerogpu-animate)**\n\n## How it works, in a nutshell\n\nEvery 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.\n\n## Call it from code\n\nEvery 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:\n\n```python\nfrom gradio_client import Client\n\nclient = Client(\"ysharma/gr-workflow-multi-endpoint-API\")\n\nprint(client.predict(\"hello there friend\", api_name=\"/word_count\"))  # -> 3\nprint(client.predict(20, api_name=\"/fahrenheit\"))                    # -> 68.0\n```\n\nEndpoints that call a model or a Space run under a Hugging Face token, so pass one when you create the client:\n\n```python\nfrom gradio_client import Client, handle_file\n\nclient = Client(\"ysharma/gr-workflow-image-editor\", token=\"hf_...\")\n\nedited = client.predict(\n    handle_file(\"dog.jpg\"),\n    \"turn it into a snowy winter scene\",\n    api_name=\"/edited_image\",\n)\n```\n\nPrefer plain HTTP? Every endpoint is reachable over `curl` too:\n\n```bash\ncurl -s https://ysharma-gr-workflow-multi-endpoint-API.hf.space/gradio_api/call/word_count \\\n  -H \"Content-Type: application/json\" -d '{\"data\": [\"hello there friend\"]}'\n```\n\n## Build your own\n\nThe fastest way in is to open any demo above, click **Duplicate**, and start rewiring. From Python, it is as short as:\n\n```python\nimport gradio as gr\n\ndef your_function(text: str) -> str:\n  pass\n\ngr.Workflow(bind=[your_function]).launch()\n```\n\nFor the full walkthrough, the operator kinds, the JSON schema, and reusable patterns, see the official [gr.Workflow guide](https://gradio.app/guides/workflows) in the Gradio docs.\n\nYou can even build something as involved as [AUTOMATIC1111](https://github.com/automatic1111/stable-diffusion-webui) 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 😉👇\n",
  "dateCreated": "2026-10-19T01:26:53.998049939+00:00",
  "date_created": "2026-08-25T00:00:00+00:00",
  "date_modified": "2026-08-25T00:00:00+00:00",
  "date_published": "2026-08-25T00:00:00+00:00",
  "description": "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…",
  "external_url": "https://huggingface.co/blog/gradio-workflow-guide",
  "git": {
    "commit": "ebb0941c5c06a2ab2377342d607535262a3e969e",
    "path": "items/huggingface-co/2026/08/2026-08-25-wire-it-run-it-deploy-it-ai-workflows-in-gradio.md",
    "permalink": "https://github.com/aymericbeaumet/aggr-instance/blob/ebb0941c5c06a2ab2377342d607535262a3e969e/items/huggingface-co/2026/08/2026-08-25-wire-it-run-it-deploy-it-ai-workflows-in-gradio.md"
  },
  "id": "urn:aggr:item:4ddb48e83cbb5a964a86c04c08123e3d56f80b91",
  "isBasedOn": {
    "@id": "https://huggingface.co/blog/gradio-workflow-guide"
  },
  "mainEntity": {
    "@id": "https://huggingface.co/blog/gradio-workflow-guide",
    "@type": "CreativeWork",
    "archivedAt": {
      "@id": "https://aggr.aymericbeaumet.com/items/huggingface-co/2026-08-25-wire-it-run-it-deploy-it-ai-workflows-in-gradio/#webpage"
    },
    "dateModified": "2026-08-25T00:00:00+00:00",
    "datePublished": "2026-08-25T00:00:00+00:00",
    "headline": "Wire It, Run It, Deploy It: AI Workflows in Gradio",
    "image": {
      "@type": "ImageObject",
      "caption": null,
      "height": 90,
      "url": "https://huggingface.co/blog/assets/gradio-workflow-guide/thumbnail.png",
      "width": 160
    },
    "timeRequired": "PT5M",
    "url": "https://huggingface.co/blog/gradio-workflow-guide",
    "wordCount": 945
  },
  "name": "Archived snapshot: Wire It, Run It, Deploy It: AI Workflows in Gradio",
  "preview": {
    "alt": null,
    "color": null,
    "height": 90,
    "placeholder": {
      "data_url": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+A8AAQUBAScY42YAAAAASUVORK5CYII=",
      "hash": ""
    },
    "url": "https://huggingface.co/blog/assets/gradio-workflow-guide/thumbnail.png",
    "width": 160
  },
  "reading_minutes": 5,
  "replicated_at": null,
  "source": "huggingface-co",
  "source_name": "Hugging Face - Blog",
  "summary": null,
  "tags": [],
  "temporalCoverage": "2026-10-19T01:26:53.998049939+00:00",
  "title": "Wire It, Run It, Deploy It: AI Workflows in Gradio",
  "url": "https://aggr.aymericbeaumet.com/items/huggingface-co/2026-08-25-wire-it-run-it-deploy-it-ai-workflows-in-gradio/",
  "word_count": 945
}