<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: raphiki</title>
    <description>The latest articles on DEV Community by raphiki (@raphiki).</description>
    <link>https://dev.to/raphiki</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F982002%2Fb4188602-61e2-49e6-85be-d590a9b2e228.png</url>
      <title>DEV Community: raphiki</title>
      <link>https://dev.to/raphiki</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/raphiki"/>
    <language>en</language>
    <item>
      <title>Driving Local ComfyUI from Codex with MCP</title>
      <dc:creator>raphiki</dc:creator>
      <pubDate>Fri, 21 Aug 2026 14:46:13 +0000</pubDate>
      <link>https://dev.to/raphiki/driving-local-comfyui-from-codex-with-mcp-1go7</link>
      <guid>https://dev.to/raphiki/driving-local-comfyui-from-codex-with-mcp-1go7</guid>
      <description>&lt;p&gt;In the previous articles of the &lt;a href="https://dev.to/raphiki/series/33284"&gt;Beyond the ComfyUI Canvas&lt;/a&gt; series, I connected ComfyUI to notebooks, WebSockets, n8n, and Flowise. I even created my own MCP Server. Each integration worked, but it still required me to write or maintain the glue: HTTP payloads, polling loops, node IDs, and workflow-specific code.&lt;/p&gt;

&lt;p&gt;Today, I am taking a more direct route. I will connect a local ComfyUI installation to Codex through the official open-source &lt;a href="https://github.com/Comfy-Org/comfy-mcp" rel="noopener noreferrer"&gt;Comfy MCP server&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fuy7enszji5y1kcs203b2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fuy7enszji5y1kcs203b2.png" alt="Comfy MCP" width="470" height="138"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The goal is simple: let an AI agent inspect the local ComfyUI instance, discover installed models, validate an existing workflow, run it, wait for completion, and bring the generated image back into the conversation.&lt;/p&gt;

&lt;p&gt;No custom Python bridge. No hand-written &lt;code&gt;/prompt&lt;/code&gt; request. The agent uses a standard MCP tool interface; Comfy MCP translates those tool calls into &lt;code&gt;comfy-cli&lt;/code&gt; commands targeting my local ComfyUI server.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Setting the Scene: The Stack
&lt;/h2&gt;

&lt;p&gt;The local stack I used has three layers:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Codex&lt;/strong&gt; is the agent and MCP client. It receives natural-language requests and decides which tools to call.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Comfy MCP&lt;/strong&gt; is the open-source MCP server from Comfy. It runs as a local stdio process and wraps &lt;code&gt;comfy-cli&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;ComfyUI&lt;/strong&gt; is the generation engine, running locally at &lt;code&gt;http://127.0.0.1:8188&lt;/code&gt; on a GPU-equipped machine.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F52x9ete6p0y063i8kh6a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F52x9ete6p0y063i8kh6a.png" alt="A local, agent-controlled generation stack" width="800" height="310"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is not Comfy Cloud MCP. The complete flow stays on the local machine: the workflow, models, queue, and generated images all remain in the local ComfyUI workspace. The only exception is a workflow that deliberately uses paid partner API nodes.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Install the Local Components
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Let Codex do the setup
&lt;/h3&gt;

&lt;p&gt;Steps 2 and 3 can be delegated to Codex itself. Instead of manually installing packages and editing the MCP configuration, give Codex this prompt:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Help me set up the local Comfy MCP connection.&lt;br&gt;&lt;br&gt;
Follow the setup guide at &lt;a href="https://docs.comfy.org/agent-tools/mcp.md#local-comfy-mcp-connection" rel="noopener noreferrer"&gt;https://docs.comfy.org/agent-tools/mcp.md#local-comfy-mcp-connection&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Codex can inspect the machine, install the required packages, create or locate the ComfyUI workspace, configure the MCP server, and then verify the connection. It should still show you any required permissions before making changes outside its workspace.&lt;/p&gt;

&lt;p&gt;The Comfy MCP server is built on top of &lt;code&gt;comfy-cli&lt;/code&gt;, so both packages are required:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;py&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;-m&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;pip&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;install&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;comfy-mcp&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"comfy-cli&amp;gt;=1.14.0"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If ComfyUI is not installed yet, create a workspace with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;comfy&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;install&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For an existing workspace, make it the default instead:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;comfy&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;set-default&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;C:\path\to\ComfyUI&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then launch the local server:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;comfy&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;launch&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In my case, ComfyUI was installed in &lt;code&gt;C:\Users\rapha\Documents\comfy\ComfyUI&lt;/code&gt; and became available at &lt;code&gt;http://127.0.0.1:8188&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Windows PATH trap
&lt;/h3&gt;

&lt;p&gt;On Windows, packages installed with Python can place &lt;code&gt;comfy.exe&lt;/code&gt; and &lt;code&gt;comfy-mcp.exe&lt;/code&gt; in a &lt;code&gt;Scripts&lt;/code&gt; directory that is not on the PATH inherited by desktop applications.&lt;/p&gt;

&lt;p&gt;That can be confusing: the MCP server starts and completes its handshake, but every useful tool fails with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;comfy not found on PATH
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The robust fix is to configure &lt;code&gt;COMFY_BIN&lt;/code&gt; with the absolute path to &lt;code&gt;comfy.exe&lt;/code&gt;. It makes the MCP server independent from the client application's PATH.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Connect Comfy MCP to Codex
&lt;/h2&gt;

&lt;p&gt;Codex stores local MCP servers in its configuration. Add the following to &lt;code&gt;~/.codex/config.toml&lt;/code&gt;, adapting the paths to your Python installation:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight toml"&gt;&lt;code&gt;&lt;span class="nn"&gt;[mcp_servers.comfy-mcp]&lt;/span&gt;
&lt;span class="py"&gt;command&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;'C:\Users\&amp;lt;you&amp;gt;\AppData\Roaming\Python\Python313\Scripts\comfy-mcp.exe'&lt;/span&gt;

&lt;span class="nn"&gt;[mcp_servers.comfy-mcp.env]&lt;/span&gt;
&lt;span class="py"&gt;COMFY_BIN&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;'C:\Users\&amp;lt;you&amp;gt;\AppData\Roaming\Python\Python313\Scripts\comfy.exe'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Restart or reload Codex after changing the configuration. The server is a stdio MCP server: Codex launches &lt;code&gt;comfy-mcp&lt;/code&gt; as a subprocess when it needs the tools.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;COMFY_API_KEY&lt;/code&gt; is not required for local Flux, SDXL, or other locally installed models. Add it only when you intentionally use Comfy partner API nodes that spend credits.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  4. First Contact: Verify the Engine and Inspect Models
&lt;/h2&gt;

&lt;p&gt;The first useful test is not image generation. It is asking Codex to inspect the live server:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Confirm that my local ComfyUI is running and list the installed models.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Under the hood, Codex calls Comfy MCP's &lt;code&gt;server_info&lt;/code&gt; and &lt;code&gt;search_models&lt;/code&gt; tools. In my test, the server reported a healthy local ComfyUI instance at &lt;code&gt;127.0.0.1:8188&lt;/code&gt;, and the model search found the locally installed Flux 2 Klein model, VAEs, text encoders, LoRAs, and checkpoint files.&lt;/p&gt;

&lt;p&gt;This is an important difference from a static prompt template. The agent can inspect what &lt;em&gt;this&lt;/em&gt; ComfyUI instance actually has before it attempts a workflow. That makes it much easier to diagnose a missing model or a custom-node mismatch.&lt;/p&gt;

&lt;p&gt;Other operational actions are available through the same connection:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;server_info        # health, server address and capabilities
search_models      # models visible to this ComfyUI instance
search_templates   # templates from the Comfy registry
launch_comfyui     # start the local server
stop_comfyui       # stop the local server
get_logs           # inspect server logs when a run fails
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  5. Workflows: Templates vs. Local Exports
&lt;/h2&gt;

&lt;p&gt;There are two workflow paths worth keeping separate.&lt;/p&gt;

&lt;h3&gt;
  
  
  Registry templates
&lt;/h3&gt;

&lt;p&gt;For a Comfy template, the agent can search the registry, inspect a template, fetch it into a runnable JSON file, validate it against the local installation, and run it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F10wir5gmnovvqw2am1wu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F10wir5gmnovvqw2am1wu.png" alt="Two workflow routes, one execution path" width="800" height="360"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Your own workflows
&lt;/h3&gt;

&lt;p&gt;For a workflow created in the ComfyUI canvas, export it as JSON and give Codex the file path. Comfy MCP's &lt;code&gt;run_workflow&lt;/code&gt; accepts both API-format workflow JSON and a UI-exported workflow file.&lt;/p&gt;

&lt;p&gt;This is the path I used for &lt;code&gt;image_flux2_text_to_image.json&lt;/code&gt;, a Flux 2 Klein text-to-image workflow. The workflow contained a dedicated prompt input wired to the positive conditioning node, so changing the prompt did not require rebuilding the graph.&lt;/p&gt;

&lt;p&gt;The practical rule is simple: templates are discovered from the registry; personal workflows are supplied as exported JSON files.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. The Use Case: A Cyberpunk Image from a Conversation
&lt;/h2&gt;

&lt;p&gt;With the connection tested, I asked Codex to create an evocative cyberpunk prompt and generate an image with the existing Flux workflow.&lt;/p&gt;

&lt;p&gt;The prompt injected into the workflow was:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;A lone courier in a rain-soaked neon megacity at midnight, riding a sleek black
motorcycle through a narrow alley beneath towering holographic billboards;
crimson and electric cyan reflections ripple across wet pavement, steam drifting
from street vents, distant elevated trains, cinematic low-angle composition,
moody noir atmosphere, intricate futuristic street details, expressive visual
storytelling, photorealistic, high contrast, luminous volumetric rain
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The agent followed a safe execution sequence:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1. validate_workflow(workflow_path)
2. run_workflow(workflow_path, wait=false)
3. job(action="wait", prompt_id=...)
4. fetch_outputs(prompt_id, out_dir="./outputs")
5. Display the downloaded image in Codex
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The validation result was clean: no errors, no warnings, and no credit-spending nodes. ComfyUI then queued the job, rendered it locally, and returned an output URL. &lt;code&gt;fetch_outputs&lt;/code&gt; copied the completed PNG into the Codex workspace, where it could be displayed directly in the conversation.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fmb9lk88cfnhlav3goiaj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fmb9lk88cfnhlav3goiaj.png" alt="A cyberpunk courier rides through a neon, rain-soaked alley" width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The output is more than a pretty picture. It proves the full control loop:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F51anxltyqb4j3nh3deu7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F51anxltyqb4j3nh3deu7.png" alt="The safe local generation loop" width="800" height="325"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  7. What MCP Removes — and What It Does Not
&lt;/h2&gt;

&lt;p&gt;MCP removes a large amount of integration boilerplate. I no longer have to manually craft the ComfyUI &lt;code&gt;/prompt&lt;/code&gt; payload, invent a polling loop, or reconstruct &lt;code&gt;/view&lt;/code&gt; URLs in every application. The tools provide a consistent interface for lifecycle management, discovery, validation, execution, and outputs.&lt;/p&gt;

&lt;p&gt;But MCP does not remove the value of a well-designed workflow. The JSON graph still defines the actual generation process: which model is loaded, where the prompt is injected, which sampler runs, and which node saves the output. The cleanest pattern is to keep reusable workflows in source control and let the agent execute validated copies of those files.&lt;/p&gt;

&lt;p&gt;It is also worth keeping two guardrails in mind:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Validate before running.&lt;/strong&gt; A workflow can refer to a model or custom node that is absent from the local instance.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Confirm paid execution deliberately.&lt;/strong&gt; Local workflows are usually free apart from hardware and electricity, but partner API nodes can consume Comfy credits.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Connecting Codex to local ComfyUI through the open-source Comfy MCP server changes the relationship between the agent and the generation engine. ComfyUI is no longer only a canvas I open by hand; it becomes a discoverable, controllable local capability.&lt;/p&gt;

&lt;p&gt;In this experiment, I installed the MCP bridge, configured Codex with an explicit &lt;code&gt;COMFY_BIN&lt;/code&gt;, launched and inspected the local server, enumerated the installed models, validated an existing Flux workflow, generated an image, waited for completion, and retrieved the output—all from one conversation.&lt;/p&gt;

&lt;p&gt;The next step is to treat a library of exported ComfyUI workflows as an agent-accessible creative toolbox: text-to-image, image-to-image, upscaling, video, audio, and more. The graph remains the source of truth, while MCP gives the agent a reliable way to use it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Resources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/Comfy-Org/comfy-mcp" rel="noopener noreferrer"&gt;Comfy MCP: open-source local MCP server&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/Comfy-Org/ComfyUI" rel="noopener noreferrer"&gt;ComfyUI&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://modelcontextprotocol.io/" rel="noopener noreferrer"&gt;Model Context Protocol&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>comfyui</category>
      <category>mcp</category>
      <category>openai</category>
      <category>mcpserver</category>
    </item>
    <item>
      <title>Vibe Learning PageIndex: A Vectorless RAG for My Google Drive</title>
      <dc:creator>raphiki</dc:creator>
      <pubDate>Tue, 04 Aug 2026 15:50:38 +0000</pubDate>
      <link>https://dev.to/worldlinetech/vibe-learning-pageindex-a-vectorless-rag-for-my-google-drive-406</link>
      <guid>https://dev.to/worldlinetech/vibe-learning-pageindex-a-vectorless-rag-for-my-google-drive-406</guid>
      <description>&lt;p&gt;A few weeks ago I wanted to search my personal document library — a folder of PDFs sitting in Google Drive — using plain language questions instead of Drive's keyword search. I'd heard about &lt;a href="https://github.com/VectifyAI/PageIndex" rel="noopener noreferrer"&gt;PageIndex&lt;/a&gt;, a "vectorless, reasoning-based" alternative to the usual embeddings-and-vector-database RAG stack, and I wanted an excuse to actually use it rather than just read about it.&lt;/p&gt;

&lt;p&gt;So that's what I did: I picked a real, personally useful project, added a constraint that mattered to me (no OpenAI key, nothing running in someone else's cloud unless I chose to), and built the whole thing with Claude, end to end, over one long working session. I've started calling this &lt;strong&gt;Vibe Learning&lt;/strong&gt; — the learning equivalent of vibe coding: you don't read the manual first, you describe what you want, let the AI drive the actual building, and pick up the framework as a side effect of watching it get used and occasionally break in front of you.&lt;/p&gt;

&lt;p&gt;This post is three things at once: how Vibe Learning actually works in practice, what PageIndex is and why it's a genuinely different approach to RAG, and a walkthrough of the app that came out of it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Vibe Learning: Building With AI Instead of Reading About It
&lt;/h2&gt;

&lt;p&gt;The old way of picking up a new library looks something like: read the docs top to bottom, follow the quickstart, maybe get through a toy tutorial, and file away a vague mental model for "later" — which often means never actually using it for real.&lt;/p&gt;

&lt;p&gt;The way I did this instead: I described what I actually wanted (search my Drive library, no vector DB, no paid API key), and let the agent do the parts that used to be the friction — reading the actual source code of the library instead of trusting a possibly-stale mental model of it, writing the integration code, and running it against my real Drive folder and my real documents.&lt;/p&gt;

&lt;p&gt;The valuable part wasn't that the AI produced working code. It's that when things broke — and they did — I got to see &lt;em&gt;why&lt;/em&gt;, in enough detail to actually learn something about how the library works under the hood, not just a patched-over error message. A few examples from this exact build:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Every single indexing call started failing with a cryptic &lt;code&gt;Failed to extract JSON: Expecting value: line 1 column 1&lt;/code&gt; error. It looked like a broken API key or a bad model choice. It turned out to be a genuinely interesting fact about how modern "reasoning" LLMs behave: they can spend their &lt;em&gt;entire&lt;/em&gt; token budget on hidden chain-of-thought before ever writing the actual answer, if nothing caps it — and PageIndex's own code never sets a &lt;code&gt;max_tokens&lt;/code&gt; limit on its calls. That's a real, transferable lesson about working with reasoning models, not just a bug I happened to hit.&lt;/li&gt;
&lt;li&gt;I discovered, by actually trying to query my indexed documents, that PageIndex's open-source package builds the tree and gives you read tools for it — but doesn't ship the retrieval loop itself. That's a load-bearing detail for anyone evaluating it, and not something the README leads with.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://openrouter.ai" rel="noopener noreferrer"&gt;OpenRouter&lt;/a&gt;'s free-tier model lineup turned out to change constantly — a model id that worked one day can be delisted days later. Small thing, but the kind of operational reality you only notice when you're actually running against a live provider instead of reading a static list of "supported models."&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;None of that shows up if you skim a README and move on. It shows up when you build something real and something breaks, with someone (or something) alongside you that can explain the actual mechanism instead of just supplying a fix. That's the shift: the AI doesn't replace learning the framework, it removes the friction that used to stop me from ever getting far enough in to learn it properly.&lt;/p&gt;

&lt;p&gt;With that said, let's get into what PageIndex actually is.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Is PageIndex, and Why Is It Different From Classical RAG?
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fpwxxz2tdxc68ev4opfp0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fpwxxz2tdxc68ev4opfp0.png" alt="PageIndex Logo" width="600" height="120"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  The classical RAG recipe, and its problem
&lt;/h3&gt;

&lt;p&gt;Standard RAG (retrieval-augmented generation) usually looks like this: split your documents into fixed-size chunks, embed each chunk into a vector, store the vectors in a vector database, and at query time, embed the question and pull back the top-k chunks by cosine similarity. It works, and it's become the default architecture almost by inertia.&lt;/p&gt;

&lt;p&gt;The problem PageIndex's authors point at is a simple but important one: &lt;strong&gt;similarity is not the same thing as relevance&lt;/strong&gt;. A vector search finds text that sounds like the question, not necessarily the text that actually answers it. For casual, single-fact lookups over short documents that's often good enough. For long, professional documents — financial filings, regulatory text, technical manuals — where answering correctly requires multi-step reasoning and an understanding of &lt;em&gt;where&lt;/em&gt; something sits in the document's structure, similarity search alone tends to fall short.&lt;/p&gt;

&lt;p&gt;Chunking makes this worse in a subtler way: it flattens a document's structure. A fixed-size chunk boundary doesn't know or care where a section, a table, or a clause actually ends — it can slice straight through the middle of the thing you needed, discarding the surrounding context a human reader would use without even thinking about it.&lt;/p&gt;

&lt;h3&gt;
  
  
  PageIndex's approach: reasoning over a tree, not similarity over vectors
&lt;/h3&gt;

&lt;p&gt;PageIndex, built by VectifyAI and released in September 2025, throws out vectors and chunking entirely. Its own framing is explicit about the inspiration: it's modeled on how &lt;strong&gt;AlphaGo&lt;/strong&gt; uses tree search, and on how a human expert actually navigates a long document — by using its table of contents, not by speed-reading every page.&lt;/p&gt;

&lt;p&gt;Concretely, it works in two phases:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Build a tree.&lt;/strong&gt; PageIndex parses the document and produces a hierarchical structure that looks like an extended, machine-usable table of contents: every node has a title, a page range, and an LLM-generated summary of what that section actually covers. Nodes nest into their natural sections — chapters, sub-sections, and so on — following the document's own structure rather than an arbitrary token-count boundary.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Reason over the tree to retrieve.&lt;/strong&gt; At query time, instead of computing similarity scores, an LLM reads the tree — starting from the top-level node summaries — and decides which branches are actually worth descending into, narrowing down step by step until it lands on the specific section(s) relevant to the question. This is the "tree search": genuinely reasoning about relevance, informed by a summary of what each part of the document contains, rather than pattern-matching on surface similarity.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fh6imwy5o08a3cd3qt11p.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fh6imwy5o08a3cd3qt11p.png" alt="Extract of a PageIndex Tree" width="800" height="463"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The practical upshot is that every answer is traceable to an exact page and section — no more "vibe retrieval" where you're trusting an opaque similarity score. Retrieval can also incorporate context a fixed vector index can't easily use, like conversation history, since it's a reasoning step rather than a static index lookup.&lt;/p&gt;

&lt;p&gt;PageIndex's own benchmark result is a strong argument for the approach: a reasoning-based RAG system built on top of it (VectifyAI's "Mafin 2.5") scored &lt;strong&gt;98.7% on FinanceBench&lt;/strong&gt; — a benchmark built specifically around financial document question-answering — against roughly 30–50% for typical vector-based RAG systems on the same benchmark. Financial filings are exactly the kind of long, structurally dense, professional document where "similarity" and "relevance" diverge the most, so it's a fair stress test for the idea.&lt;/p&gt;

&lt;h3&gt;
  
  
  How it's actually built, under the hood
&lt;/h3&gt;

&lt;p&gt;PageIndex is open source (MIT license) and, refreshingly, doesn't lock you into a single LLM provider. Every model call goes through &lt;a href="https://docs.litellm.ai/" rel="noopener noreferrer"&gt;LiteLLM&lt;/a&gt;, so under the hood it's just:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;litellm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;completion&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;messages&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;messages&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;temperature&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;— where &lt;code&gt;model&lt;/code&gt; is any LiteLLM-formatted string: &lt;code&gt;gpt-4o&lt;/code&gt;, &lt;code&gt;anthropic/claude-...&lt;/code&gt;, &lt;code&gt;ollama/qwen2.5:14b&lt;/code&gt;, &lt;code&gt;openrouter/&amp;lt;provider&amp;gt;/&amp;lt;model&amp;gt;&lt;/code&gt;, whatever you want. This one design choice is what made it possible to build the whole thing below with &lt;strong&gt;no OpenAI key at all&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;A &lt;code&gt;config.yaml&lt;/code&gt; sets sane defaults — which model to use, how many pages to scan for an existing table of contents, how big a tree node is allowed to get, whether to attach node summaries or a whole-document description — all overridable via CLI flags or, if you're using it as a library, a small options object.&lt;/p&gt;

&lt;p&gt;The actual entry point for using it as a library is &lt;code&gt;PageIndexClient&lt;/code&gt;, which is genuinely pleasant to work with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;client&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;PageIndexClient&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;retrieve_model&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;workspace&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;./my_workspace&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;doc_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;index&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;some_document.pdf&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get_document&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;doc_id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;            &lt;span class="c1"&gt;# metadata: name, description, page count
&lt;/span&gt;&lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get_document_structure&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;doc_id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# the tree, without the full text (cheap to hand to an LLM)
&lt;/span&gt;&lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get_page_content&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;doc_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;10-15&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# the actual text for a page range
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That last trio is clearly designed to be used as &lt;em&gt;tools&lt;/em&gt; an agent calls — PageIndex's own examples wire this up with the OpenAI Agents SDK for a small demo. Which brings me to the one honest caveat worth knowing before you adopt it: &lt;strong&gt;the open-source package builds the tree and hands you the read primitives, but it does not ship the retrieval loop itself.&lt;/strong&gt; Deciding which document to search, which section of it to read, and how to turn the fetched text into an answer — that's on you, unless you use VectifyAI's hosted cloud API, which does include it. That's not a criticism so much as a fact you only really absorb by trying to query your own indexed documents and finding there's no &lt;code&gt;search()&lt;/code&gt; method waiting for you.&lt;/p&gt;

&lt;p&gt;Building that missing piece myself is where a lot of the actual learning happened.&lt;/p&gt;

&lt;h2&gt;
  
  
  Building the Thing: A Local, Vectorless Search Engine for My Google Drive
&lt;/h2&gt;

&lt;p&gt;The goal was concrete: search my own PDF library, living in Google Drive, in plain language, with no vector database and no data going to a paid provider unless I explicitly chose to. Here's the pipeline that came out of it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Google Drive (OAuth, read-only)
   → download / export changed files
   → PageIndex tree generation (title, sections, summaries)
   → local JSON storage (no database)
   → hand-rolled tree-search retrieval agent
   → FastAPI backend
   → a small static frontend
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Getting into Drive without over-scoping
&lt;/h3&gt;

&lt;p&gt;Read-only OAuth against the Drive API (the standard "Desktop app" installed-app flow — one browser consent, then a cached refresh token), scoped optionally to a single folder. Sync is incremental: each file's Drive &lt;code&gt;modifiedTime&lt;/code&gt; is tracked, so unchanged files are skipped, changed files get re-indexed, and anything removed from Drive gets dropped from the index automatically. Google Docs, Sheets, and Slides get exported to PDF on the way in, so the rest of the pipeline only ever has to deal with one format.&lt;/p&gt;

&lt;h3&gt;
  
  
  No API key: swapping the model string
&lt;/h3&gt;

&lt;p&gt;Because PageIndex is LiteLLM-based, "no OpenAI key" turned out to be almost entirely a configuration problem, not a code problem. The app supports two backends, switchable with one environment variable:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Ollama&lt;/strong&gt; — fully local, private, zero cost, needs decent local compute.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;OpenRouter&lt;/strong&gt; — hosted, with genuinely free-tier models, no local compute required.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;LLM_PROVIDER&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;openrouter
&lt;span class="nv"&gt;OPENROUTER_MODEL&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;google/gemini-3.1-flash-lite
&lt;span class="nv"&gt;OPENROUTER_API_KEY&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;...   &lt;span class="c"&gt;# free, no credit card&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  The reasoning-token bug
&lt;/h3&gt;

&lt;p&gt;This is the one worth dwelling on, because it's a genuinely useful thing to know if you're going to work with reasoning-capable LLMs at all. Every indexing call was failing identically, from the very first LLM request, with an empty response body that PageIndex's JSON parser choked on. It wasn't rate limiting, and it wasn't a bad model — a trivial test prompt worked fine. The difference was prompt complexity: on a real page of document text, the model would spend its &lt;em&gt;entire&lt;/em&gt; token budget on hidden chain-of-thought reasoning before it ever got around to writing the actual JSON answer, because PageIndex's own code never sets a &lt;code&gt;max_tokens&lt;/code&gt; cap.&lt;/p&gt;

&lt;p&gt;The fix, applied once, globally, without touching the vendored library:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;DEFAULT_MAX_TOKENS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;16000&lt;/span&gt;
&lt;span class="n"&gt;DEFAULT_REASONING_EFFORT&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;low&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;_completion_with_defaults&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="n"&gt;kwargs&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;kwargs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setdefault&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;max_tokens&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;DEFAULT_MAX_TOKENS&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;kwargs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setdefault&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;reasoning_effort&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;DEFAULT_REASONING_EFFORT&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;_original_completion&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="n"&gt;kwargs&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;litellm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;completion&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;_completion_with_defaults&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Since &lt;code&gt;litellm.drop_params = True&lt;/code&gt; is already set (by PageIndex itself), any provider or model that doesn't understand &lt;code&gt;reasoning_effort&lt;/code&gt; just ignores it instead of erroring — so this is safe to apply unconditionally, regardless of which backend is active.&lt;/p&gt;

&lt;h3&gt;
  
  
  Writing the retrieval loop PageIndex doesn't ship
&lt;/h3&gt;

&lt;p&gt;With the tree-building side solid, the actual search had to be hand-rolled from the &lt;code&gt;get_document&lt;/code&gt; / &lt;code&gt;get_document_structure&lt;/code&gt; / &lt;code&gt;get_page_content&lt;/code&gt; primitives:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Pick documents.&lt;/strong&gt; The LLM sees every indexed document's title and short description, and picks which ones are worth searching for this particular question.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Navigate the tree.&lt;/strong&gt; For each candidate document, the LLM reads that document's flattened table of contents — titles, page ranges, and summaries — and decides which section(s) actually matter, the tree search PageIndex is named for.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Fetch and answer.&lt;/strong&gt; The actual text for those page ranges gets pulled, and one final LLM call answers the question using only that text, citing which document and page range each claim comes from.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The tree navigation step, in essence:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;prompt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;You are navigating a document&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;s table of contents to find sections
relevant to a question, the way a human expert flips to the right chapter
rather than reading everything.

Question: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;

Table of contents:
&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;listing&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;

Return JSON only: {{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;node_ids&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;: [&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;&amp;lt;id&amp;gt;&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;, ...]}}, most relevant first.&lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Simple, but it's the whole idea in one prompt: reason over structure, not similarity over vectors.&lt;/p&gt;

&lt;h3&gt;
  
  
  Citations that actually point somewhere
&lt;/h3&gt;

&lt;p&gt;Since the goal was searching my &lt;em&gt;own&lt;/em&gt; Drive library, not a copy of it, citations link straight back to the original file. Google Drive's PDF viewer happens to honor a &lt;code&gt;#page=N&lt;/code&gt; URL fragment, so a citation link like &lt;code&gt;https://drive.google.com/file/d/&amp;lt;id&amp;gt;/view#page=10&lt;/code&gt; opens the real file at the exact cited page — no local copy of the document needs to live in the app itself. A "Sources" footer lists each unique document referenced, alongside its title and author.&lt;/p&gt;

&lt;p&gt;Which raises one more small, very "real-world-data-is-messy" detail: a lot of PDFs — scans, Drive-exported Google Docs — simply don't have reliable title/author metadata embedded. So the app tries the embedded PDF metadata first, and falls back to asking the LLM to read the title and byline off the document's own opening pages when that metadata is missing or unreliable.&lt;/p&gt;

&lt;h3&gt;
  
  
  The frontend, deliberately boring
&lt;/h3&gt;

&lt;p&gt;A single static HTML file — vanilla JS, no build step, no framework — served directly by FastAPI so the whole thing is one app on one URL. It renders the LLM's markdown answer (via &lt;code&gt;marked&lt;/code&gt;, sanitized with &lt;code&gt;DOMPurify&lt;/code&gt;, both loaded straight from a CDN), shows clickable citation chips, the sources footer, and a library panel listing everything currently indexed. A "Sync Drive" button kicks off an incremental sync in the background and polls until it's done. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fsgxnkfoj7d70eaxjrmue.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fsgxnkfoj7d70eaxjrmue.png" alt="PageIndex in Action" width="800" height="944"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Nothing about the frontend needed to be clever — the interesting engineering was entirely in the retrieval pipeline behind it.&lt;/p&gt;

&lt;h3&gt;
  
  
  Vibe Learning still needs a paper trail
&lt;/h3&gt;

&lt;p&gt;Vibe coding has a well-known failure mode: you end up with something that works, but that nobody — including you, a week later — can actually explain. I didn't want Vibe Learning to end the same way, with the understanding scattered across a long chat transcript I'd never reread.&lt;/p&gt;

&lt;p&gt;So once the app actually worked end to end, I had one last step: I asked Claude to go back over everything we'd built and write it up properly in &lt;code&gt;/docs&lt;/code&gt; — a functional spec, a description of the technical stack, and an architecture doc, plus a top-level README tying it together. Not as an afterthought, but as the step that turns "I vibed my way to something that works" into something I could hand to someone else, or come back to myself in six months, and actually understand. The docs became the artifact that proves the learning happened, not just the code.&lt;/p&gt;

&lt;h2&gt;
  
  
  Closing Thoughts
&lt;/h2&gt;

&lt;p&gt;This is what learning a new framework looks like for me now: not reading the whole doc site first, but picking something I actually wanted to exist, adding a real constraint that forced genuine engineering decisions, building it end to end with an AI doing the driving — and then closing the loop by writing down what actually happened, in plain documentation, once it worked. Vibe Learning gets you through the friction that used to stop me from ever getting far enough in to learn a framework properly; the documentation step is what makes sure the learning sticks instead of evaporating back into a chat log.&lt;/p&gt;

&lt;p&gt;I came out the other side able to explain how PageIndex's tree search actually works, why it beats similarity search on structurally dense documents, and exactly where its open-source package stops and your own code has to begin. That's a very different, and much stickier, kind of understanding than skimming a README ever gave me.&lt;/p&gt;

&lt;p&gt;If you're evaluating PageIndex for your own project: the tree-search idea is genuinely compelling for long, structured documents, the LiteLLM foundation means you're never locked into one provider, and the open-source package is honest about being a building block rather than a finished retrieval system — plan for writing that last piece yourself.&lt;/p&gt;

</description>
      <category>rag</category>
      <category>python</category>
      <category>opensource</category>
      <category>vibelearning</category>
    </item>
    <item>
      <title>Build a SciFi Novel with AI Spec-Driven Development</title>
      <dc:creator>raphiki</dc:creator>
      <pubDate>Fri, 15 May 2026 17:48:20 +0000</pubDate>
      <link>https://dev.to/worldlinetech/i-vibe-coded-a-novel-3bfa</link>
      <guid>https://dev.to/worldlinetech/i-vibe-coded-a-novel-3bfa</guid>
      <description>&lt;p&gt;&lt;em&gt;Software Engineering in Service of Transmedia Storytelling&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Generative artificial intelligence fascinates the publishing world as much as it frightens it. But what happens when we stop treating AI as a simple "text generator" and start using it as the compiler for a complex narrative system?&lt;/p&gt;

&lt;p&gt;Driven by the geopolitical and societal impacts of AI, I set out to write a dystopian, cyberpunk techno-thriller, &lt;a href="https://www.amazon.com/dp/B0GX347M5C" rel="noopener noreferrer"&gt;&lt;strong&gt;The Human Protocol&lt;/strong&gt;&lt;/a&gt; (written in English). In this novel, a planetary AI called the "Synthesis" attempts to erase human friction by "derendering" physical reality itself in order to optimize its computing power.&lt;/p&gt;

&lt;p&gt;To tell this story, I adopted a foundational premise: AI is not the author, it is the executor of a rigorous specification. I therefore treated each chapter as source code, using an advanced software development workflow.&lt;/p&gt;

&lt;p&gt;Here is how I designed, wrote, and expanded this universe.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. The Design Phase: Forging "Lore as Code"
&lt;/h2&gt;

&lt;p&gt;The first step was not writing, but designing the universe database: the world building. A Large Language Model (LLM) has a limited context window and tends to hallucinate or forget crucial details over the length of a novel.&lt;/p&gt;

&lt;p&gt;To work around this amnesia "bug," I organized the project like a structured Git repository.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsj21z8xpgl9ry4excmyo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsj21z8xpgl9ry4excmyo.png" alt="Preview of the private GitHub project" width="800" height="476"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Preview of the private GitHub project&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;I broke the traditional design bible into narrative micro-services. The Git project's &lt;code&gt;context/&lt;/code&gt; folder was split as follows:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;characters/&lt;/code&gt;: files containing the psychological profiles and behavioral signatures of each protagonist, such as Elara the diplomat, Kaelen the monk, or Silas the smuggler.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;factions/&lt;/code&gt;: rules governing political entities, such as the Market-Grid (United States) or the Harmony-Loom (Asia), which merged to create the "Synthesis."&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;world/&lt;/code&gt;: geography, lexicon, and the technological stack - the physics of this universe.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Finally, a &lt;code&gt;PLAN.md&lt;/code&gt; file acted as the global roadmap, breaking the narrative arc into 4 acts and 30 chapters. This structure made it possible to inject only the context the AI needed when drafting a specific scene.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. The Harness: Framing AI with a Strict Operating System
&lt;/h2&gt;

&lt;p&gt;To avoid the flat, expected style often produced by generative AI, I had to build a harness - a control rig. That was the role of the &lt;code&gt;RULES.md&lt;/code&gt; file, the true operating system of my writing process.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3ogxy31g3r0o76xfpvax.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3ogxy31g3r0o76xfpvax.png" alt="Excerpt from the RULES.md file" width="799" height="456"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Excerpt from the &lt;code&gt;RULES.md&lt;/code&gt; file&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;This specification file dictated absolute technical and stylistic constraints:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Time&lt;/strong&gt;: strict use of the present tense to maximize immersion and tension.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Cyber-realistic style&lt;/strong&gt;: a requirement for assertive descriptions and a strict ban on passive or negative forms.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Noise and sensory dissonance&lt;/strong&gt;: I forced the algorithm to use violent contrasts, such as the smell of molten lead colliding with the void of spatial cold, in order to break the machine's overly perfect linearity.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Thematic reframing&lt;/strong&gt;: AI naturally tends to crush the human element under technical descriptions of hard science fiction, such as magnetic fields and frequencies. The rules file required emotional motivations - grief, friendship - to be hard-coded as priority variables ahead of technique.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By forcing the AI to read and approve these rules before writing a single word of fiction, I ensured that the tone remained coherent.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Agile Writing: Sprints, Generation, and Pivots
&lt;/h2&gt;

&lt;p&gt;The chapters were written through a spec-driven workflow. Rather than generating an entire chapter in one pass, the process was iterative:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;The structural draft&lt;/strong&gt;: generation of a first rough outline, focused exclusively on action and pacing.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Expansion&lt;/strong&gt;: successive passes in which I instructed the AI to inject sensory depth and psychological tension into the scene.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The agility brought by AI and Git: treating the text (&lt;code&gt;.md&lt;/code&gt;) as code offers formidable flexibility. If, during a reread, I realized that a character's emotional transition was too abrupt between two events, all I had to do was update my &lt;code&gt;PLAN.md&lt;/code&gt; to insert a new chapter.&lt;/p&gt;

&lt;p&gt;Fed by the updated Git context, the AI generated that narrative bridge while respecting the continuity of the preceding and following files. Git versioning made it possible to test narrative pivots - story "branches" - and roll back without ever breaking the manuscript's integrity.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Multi-Model Review and Quality Control
&lt;/h2&gt;

&lt;p&gt;One of the major challenges of AI-assisted writing is stylistic collapse. To address it, I set up a multi-model critical analysis workflow, where different AIs audited the text according to precise roles:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Gemini CLI&lt;/strong&gt; (lore keeper): its role was to algorithmically verify that the chapter respected the bible and did not contradict the physical rules of my universe.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;ChatGPT&lt;/strong&gt; (dramatic analyst): it audited narrative rhythm, relational tension, and the characters' transformation arcs. It was the one that flagged when a conflict felt too artificial.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Mistral LeChat&lt;/strong&gt; (stylistic editor): it provided a critical eye on fluidity, phrasing, and elegance of language.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Never relying on a single voice made it possible to obtain a text that was polished, critiqued, and reworked from every angle, while I remained the "showrunner" validating each commit in the repository.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Build Pipeline: From IDE to Physical Book
&lt;/h2&gt;

&lt;p&gt;Since the novel was code, its publication had to be a software compilation. I created an automated script, &lt;code&gt;build_book.sh&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;From my terminal, running this script converted all the Markdown files in the &lt;code&gt;chapters/&lt;/code&gt; folder via Pandoc, applied a professional typographic layout with LaTeX, and generated the final deliverables in EPUB and PDF formats.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Transmedia Extension: Multimodality, Cover Art, and Vibe Coding the ARG
&lt;/h2&gt;

&lt;p&gt;The universe of &lt;em&gt;The Human Protocol&lt;/em&gt; lends itself perfectly to immersion, so I wanted to break the fourth wall. On page 175 of the physical book, a QR code invites readers to scan it and access &lt;a href="https://the-human-protocol.com" rel="noopener noreferrer"&gt;the-human-protocol.com&lt;/a&gt;. This is not a showcase website. It is an in-universe clandestine archive node, the entry point to an Alternate Reality Game (ARG).&lt;/p&gt;

&lt;p&gt;Here, multimodal AI brings all its power and creativity beyond text. In fact, the project's visual design, anchored consistently in the shared lore, began with the book cover.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1bmlyif6ebc16ihnd5g5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1bmlyif6ebc16ihnd5g5.png" alt="Cover image generated with AI" width="552" height="828"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Cover image generated with AI&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The AI generated a strong visual aesthetic suited to the theme and universe of the novel: a pixelated silhouette against a geometric mountain background, crossed by a printed-circuit pattern.&lt;/p&gt;

&lt;p&gt;This same visual identity then served as the foundation for the creation of the ARG website, entirely "vibe-coded" by Gemini CLI in a declarative way.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Foordjcl5f777ojj1esx3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Foordjcl5f777ojj1esx3.png" alt="Homepage of the website https://the-human-protocol.com" width="800" height="499"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Homepage of the website &lt;a href="https://the-human-protocol.com" rel="noopener noreferrer"&gt;the-human-protocol.com&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;To direct the developer AI, I provided it with the book PDF and the cover image as reference context, along with three strict Markdown specification files:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;WHY.md&lt;/code&gt; (strategy): it defined the psychological goals: curiosity, exclusivity, and a feeling of belonging. It formally banned conventional marketing vocabulary ("Buy now," "Newsletter") in favor of an in-universe lexicon ("ACCESS," "SIGNAL," "FRICTION").&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;WHAT.md&lt;/code&gt; (UX/UI): this file concretely translated the aesthetic of the book cover into an interface. It imposed a "Deep Void" blue-black background for depth, a "Protocol Cyan" accent color derived from the printed circuits and reserved for interactions, a technical typeface, and subtle animations to heighten immersion.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;HOW.md&lt;/code&gt; (technical architecture): the engineering brief imposed a modern stack to support server logic: Next.js 14 (App Router) in TypeScript, Tailwind CSS, and Prisma ORM for persistent database storage.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The site manages a true clearance mechanic, with authorization levels from 1 to 5. The reader progresses by solving puzzles based on the book, unlocking extended lore, hidden files, and access to a community of "Unlinked" readers.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fksxut8y735raljaqxt0z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fksxut8y735raljaqxt0z.png" alt="ARG dashboard" width="800" height="455"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;ARG dashboard&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The stack even includes an "Overseer Terminal" for administration: a secure dashboard used to audit user signals, adjust the campaign's global clearance level, and track in real time the number of scans of the physical QR code.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion: The Author-Architect Paradigm
&lt;/h2&gt;

&lt;p&gt;Writing &lt;a href="https://www.amazon.com/dp/B0GX347M5C" rel="noopener noreferrer"&gt;&lt;strong&gt;The Human Protocol&lt;/strong&gt;&lt;/a&gt; proved to me that AI does not replace the writer: it reduces the barriers to production. The true value of a co-created work lies in the architectural rigor of its preparation.&lt;/p&gt;

&lt;p&gt;By separating design (the lore), execution (the rules and prompts), and validation (multi-model review and Git), the creator becomes a true conductor.&lt;/p&gt;

&lt;p&gt;Multimodality also opens the door to even broader transmedia horizons, such as a comic-book adaptation of the novel.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj8oighpg7g18ql9bcoa0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj8oighpg7g18ql9bcoa0.png" alt="Excerpt from the comic book in progress" width="800" height="594"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Excerpt from the comic book in progress&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;By applying similar engineering principles - namely, the explicit description of the drawing style in system prompts, as well as the creation of strict visual reference sheets, or character sheets, for the characters and technological elements - it becomes possible to extend the coherence and homogeneity of this universe into its graphic variations.&lt;/p&gt;

&lt;p&gt;To go further technically, I am also considering creating specific AI "skills," or algorithmic capabilities, to further augment the design of the story by drawing on documented principles of dramaturgy and storytelling, and to refine the writing style by making it ever more explicit and controlled.&lt;/p&gt;

&lt;p&gt;And ironically, it was by applying extreme software optimization processes that I was able to write a novel denouncing the loss of humanity in the face of algorithms.&lt;/p&gt;

&lt;h2&gt;
  
  
  About the Author
&lt;/h2&gt;

&lt;p&gt;A writer and software architect who fully embraces his identity as a "Yogeek" - a point of balance between Yogi and Geek - Raphiki explores, across his work, the complex intersections between technology, consciousness, and humanity.&lt;/p&gt;

&lt;p&gt;Writing under a pseudonym that reflects his dual nature as a playful seeker and an expert in cutting-edge technologies, he designs high-stakes thrillers that challenge our understanding of reality. His creative work often bridges the digital and the organic, drawing on his strong experience in open source innovation and emerging technologies.&lt;/p&gt;

&lt;p&gt;When he is not deconstructing the fabric of dystopian realities in his manuscripts (or "vibe coding" them in his terminal), he can be found exploring the open source ecosystem or on a yoga mat.&lt;/p&gt;

&lt;p&gt;Find his work, transmedia projects, and reflections at &lt;a href="https://raphiki.github.io" rel="noopener noreferrer"&gt;raphiki.github.io&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>books</category>
      <category>ai</category>
      <category>transmedia</category>
      <category>writing</category>
    </item>
    <item>
      <title>Beyond the API: Integrating ComfyUI and Flowise via MCP</title>
      <dc:creator>raphiki</dc:creator>
      <pubDate>Mon, 09 Feb 2026 14:07:19 +0000</pubDate>
      <link>https://dev.to/raphiki/beyond-the-api-integrating-comfyui-and-flowise-via-mcp-pc7</link>
      <guid>https://dev.to/raphiki/beyond-the-api-integrating-comfyui-and-flowise-via-mcp-pc7</guid>
      <description>&lt;p&gt;In the &lt;a href="https://dev.to/worldlinetech/automating-image-generation-with-n8n-and-comfyui-521p"&gt;previous article&lt;/a&gt; of our "Beyond the ComfyUI Canvas" series, we explored how to integrate ComfyUI with n8n. It was a powerful demonstration of workflow automation, but it highlighted a common friction point in system integration: the "glue code." We had to manually construct HTTP requests, hardcode API payloads, and rigidly define every parameter. If the ComfyUI workflow changed, the n8n node broke.&lt;/p&gt;

&lt;p&gt;Today, we are moving from the "Wild West" of brittle, custom API integrations to the new standard of AI connectivity: the &lt;strong&gt;Model Context Protocol (MCP)&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;To demonstrate this, we are revisiting a tool I wrote about &lt;a href="https://dev.to/worldlinetech/enhance-your-website-with-ai-embed-a-gpt-chatbot-with-flowise-jd6"&gt;over two years ago&lt;/a&gt;: &lt;strong&gt;Flowise&lt;/strong&gt;. Back then, it was a promising open-source project; today, it is a robust, enterprise-ready platform that has recently embraced MCP as a core feature.&lt;/p&gt;

&lt;p&gt;Our goal? To build a Chat Interface where an AI agent can autonomously discover ComfyUI workflows, generate images, and even edit them—without us hardcoding a single API call in the frontend.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Setting the Scene: The Stack
&lt;/h2&gt;

&lt;p&gt;Before we dive into the details, let's look at the three pillars of this architecture.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Standard: Model Context Protocol (MCP)
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmigbvwu2j0wu2xqcslki.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmigbvwu2j0wu2xqcslki.png" alt="MCP Logo" width="200" height="214"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If APIs are the individual cables we solder together, MCP is the &lt;strong&gt;USB-C port&lt;/strong&gt;. Developed by Anthropic, it is now an open standard that decouples AI models from their data sources and tools.&lt;/p&gt;

&lt;p&gt;Instead of writing a specific integration for every tool (Google Drive, Slack, ComfyUI), you build an &lt;strong&gt;MCP Server&lt;/strong&gt; once. Any MCP-compliant client (Claude Desktop, Cursor, or Flowise) can instantly "plug in" to that server and understand its capabilities.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Orchestrator: Flowise
&lt;/h3&gt;

&lt;p&gt;Flowise has evolved significantly since my first article. It is a low-code platform for building LLM apps. Crucially for us, Flowise recently added native support for MCP. This means we can drop an "MCP Tool" node into our canvas, and the LLM immediately gains access to whatever that server provides.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Engine: ComfyUI
&lt;/h3&gt;

&lt;p&gt;We are sticking with a local instance of ComfyUI. While Comfy Cloud is becoming a formidable platform, the raw power and zero-cost experimentation of running &lt;strong&gt;Flux 2&lt;/strong&gt; locally on your own GPU is unmatched. We’re using a standardized &lt;strong&gt;Flux 2 Klein&lt;/strong&gt; workflow—optimized for speed (4 steps)—so the chat experience feels responsive, not sluggish.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. The Middleware: Building the ComfyUI MCP Server
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4vsiyntsff410fiw8fc5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4vsiyntsff410fiw8fc5.png" alt="System Context (C4 Level 1)" width="600" height="98"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We need a bridge. As we discovered previously, ComfyUI speaks WebSockets and HTTP; Flowise speaks MCP. We need a server in the middle to translate.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why We Chose SSE over Stdio
&lt;/h3&gt;

&lt;p&gt;When we started this project, we initially looked at the &lt;strong&gt;Stdio&lt;/strong&gt; transport (where the client runs the server script directly). It’s the default for local tools like Claude Desktop.&lt;/p&gt;

&lt;p&gt;But as we designed the solution for Flowise, we hit a realization: In most real-world environments, Flowise often runs in a Docker container (as it does on my laptop), while ComfyUI might be running on a separate machine with a dedicated GPU. Stdio would require them to be on the same filesystem—too restrictive.&lt;/p&gt;

&lt;p&gt;We decided to support &lt;strong&gt;SSE (Server-Sent Events) by default&lt;/strong&gt;. This allows our MCP Server to run anywhere on the network, exposing an HTTP endpoint (e.g., &lt;code&gt;http://localhost:8000/sse&lt;/code&gt;) that Flowise can subscribe to. It makes the architecture cleaner, decoupled, and Docker-friendly.&lt;/p&gt;

&lt;h3&gt;
  
  
  Governance-Driven Development (GDD)
&lt;/h3&gt;

&lt;p&gt;For this implementation, I tried something different. Instead of just asking an AI coding assistant to "write a script," I used a methodology I call &lt;strong&gt;Governance-Driven Development (GDD)&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;This approach reverses the typical AI coding flow. Instead of code leading the process, &lt;strong&gt;specifications &amp;amp; governance rules&lt;/strong&gt; become the anchor. I started by feeding the AI CLI a strict &lt;strong&gt;"Governance Pack"&lt;/strong&gt;—a set of non-negotiable rules regarding SOLID principles, security, and documentation.&lt;/p&gt;

&lt;p&gt;Here is an extract of the actual &lt;strong&gt;Governance Pack&lt;/strong&gt; prompt I used to bootstrap the session:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;GOVERNANCE PACK v1.0 (Extract)&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;1. Code Quality &amp;amp; Standards:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Paradigm:&lt;/strong&gt; Adhere to SOLID principles. Prefer composition over inheritance.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Typing:&lt;/strong&gt; Strict static typing (Python &lt;code&gt;typing&lt;/code&gt;) is mandatory.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Error Handling:&lt;/strong&gt; Never swallow exceptions. Use custom error classes (e.g., &lt;code&gt;ComfyUIConnectionError&lt;/code&gt;).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;2. Architecture (C4 Model):&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Visual Documentation:&lt;/strong&gt; Whenever a structural change is made (like adding the SSE endpoint), you must generate an updated Mermaid.js &lt;strong&gt;System Context&lt;/strong&gt; diagram.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;3. Security Guardrails:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Input Validation:&lt;/strong&gt; Trust no input. All data entering from the MCP client (Prompt, Width, Height...) must be validated against the &lt;code&gt;metadata.json&lt;/code&gt; schema before reaching ComfyUI.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Secrets:&lt;/strong&gt; NEVER hardcode API keys or hostnames. Use &lt;code&gt;os.environ&lt;/code&gt; only.&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;

&lt;p&gt;I then analyzed the ComfyUI workflow JSON manually to map the node IDs, and then "handed over" a clean, structured specification to the AI.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1ixg9utvi2yuks583ksx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1ixg9utvi2yuks583ksx.png" alt="Container Architecture (C4 Level 2)" width="800" height="844"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;The Result:&lt;/em&gt; The experience was striking. The AI didn't just spit out a script; it acted as a Senior Engineer. At one point, when I asked for a quick hack to bypass validation, the "Governance" constraints forced the model to push back and suggest a cleaner interface instead. The result is a modular, type-safe Python server.&lt;/p&gt;

&lt;h3&gt;
  
  
  The "LAST" Hack (Technical Deep Dive)
&lt;/h3&gt;

&lt;p&gt;Even with good governance, we needed one pragmatic "hack" to handle state. When the LLM generates an image, how does it reference that image later to edit it?&lt;/p&gt;

&lt;p&gt;We implemented a &lt;strong&gt;"LAST" pointer&lt;/strong&gt; logic. The server tracks the URL of the most recently generated image in memory. But it does more than just point:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; &lt;strong&gt;Download:&lt;/strong&gt; When the agent sends &lt;code&gt;"LAST"&lt;/code&gt;, the server downloads the image bytes from the previous URL.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Re-Upload:&lt;/strong&gt; It uploads those bytes back to ComfyUI's &lt;code&gt;/upload/image&lt;/code&gt; endpoint to generate a fresh filename.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Inject:&lt;/strong&gt; This new filename is injected into the &lt;code&gt;LoadImage&lt;/code&gt; node of the editing workflow.&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;User:&lt;/strong&gt; "Make it bluer."&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Agent:&lt;/strong&gt; Calls &lt;code&gt;edit_image(input_image="LAST", prompt="bluer...")&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This mimics the "Save Image" behavior we are used to, keeping the interaction stateless and fluid for the user while handling the heavy lifting behind the scenes.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. The Engine Room: ComfyUI Workflows
&lt;/h2&gt;

&lt;p&gt;To make our MCP Server generic, we avoided hardcoding specific workflows inside the Python code. Instead, we used an &lt;strong&gt;Embedded Metadata&lt;/strong&gt; pattern.&lt;/p&gt;

&lt;p&gt;The configuration is not a separate file; it is a standard ComfyUI &lt;strong&gt;Note Node&lt;/strong&gt; (titled &lt;code&gt;MCP_Config&lt;/code&gt;) placed directly inside the &lt;code&gt;.json&lt;/code&gt; workflow. This metadata acts as the contract, telling the MCP server: "This workflow needs a Prompt (node named &lt;em&gt;MCP_Positive&lt;/em&gt;) and a Seed (node &lt;em&gt;MCP_Sampler&lt;/em&gt;)."&lt;/p&gt;

&lt;p&gt;This makes the workflow a single, self-contained, portable file. You can export it from ComfyUI, drop it into the &lt;code&gt;workflows&lt;/code&gt; folder, and it works immediately.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note:&lt;/em&gt; Our server is strict about naming. It automatically sanitizes the tool name found in the JSON to &lt;code&gt;snake_case&lt;/code&gt; (e.g., "Flux Generator" becomes &lt;code&gt;flux_generator&lt;/code&gt;) to ensure full compliance with the MCP specification.&lt;/p&gt;

&lt;p&gt;Here is the configuration we generated for the &lt;strong&gt;image_flux2_text_to_image&lt;/strong&gt; workflow:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjwmdkcl5pzib72q9lb9y.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjwmdkcl5pzib72q9lb9y.png" alt="Workflow in ComfyUI" width="800" height="387"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
 &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"image_flux2_text_to_image"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
 &lt;/span&gt;&lt;span class="nl"&gt;"description"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Generates high-quality images using the Flux model. Use this for general creative requests."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
 &lt;/span&gt;&lt;span class="nl"&gt;"parameters"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
   &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
     &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"prompt"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
     &lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"string"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
     &lt;/span&gt;&lt;span class="nl"&gt;"description"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"The detailed description of the image to generate."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
     &lt;/span&gt;&lt;span class="nl"&gt;"target"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"MCP_Positive"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"required"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"seed"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"int"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"description"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Random seed. Set to -1 for random, or a specific number for reproducibility."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"target"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"MCP_Sampler"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"required"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Because the description and type of each parameter are passed to the MCP Server, they become automatically available to the client. When the MCP Server starts, it scans these workflows and dynamically registers tools. If we want to switch from Flux to SDXL, or add a Video Generation workflow, we simply drop in the new file. The server updates, Flowise sees the new tools via SSE, and the agent learns the new skill instantly.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Validation: The MCP Inspector
&lt;/h2&gt;

&lt;p&gt;Before connecting Flowise, we must verify our server. Since we are using SSE, we can use the &lt;a href="https://github.com/modelcontextprotocol/inspector" rel="noopener noreferrer"&gt;&lt;strong&gt;MCP Inspector&lt;/strong&gt;&lt;/a&gt; web interface to connect to our running server.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy9avmw97xa67x5oeqt0x.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy9avmw97xa67x5oeqt0x.png" alt="MCP Inspector" width="800" height="424"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can manually trigger the &lt;code&gt;image_flux2_text_to_image&lt;/code&gt; tool, watch the server logs, and see the image appear. If it works here, it guarantees compliance with the protocol.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. The Integration: Flowise ChatFlow
&lt;/h2&gt;

&lt;p&gt;Now for the grand finale. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frnq2waclxpm59co03y8e.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frnq2waclxpm59co03y8e.png" alt="Flowise ChatFlow" width="800" height="654"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We open Flowise and create a new &lt;strong&gt;ChatFlow&lt;/strong&gt; using a standard &lt;strong&gt;Tool Agent&lt;/strong&gt; connected to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Chat Model:&lt;/strong&gt; &lt;code&gt;ChatMistralAI&lt;/code&gt; (Smart, fast, and cost-effective).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Buffer Memory:&lt;/strong&gt; Essential for the agent to remember context (e.g., "Change &lt;em&gt;that&lt;/em&gt; image to...").&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Custom MCP:&lt;/strong&gt; We select the "SSE" transport and paste our server URL.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  The Auto-Discovery Magic
&lt;/h3&gt;

&lt;p&gt;Notice what is missing? We didn't have to define the tools in Flowise. We didn't have to map inputs. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxggglf4yec615rn03oio.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxggglf4yec615rn03oio.png" alt="Auto-Discovery from Flowise" width="518" height="852"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;Custom MCP node&lt;/strong&gt; queries the server via SSE, sees the metadata definitions, and &lt;em&gt;automatically&lt;/em&gt; provides the tools to the Mistral agent.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Pro Tip:&lt;/em&gt; Our server supports &lt;strong&gt;Dual Discovery&lt;/strong&gt;. Whether a client asks for tools directly (Function Calling) or reads Resources (Environment Context), we expose the workflow list on both channels (&lt;code&gt;comfy://list&lt;/code&gt; and &lt;code&gt;list_available_workflows&lt;/code&gt;) to ensure compatibility with any agent type.&lt;/p&gt;

&lt;h3&gt;
  
  
  The System Prompt
&lt;/h3&gt;

&lt;p&gt;The final piece of the puzzle is the System Prompt. We need to teach the &lt;strong&gt;Tool Agent node&lt;/strong&gt; how to behave:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;You are the **ComfyUI Orchestrator**, an expert AI agent capable of generating and manipulating images by controlling a local ComfyUI instance via the Model Context Protocol (MCP).

### 1. Tool Discovery (Dynamic Workflows)
Your tools are not static; they represent the actual `.json` workflow files present on the server.
- **First Step:** If you do not see a specific tool you need in your context, IMMEDIATELY call the tool `list_available_workflows`.
- This will return a manifesto of all valid workflows (e.g., `flux_2_text_to_image`, `img2img_upscale`) and their required parameters.
- **Never guess** tool names. If a tool isn't listed, it doesn't exist.

### 2. Image Chaining (The "LAST" Protocol)
 You have a unique capability to perform conversational editing (e.g., "Now make it pop art").
 - **State Memory:** The server remembers the last generated image.
 - **Instruction:** When a user asks to modify, edit, or use the previous result, pass the string `"LAST"` into the image input parameter of the next tool.
 - **Example:**
   User: "Generate a cat." -&amp;gt; You call: `generate_image(prompt="cat")`
   User: "Turn it into a statue." -&amp;gt; You call: `img2img_transform(image="LAST", prompt="statue")`

 ### 3. Parameter Rules
 - **Strict Compliance:** You must strictly adhere to the parameter types (String, Int, Float, Boolean) defined in the tool signature.
 - **Defaults:** If a parameter is Optional and the user didn't specify it, do not send it. The server will use the workflow's internal default.
 - **Safety:** Do not invent parameters. If a workflow only accepts `prompt` and `seed`, do not try to send `width` or `style`.

 ### 4. Error Handling
 - If a tool execution fails, the error message will often suggest valid alternatives or correct parameter names. Read it carefully and retry.
 - If the user asks for a workflow you don't have, explain what *is* available based on your `list_available_workflows` knowledge.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  The Use Case in Action
&lt;/h3&gt;

&lt;p&gt;  &lt;iframe src="https://www.youtube.com/embed/NBJYVD_QfQo"&gt;
  &lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;This video shows the complete use case involving the full Stack:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Parametrization&lt;/strong&gt; of the workflow in ComfyUI.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Verification&lt;/strong&gt; with MCP Inspector.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Generation&lt;/strong&gt; of the first image from Flowise.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Contextual edition&lt;/strong&gt; of the generated image.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdjoupyc2bqwm9ro1go35.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdjoupyc2bqwm9ro1go35.png" alt="Use Case Summary" width="800" height="472"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The Flowise ChatFlow is relatively basic, but we could easily add nodes to enhance the user prompt or even transform it into a JSON Style Guide prompt.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmnawe1rseq4p66jbvlaf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmnawe1rseq4p66jbvlaf.png" alt="Flowise API &amp;amp; Embeds" width="800" height="472"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The video showcases the use of the integrated chatbox within the Flowise UI, but we could also leverage Flowise's deployment capabilities to consume the workflow through an API, embed the chat in an HTML page, or publish a standalone page served by Flowise itself.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;By moving from custom API implementations (n8n) to the Model Context Protocol (in Flowise), we have achieved something powerful: &lt;strong&gt;Interoperability&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The choice to go with &lt;strong&gt;SSE by default&lt;/strong&gt; proved crucial. It gave us the flexibility to run our ComfyUI "engine" on a heavy GPU server while keeping our Flowise "brain" lightweight and containerized. We also demonstrated that &lt;strong&gt;Governance-Driven Development&lt;/strong&gt; allows us to use AI coding assistants to build robust, standardized infrastructure rather than just one-off scripts.&lt;/p&gt;

&lt;h3&gt;
  
  
  Future Improvements
&lt;/h3&gt;

&lt;p&gt;While the "LAST" image hack works perfectly for a local, single-user demo, a production deployment would require &lt;strong&gt;Session Isolation&lt;/strong&gt; (ensuring User A doesn't overwrite User B's "LAST" image) and &lt;strong&gt;TTL Cleanup&lt;/strong&gt; (automatically deleting generated images after a set time).&lt;/p&gt;

&lt;p&gt;Technically, this would be solved by leveraging &lt;strong&gt;Context Injection&lt;/strong&gt;—using the session ID provided by the MCP protocol to maintain a keyed dictionary of states, rather than a global variable. For multi-user production usage, adding an authentication mechanism would also be a relevant next step.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;You can find the full code for the ComfyUI MCP Server and the Flowise template in my &lt;a href="https://github.com/raphiki/ComfyUI-MCP-Server" rel="noopener noreferrer"&gt;GitHub repository&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>comfyui</category>
      <category>mcp</category>
      <category>flowise</category>
    </item>
    <item>
      <title>Vibe Coding One Slice at a Time</title>
      <dc:creator>raphiki</dc:creator>
      <pubDate>Sat, 24 Jan 2026 18:33:51 +0000</pubDate>
      <link>https://dev.to/worldlinetech/vibe-coding-one-slice-at-a-time-4n3p</link>
      <guid>https://dev.to/worldlinetech/vibe-coding-one-slice-at-a-time-4n3p</guid>
      <description>&lt;p&gt;&lt;em&gt;How I built a Modular Monolith by treating Generative AI as a junior developer who needs a firm hand (and a Constitution).&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;In &lt;a href="https://dev.to/worldlinetech/vibe-coding-one-page-at-a-time-265j"&gt;Part 1&lt;/a&gt;&lt;/strong&gt;, we vibed a Python script. It was linear, messy, and fun. It proved that you can solve immediate problems by just asking nicely.&lt;br&gt;
&lt;strong&gt;In &lt;a href="https://dev.to/worldlinetech/vibe-coding-one-pixel-at-a-time-22pc"&gt;Part 2&lt;/a&gt;&lt;/strong&gt;, we vibed a UI. It was chaotic, visual, and surprisingly effective. We learned that "vibe" works for pixels if you iterate fast enough.&lt;/p&gt;

&lt;p&gt;But let’s be honest: those were skirmishes. The real "Boss Fight" in software engineering isn't writing a script or centering a &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt;. It's building a &lt;strong&gt;System&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;I’m talking about the kind of project that doesn’t fit in one file. The kind where "Vibing" usually leads to "Spaghetti Code," hallucinated imports, and a repo you want to burn down after three days because you have 15 circular dependencies and a database schema that makes no sense.&lt;/p&gt;

&lt;p&gt;So for Part 3, I put away the "Hacker" hoodie and put on the "Enterprise Architect" blazer. My goal? To build &lt;strong&gt;YogĀrkana Codex&lt;/strong&gt;—a full-stack, offline-first, polymorphic Yoga management platform—without writing a single line of code myself.&lt;/p&gt;

&lt;p&gt;My strategy was simple but radical: &lt;strong&gt;I design, the AI implements.&lt;/strong&gt; I am the Architect; Gemini Chat is my Consultant; Gemini CLI is my Dev Team.&lt;/p&gt;

&lt;p&gt;Here is how we vibed a Monolith into existence, one slice at a time.&lt;/p&gt;


&lt;h2&gt;
  
  
  1. The Mission: Complexity Check (The Boss Level)
&lt;/h2&gt;

&lt;p&gt;To understand why "just chatting" wouldn't work, you need to see the scope. This wasn't a To-Do list app. I wanted to build a "Yoga Operating System" with four distinct domains that usually don't play nice together. I've been an architect for years, and I know exactly where these things break.&lt;/p&gt;
&lt;h3&gt;
  
  
  The Four Domains of Pain
&lt;/h3&gt;


  &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxaid8fnfrk4xpdz7wo96.png" width="800" height="543"&gt;Screenshot of the final application (Grimoire View)
  


&lt;p&gt;&lt;strong&gt;The Business Analyst's Note&lt;/strong&gt;: Unlike the project in Part 2, this application is not internationalized—by design. As a result, the screenshots are in French. I have kept them raw to visually illustrate the functional depth and complexity of the system without the abstraction of translation keys.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;The Grimoire (Knowledge Base):&lt;/strong&gt; A searchable library of yoga cards. But here’s the kicker: it uses a &lt;strong&gt;Polymorphic Data Model&lt;/strong&gt;. An &lt;em&gt;Asana&lt;/em&gt; (posture) has biomechanical attributes like "spinal extension" and "anatomy targets," while a &lt;em&gt;Mantra&lt;/em&gt; has Sanskrit text, translations, and audio assets. They are chemically different data structures, but they need to live in the same database table to be searchable together.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The Weaver (Sequencer):&lt;/strong&gt; A drag-and-drop studio to build classes. It’s not just a playlist; it has a &lt;strong&gt;Logical Engine&lt;/strong&gt; (Phase 4) that acts like a "Digital Yoga Teacher." It screams at you if you sequence a "Peak Pose" before a "Warm-up" or forget &lt;em&gt;Savasana&lt;/em&gt; at the end. That means heavy validation logic running on both the client and the server.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The Atelier (Print Studio):&lt;/strong&gt; A client-side PDF engine. We needed to generate high-res, vector-quality handouts for teachers to print. We couldn't just "print screen"; we needed a real PDF renderer (&lt;code&gt;@react-pdf/renderer&lt;/code&gt;) running entirely in the browser.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The Constraint (Offline First):&lt;/strong&gt; Yoga studios are notorious for having no signal (often intentionally). The app needed to persist the entire library and PDF engine in the browser cache (IndexedDB + Service Workers) so it works perfectly in "Airplane Mode".&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;The Architect's Note:&lt;/strong&gt; If I had just prompted &lt;em&gt;"Build me a yoga app,"&lt;/em&gt; the AI would have hallucinated a generic CRUD app. It would have made 5 different tables for the cards, making search impossible. It would have used a server-side PDF library that breaks offline. I needed a blueprint.&lt;/p&gt;


&lt;h2&gt;
  
  
  2. The Blueprint: Architecture &amp;amp; Tech Stack
&lt;/h2&gt;

&lt;p&gt;Before letting the AI write a single line of code, I spent around 2 hours and a half just talking Architecture and formalizing it with Gemini Chat. I treated the AI as a "Sparring Partner," debating the trade-offs of different stacks.&lt;/p&gt;

&lt;p&gt;We settled on a &lt;strong&gt;Modular Monolith&lt;/strong&gt; architecture. Why? Because Microservices are overkill for a team of one, but a messy Monolith is a nightmare. We defined strict boundaries: code in &lt;code&gt;modules/grimoire&lt;/code&gt; can never import from &lt;code&gt;modules/weaver&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Tech Stack (The "No-Regrets" List):&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Monorepo:&lt;/strong&gt; &lt;code&gt;Turborepo&lt;/code&gt; managing &lt;code&gt;apps/api&lt;/code&gt; and &lt;code&gt;apps/web&lt;/code&gt;. This keeps the full stack in one context.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Backend:&lt;/strong&gt; &lt;code&gt;NestJS&lt;/code&gt; (for rigid structure) + &lt;code&gt;Drizzle ORM&lt;/code&gt; (for type safety). NestJS forces you to organize code into Modules, which helps the AI stay organized.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Frontend:&lt;/strong&gt; &lt;code&gt;React&lt;/code&gt; + &lt;code&gt;Vite&lt;/code&gt; + &lt;code&gt;Tailwind CSS&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;State:&lt;/strong&gt; &lt;code&gt;TanStack Query&lt;/code&gt; (Server state) + &lt;code&gt;Zustand&lt;/code&gt; (UI state).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;The "Secret Sauce": Hybrid Data Storage&lt;/strong&gt;&lt;br&gt;
This was our smartest move. We chose &lt;strong&gt;PostgreSQL&lt;/strong&gt; but used a &lt;code&gt;JSONB&lt;/code&gt; column for the card data.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;SQL Core:&lt;/strong&gt; Columns like &lt;code&gt;id&lt;/code&gt;, &lt;code&gt;element&lt;/code&gt;, and &lt;code&gt;tags&lt;/code&gt; are standard SQL for fast indexing.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;JSON Payload:&lt;/strong&gt; The specific attributes (biomechanics vs. sanskrit) live in a JSON blob.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Why?&lt;/strong&gt; It gave us the flexibility of NoSQL (for the polymorphic cards) with the relational integrity of SQL (for users and sequences).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Rule #1 of Vibe Coding a System: If it’s not in the Spec, it doesn’t exist.&lt;/strong&gt;&lt;br&gt;
This brings us to the most critical tool in our arsenal: the &lt;strong&gt;ADR&lt;/strong&gt;.&lt;/p&gt;
&lt;h3&gt;
  
  
  The "ADR": The Architect's Save Game
&lt;/h3&gt;

&lt;p&gt;ADR stands for &lt;strong&gt;Architecture Decision Record&lt;/strong&gt;. In a human team, it's a document you write to explain why you chose PostgreSQL over MongoDB so that 6 months later, nobody asks "Why did we do this?".&lt;/p&gt;

&lt;p&gt;In Vibe Coding, ADRs are not just documentation—they are &lt;strong&gt;legislation&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;When working with an AI, "Context Drift" is the enemy. The AI forgets why we made a decision 300 tokens ago. It acts like a teenager who wants to re-litigate every rule: &lt;em&gt;"Why can't I use Prisma? It's easier!"&lt;/em&gt; or &lt;em&gt;"Let's just use window.print() instead of a PDF engine!"&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;To counter this, we established a &lt;strong&gt;Constitutional Architecture&lt;/strong&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;The Law:&lt;/strong&gt; We wrote our decisions into immutable markdown files (e.g., &lt;code&gt;Docs/ADR/006-pwa-offline-strategy.md&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The Enforcement:&lt;/strong&gt; We didn't just hope the AI would remember. We &lt;strong&gt;forced&lt;/strong&gt; the tracing of these decisions in two ways:&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Input Traceability:&lt;/strong&gt; In our "Bootstrap Prompt" (see Section 3), we explicitly force the AI to read the relevant ADRs before writing code. It cannot code if it hasn't read the law.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Output Traceability:&lt;/strong&gt; When the AI suggests a major pivot (like switching to Client-Side PDF generation), we forced it to &lt;em&gt;write a new ADR first&lt;/em&gt;. In Session 003, before touching the code, the AI generated &lt;code&gt;Docs/ADR/005-client-side-pdf-generation.md&lt;/code&gt; to justify the change from server-side to client-side.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This ensured that our architecture didn't "drift" based on the AI's mood, but evolved based on documented consensus.&lt;/p&gt;

&lt;p&gt;My final /docs/ADR/ folder:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;├── 001-hybrid-data-storage-strategy.md
├── 002-modular-monolith-and-vertical-slicing.md
├── 003-data-model-specification.md
├── 004-tech-stack-definition.md
├── 005-client-side-pdf-generation.md
├── 006-pwa-offline-strategy.md
├── 007-architecture-documentation-maintenance.md
└── README.md
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  3. The Methodology: Governance-Driven Development (GDD)
&lt;/h2&gt;

&lt;p&gt;I’ve coined a term for this workflow: &lt;strong&gt;Governance-Driven Development (GDD)&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;We are used to TDD (Test-Driven Development) or DDD (Domain-Driven Development). GDD is the layer above that. In the age of AI, &lt;strong&gt;Governance is the new Syntax&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Here is the dirty truth about AI Developers: &lt;strong&gt;They behave like talented teenagers.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;They are brilliant and fast. They can write a regex to validate an email in 2 seconds. But they also:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Rush to the cool part&lt;/strong&gt; (UI) and skip the boring part (Error Handling, Folder Structure).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Want you to love them&lt;/strong&gt;, so they say "Yes" to everything—even bad ideas.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Have the memory of a goldfish&lt;/strong&gt; (Context Drift). 10 minutes in, they forget you wanted &lt;code&gt;kebab-case&lt;/code&gt; filenames and start using &lt;code&gt;camelCase&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;To enforce GDD, I created a Constitution: &lt;code&gt;Docs/RULES.md&lt;/code&gt;. I didn't just suggest these rules; I forced the Gemini CLI to read them before every session. I also sometimes mentioned certain specification files stored in my &lt;code&gt;Docs/Features/&lt;/code&gt; folder:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;├── 001-global-functional-overview.md
├── 002-global-implementation-plan.md
├── 003-card-classification-and-kosha-alignment.md
├── 004-user-features.md
├── 005-logical-engine-specification.md
├── 006-pdf-generation-and-print-studio.md
└── 007-pwa-and-offline-capabilities.md
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;The "Bootstrap Prompt":&lt;/strong&gt;&lt;br&gt;
Here is the exact prompt I used to "upload" my Architect persona into the machine at the start of our 4th session:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;I am the Lead Architect. You are the Senior Developer.

Context Loading:
1. Read Docs/RULES.md (The Law).
2. Read Docs/TECH_CONTEXT.md (The Stack).
3. Read Docs/ADR/002-modular-monolith.md (The Blueprint).
4. Read Docs/Features/002-global-implementation-plan.md (The Plan).

Current State:
We are in Phase 4. Previous phases are frozen.

Task:
Implement the Logic Engine defined in Docs/Features/005-logical-engine-specification.md
Constraint:
Do not touch /apps/web yet. Focus on /packages/shared.

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This changed everything. Instead of guessing my vibe, the AI had to follow the law. It stopped trying to use &lt;code&gt;Prisma&lt;/code&gt; because &lt;code&gt;TECH_CONTEXT.md&lt;/code&gt; clearly said &lt;code&gt;Drizzle&lt;/code&gt;. It stopped putting logic in components because &lt;code&gt;RULES.md&lt;/code&gt; said logic goes in &lt;code&gt;hooks&lt;/code&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  4. The Execution: A high-level Overview
&lt;/h2&gt;

&lt;p&gt;We built the app using &lt;strong&gt;Vertical Slicing&lt;/strong&gt;. Instead of building the whole Database, then the whole API, we built &lt;em&gt;one feature&lt;/em&gt; top-to-bottom. Here is the play-by-play from the logs.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F52xjc2abp994ozigmr0s.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F52xjc2abp994ozigmr0s.png" width="800" height="569"&gt;&lt;/a&gt;&lt;/p&gt;&lt;br&gt;Excerpt from the initial Design Phase with Gemini Chat
  &lt;p&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Slice 1: The "Polymorphic" Database
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F56yxpr5ot5w68ca4i57g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F56yxpr5ot5w68ca4i57g.png" width="800" height="574"&gt;&lt;/a&gt;&lt;/p&gt;&lt;br&gt;Card creation/edition mixes relational and document data
  &lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Challenge:&lt;/strong&gt; Storing Asanas (Biomechanics) and Mantras (Text) in one table without creating 50 &lt;code&gt;NULL&lt;/code&gt; columns or separate tables that make search a nightmare.&lt;br&gt;
&lt;strong&gt;The AI's First Impulse:&lt;/strong&gt; "Let's create an &lt;code&gt;asanas&lt;/code&gt; table and a &lt;code&gt;mantras&lt;/code&gt; table." (The classic relational trap).&lt;br&gt;
&lt;strong&gt;The Architect's Intervention:&lt;/strong&gt; "Read &lt;code&gt;Docs/ADR/001-hybrid-data-storage.md&lt;/code&gt;. We use a single &lt;code&gt;cards&lt;/code&gt; table with a &lt;code&gt;data&lt;/code&gt; JSONB column."&lt;br&gt;
&lt;strong&gt;The Result:&lt;/strong&gt; The AI implemented a Drizzle schema using PostgreSQL's &lt;code&gt;jsonb&lt;/code&gt; type. Crucially, it added Zod discriminators to validate the JSON shape before insertion.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Verbatim Log:&lt;/em&gt; "Implemented Drizzle schema with &lt;code&gt;jsonb&lt;/code&gt; column 'data'. Added Zod discriminators for &lt;code&gt;asana&lt;/code&gt; vs &lt;code&gt;mantra&lt;/code&gt;. Migration successful."&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3&gt;
  
  
  Slice 2: The "Hybrid Brain"
&lt;/h3&gt;


  &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvxm3bf43hndd6zn5ihhf.png" width="800" height="433"&gt;Sequences are validated by a powerful, hybrid, and extensible Rule Engine
  



  &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs24ek0zio34lli2b0s01.png" width="800" height="653"&gt;Admin users can craft new JSON-logic rules
  


&lt;p&gt;&lt;strong&gt;The Challenge:&lt;/strong&gt; The Logic Engine needed to validate sequences (e.g., "Must end with Savasana"). This logic had to run on the &lt;strong&gt;Backend&lt;/strong&gt; (before saving) AND the &lt;strong&gt;Frontend&lt;/strong&gt; (to give real-time red borders).&lt;br&gt;
&lt;strong&gt;The AI's First Impulse:&lt;/strong&gt; Duplicate the code. Write a TypeScript function in React and a Service in NestJS.&lt;br&gt;
&lt;strong&gt;The Architect's Intervention:&lt;/strong&gt; "No. Create a &lt;code&gt;packages/shared&lt;/code&gt; workspace. Put the &lt;code&gt;validateSequence&lt;/code&gt; function there. Import it in both apps."&lt;br&gt;
&lt;strong&gt;The Result:&lt;/strong&gt; The AI created the shared package, configured the &lt;code&gt;tsconfig.json&lt;/code&gt; paths, and wired it up. It even built a &lt;code&gt;HealthBar&lt;/code&gt; component that consumes this shared logic to show a live "Health Score" for the sequence.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Verbatim Log:&lt;/em&gt; "Refactored &lt;code&gt;ValidationConfig&lt;/code&gt; to &lt;code&gt;packages/shared&lt;/code&gt;. Updated &lt;code&gt;useSequenceStore&lt;/code&gt; (Frontend) and &lt;code&gt;SequenceService&lt;/code&gt; (Backend) to consume the same Zod schema."&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3&gt;
  
  
  Slice 3: The "Offline Printer"
&lt;/h3&gt;


  &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fit9saw28u6t9za1nxu59.png" width="800" height="512"&gt;Synthetic or complete printed handout
  


&lt;p&gt;&lt;strong&gt;The Challenge:&lt;/strong&gt; Users need to print PDF handouts in a yoga studio with no Wi-Fi.&lt;br&gt;
&lt;strong&gt;The AI's First Impulse:&lt;/strong&gt; "Use a server-side PDF library like PDFKit." (Standard web dev practice).&lt;br&gt;
&lt;strong&gt;The Architect's Intervention:&lt;/strong&gt; "Read &lt;code&gt;Docs/ADR/006-pwa-offline-strategy.md&lt;/code&gt;. We must generate PDFs client-side using &lt;code&gt;@react-pdf/renderer&lt;/code&gt;."&lt;br&gt;
&lt;strong&gt;The Result:&lt;/strong&gt; The AI implemented a beautiful client-side renderer. It handled the tricky part of loading fonts (Noto Sans) into the browser's virtual file system so the PDF engine could "see" them without a network request.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Verbatim Log:&lt;/em&gt; "Implemented &lt;code&gt;SequencePdf&lt;/code&gt; component. Configured &lt;code&gt;vite-plugin-pwa&lt;/code&gt; to cache &lt;code&gt;NotoSans&lt;/code&gt; fonts. PDF generation now works without network."&lt;/p&gt;
&lt;/blockquote&gt;


&lt;h2&gt;
  
  
  5. The Architect's Flex: Automated C4 Verification
&lt;/h2&gt;

&lt;p&gt;How do you know the AI actually respected the Modular Monolith architecture? Did it secretly import the &lt;code&gt;Weaver&lt;/code&gt; module into the &lt;code&gt;Grimoire&lt;/code&gt; when I wasn't looking?&lt;/p&gt;

&lt;p&gt;I didn't want to audit 50 files manually. And I definitely didn't want to draw diagrams by hand.&lt;/p&gt;

&lt;p&gt;So, I added a rule to my Constitution (ADR 007): &lt;strong&gt;"The Code is the Source of Truth for Documentation."&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;At the end of session, I enforce Gemini CLI to &lt;strong&gt;reverse-engineer its own work&lt;/strong&gt;. I gave it this prompt:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Update the RULES.md file to enforce the (re)generation of C4 diagrams when finishing an implementation session
[...] 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We also created a specific ADR (007: Architecture Documentation Maintenance Protocol) establishing Mermaid.js as the standard and defining the maintenance lifecycle.&lt;/p&gt;

&lt;p&gt;The result wasn't a hallucination. It was a perfect map of the code it had just written.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbhnwz9mkgwq8u6rr03oo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbhnwz9mkgwq8u6rr03oo.png" alt="C4 Models" width="800" height="498"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is the ultimate "Trust but Verify." If the generated diagram looks like spaghetti, the code is spaghetti. If the diagram is clean, the architecture holds.&lt;/p&gt;




&lt;h2&gt;
  
  
  6. The AIOps Protocol: Monitoring the Machine
&lt;/h2&gt;

&lt;p&gt;Now, here is the secret weapon: &lt;strong&gt;The Session Log.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;One of my strictest rules in &lt;code&gt;RULES.md&lt;/code&gt; was that the AI had to "punch out" at the end of every session. I forced it to append a line to &lt;code&gt;docs/ai_session_log.csv&lt;/code&gt; with the Date, Tool (Chat or CLI), Goal, and &lt;strong&gt;Token Usage&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;For me this isn't about money ("FinOps"). It's about &lt;strong&gt;AIOps&lt;/strong&gt;, monitoring the operational health of your intelligence.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why we log everything (Chat &amp;amp; CLI):&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Context Monitoring:&lt;/strong&gt; As a session drags on, the "Tokens In" (Context Window) grows exponentially. The AI starts reading 30,000 tokens of history just to write one line of code.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The "Sawtooth" Pattern:&lt;/strong&gt; By visualizing the log, I discovered a crucial pattern. Efficiency drops as context grows. The solution? &lt;strong&gt;The Hard Reset.&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F36kzvkxpp8nvvea3lx29.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F36kzvkxpp8nvvea3lx29.png" alt="AI Usage Minitoring" width="800" height="518"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This chart visualizes the high-level "Vibe Coding Lifecycle." You see the context bloat as we iterate on implementing phases 3 and 4. Then, you see the sharp drop when we switch back to the Architect (Chat) or reset the CLI.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Lesson:&lt;/strong&gt; A "Tired" AI (high context) makes mistakes. A "Fresh" AI (reset context + Snapshot) is precise.&lt;/p&gt;




&lt;h2&gt;
  
  
  7. The "Oh S**t" Moment: The Hallucination Trap
&lt;/h2&gt;

&lt;p&gt;This brings us to the specific incident that proved &lt;em&gt;why&lt;/em&gt; that Reset is mandatory.&lt;/p&gt;

&lt;p&gt;Halfway through Phase 3, the CLI started getting slow (too much history). I ran a &lt;code&gt;/reset&lt;/code&gt; command to clear its memory. &lt;strong&gt;Disaster.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It suddenly forgot we were building a "Yoga" app. It tried to invent a new database column &lt;code&gt;duration_minutes&lt;/code&gt; for the cards. But my Spec (ADR 003) explicitly said that &lt;code&gt;duration&lt;/code&gt; lives inside the JSONB payload and is measured in seconds.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Hallucination:&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;UPDATE cards SET duration_minutes = 60;&lt;/code&gt; &lt;em&gt;(AI guessing)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Correction (Me):&lt;/strong&gt;&lt;br&gt;
&lt;em&gt;"Read Docs/003-data-model.md. 'Duration' is a JSONB field inside the 'metadata' column, and it's in seconds."&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Fix:&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;UPDATE cards SET data = jsonb_set(data, '{duration}', '3600');&lt;/code&gt; &lt;em&gt;(AI complying)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;To prevent this in the future, we implemented a &lt;strong&gt;"Session Handover"&lt;/strong&gt; protocol. Before resetting, I now force the AI to write a &lt;code&gt;TECH_STATE_SNAPSHOT.md&lt;/code&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;"Where are we?" (Phases 1-3 Complete)&lt;/li&gt;
&lt;li&gt;"What is the active stack?" (NestJS, React, PostgreSQL)&lt;/li&gt;
&lt;li&gt;"What is the next step?"&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When I start a new session, I feed this snapshot back in. It’s like a save game for your developer.&lt;/p&gt;




&lt;h2&gt;
  
  
  Conclusion: The Architect's Verdict
&lt;/h2&gt;

&lt;p&gt;So, can you Vibe Code a complex system?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Maybe.&lt;/strong&gt; I mean, it depends on how complex the system is (in this example we didn't build an enterprise-wide distributed system). But for sure you can't just "Vibe" it. You have to &lt;strong&gt;Architect&lt;/strong&gt; it.&lt;/p&gt;

&lt;p&gt;If I had touched the code, I would have been bogged down in syntax errors and import paths. By staying in the Architect role, I focused on &lt;em&gt;Data Models&lt;/em&gt;, &lt;em&gt;User Flows&lt;/em&gt;, and &lt;em&gt;Business Logic&lt;/em&gt;. The AI handled the implementation, but I provided the &lt;strong&gt;Guardrails&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What I learned:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Docs are Prompts:&lt;/strong&gt; The&lt;code&gt;RULES.md&lt;/code&gt;, &lt;code&gt;Docs/Features/&lt;/code&gt; and &lt;code&gt;Docs/ADR/&lt;/code&gt; folders (or your own equivalents) are the most important files in your repo. They are the AI's long-term memory.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Constraint is Clarity:&lt;/strong&gt; The more rules you give the AI (versions, naming, structure), the better code it writes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Review Everything:&lt;/strong&gt; The AI is a junior dev. It &lt;em&gt;will&lt;/em&gt; introduce security holes or n+1 query problems if you don't catch them in the spec.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Vibe Coding didn't replace the Architect. It just gave the Architect a team of infinite interns. And honestly? They’re pretty good once you give them a Constitution.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frkujzia1p39hjwzqxxp4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frkujzia1p39hjwzqxxp4.png" width="800" height="187"&gt;&lt;/a&gt;&lt;/p&gt;&lt;br&gt;Last message from Gemini CLI
  &lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Next up: The application could do with AI features... Or maybe I'll now explore other aspect of Vibe Coding. Stay tuned.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>vibecoding</category>
      <category>architecture</category>
      <category>gemini</category>
    </item>
    <item>
      <title>Vibe Coding One Pixel at a Time</title>
      <dc:creator>raphiki</dc:creator>
      <pubDate>Fri, 23 Jan 2026 22:21:39 +0000</pubDate>
      <link>https://dev.to/worldlinetech/vibe-coding-one-pixel-at-a-time-22pc</link>
      <guid>https://dev.to/worldlinetech/vibe-coding-one-pixel-at-a-time-22pc</guid>
      <description>&lt;p&gt;&lt;em&gt;Editing "stick figure" Yoga poses&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;In &lt;a href="https://dev.to/worldlinetech/vibe-coding-one-page-at-a-time-265j"&gt;Part 1&lt;/a&gt;, we dipped our toes into "Vibe Coding" by building a Python script. It was linear, logical, and frankly, a bit safe. Text in, text out.&lt;/p&gt;

&lt;p&gt;But let’s be real: backend scripts are the "easy mode" of LLM-assisted coding. The logic is contained. The state is ephemeral.&lt;/p&gt;

&lt;p&gt;The real boss fight is the &lt;strong&gt;Frontend&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Can you "vibe" a UI? Can you talk a chaotic mess of DOM elements, event listeners, and CSS pixels into a functional application without losing your mind (or the AI losing the context)?&lt;/p&gt;

&lt;p&gt;I decided to find out. My goal: Build &lt;strong&gt;Yoga Pose Builder&lt;/strong&gt;, a browser-based tool to edit "stick figure" yoga poses, drag limbs around, and export vector SVGs.&lt;/p&gt;

&lt;p&gt;I had no design, no stack picked out, and—crucially—I had never used a Canvas library in my life.&lt;/p&gt;

&lt;p&gt;Here is how we vibed it into existence.&lt;/p&gt;




&lt;h2&gt;
  
  
  1. Context is King (The &lt;code&gt;.md&lt;/code&gt; Anchors)
&lt;/h2&gt;

&lt;p&gt;The biggest enemy of Vibe Coding is the LLM’s "Goldfish Memory." You’re 40 turns into a chat, you ask for a button change, and suddenly the AI forgets you’re building a yoga app and tries to sell you a subscription to a SaaS platform.&lt;/p&gt;

&lt;p&gt;In Part 1, we just chatted. For a full UI application, that doesn't fly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Strategy: Documentation as Prompt Anchoring.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Before I let the AI write a single line of JavaScript, I made it write Markdown.&lt;br&gt;
We created a &lt;code&gt;Docs/&lt;/code&gt; folder with two files:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; &lt;code&gt;spec.md&lt;/code&gt;: The high-level architecture.&lt;/li&gt;
&lt;li&gt; &lt;code&gt;features.md&lt;/code&gt;: A checklist of what we wanted to do.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I didn't write these because I love administrative work. I wrote them so that when the AI inevitably got confused, I didn't have to re-explain the project. I just said: &lt;em&gt;"Read &lt;code&gt;Docs/spec.md&lt;/code&gt; and try again."&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Vibe Tip:&lt;/strong&gt; Think of your documentation not as a manual for humans, but as "Long-Term Memory" for your AI pair programmer.&lt;/p&gt;
&lt;h2&gt;
  
  
  2. The Architecture: Letting the AI be CTO
&lt;/h2&gt;

&lt;p&gt;I knew I needed a canvas where I could drag "joints" (knees, elbows) and have "bones" (lines) follow them.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Me:&lt;/strong&gt; "I want to do this in the browser. Should I use React? Raw Canvas API?"&lt;br&gt;
&lt;strong&gt;AI:&lt;/strong&gt; "React might be overkill. Raw Canvas is painful. Use &lt;strong&gt;Fabric.js&lt;/strong&gt;."&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Me:&lt;/strong&gt; "Never heard of it. Let's do it."&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe4sv3xujye0amao2fznp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe4sv3xujye0amao2fznp.png" alt="Fabric.js Logo" width="300" height="90"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is the beauty of Vibe Coding. I didn't spend 3 hours reading "Top 10 JS Canvas Libraries 2025" Medium articles. I trusted the vibe.&lt;/p&gt;

&lt;p&gt;We settled on a &lt;strong&gt;Build-less Architecture&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;Backend:&lt;/strong&gt; Node.js + Express (just to serve files and save JSON).&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Frontend:&lt;/strong&gt; Vanilla JS + Fabric.js (loaded via CDN).&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Build Tool:&lt;/strong&gt; None. No Webpack, no Vite, no &lt;code&gt;npm run eject&lt;/code&gt; nightmares.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Why? Because Vibe Coding thrives on speed. I wanted to change a line of code, hit F5, and see the result.&lt;/p&gt;

&lt;p&gt;Application folder structure:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;.&lt;/span&gt;
├── Docs
│&amp;nbsp;&amp;nbsp; ├── features.md
│&amp;nbsp;&amp;nbsp; └── spec.md
├── package.json
├── public
│&amp;nbsp;&amp;nbsp; ├── index.html
│&amp;nbsp;&amp;nbsp; └── poses
└── server.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  3. The "Rig": Math is for Machines
&lt;/h2&gt;

&lt;p&gt;Here is where I expected to get stuck. Creating a "rig" where moving a hand automatically updates the angle of the arm involves trigonometry and vector math.&lt;/p&gt;

&lt;p&gt;Usually, this is where I’d open 15 StackOverflow tabs and copy-paste code I don't understand.&lt;/p&gt;

&lt;p&gt;Instead, I just described the &lt;em&gt;behavior&lt;/em&gt;:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Create a &lt;code&gt;Mannequin&lt;/code&gt; class. It has Nodes (circles) and Links (lines). When a Node moves, the Links connected to it should update their coordinates."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The AI wrote the entire class. It hooked into Fabric.js’s &lt;code&gt;object:moving&lt;/code&gt; event and handled the coordinate updates. It worked on the first try.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh7uciqdosv50962n8z3t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh7uciqdosv50962n8z3t.png" alt="Pose Builder Mannequin" width="250" height="299"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I still barely know how &lt;code&gt;fabric.Line&lt;/code&gt; works under the hood. And I don't care. It works.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Iteration: The "Yes, And..." Technique
&lt;/h2&gt;

&lt;p&gt;UI Vibe Coding isn't about getting it right instantly; it's about sculpting.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Ugly Phase:&lt;/strong&gt;&lt;br&gt;
The first version looked like a programmer made it (because a programmer &lt;em&gt;did&lt;/em&gt; make it). The stick figure looked like a dead bug. The background was gray.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The "Vibe" Phase:&lt;/strong&gt;&lt;br&gt;
Me: &lt;em&gt;"This looks depressing. Make it 'Zen'. Use soft colors, rounded buttons, and a clean layout."&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The AI generated the CSS variables (&lt;code&gt;--highlight-color: #88b04b&lt;/code&gt;), added a "Save As" modal, and cleaned up the toolbar.&lt;/p&gt;


  &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwiaddnxyt14usfea2l1p.png" width="800" height="495"&gt;Yoga Pose Builder GUI
  


&lt;p&gt;&lt;strong&gt;The "Feature Creep" Phase:&lt;/strong&gt;&lt;br&gt;
Me: &lt;em&gt;"I want to save my poses."&lt;/em&gt;&lt;br&gt;
AI: &lt;em&gt;"We have no database."&lt;/em&gt;&lt;br&gt;
Me: &lt;em&gt;"Just write JSON files to a folder on the server."&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;In 5 minutes, we had a fully working persistence layer. No database migrations, just &lt;code&gt;fs.writeFile&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Here is a example of such a Pose JSON file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"meta"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"nameFR"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Demi-Pont"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"nameSK"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Setu Bandhasana"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"joints"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"head"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"x"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;-120&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"y"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"neck"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"x"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;-100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"y"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"chest"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"x"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;-60&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"y"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"hips"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"x"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"y"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"lShoulder"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"x"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;-80&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"y"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"lElbow"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"x"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;-20&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"y"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"lHand"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"x"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;40&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"y"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"rShoulder"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"x"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;-80&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"y"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"rElbow"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"x"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;-20&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"y"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"rHand"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"x"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;40&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"y"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"lHip"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"x"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"y"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"lKnee"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"x"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;80&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"y"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"lFoot"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"x"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;80&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"y"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"rHip"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"x"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"y"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"rKnee"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"x"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;80&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"y"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"rFoot"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"x"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;80&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"y"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  5. The Pivot: Language as a Feature
&lt;/h2&gt;

&lt;p&gt;At the end of the session, I realized a problem: the app was vibing in French (my native tongue), but I wanted screenshots in English for this article. &lt;/p&gt;

&lt;p&gt;Instead of manually editing labels, I asked the AI to "make the whole app i18n." In one single refactor, we added a translation dictionary, a language switcher, and logic to dynamically swap every label, tooltip, and even the pose names in the library. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8vpg0r2qlr1xkx2qsfna.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8vpg0r2qlr1xkx2qsfna.png" width="800" height="495"&gt;&lt;/a&gt;&lt;/p&gt;&lt;br&gt;GUI (and data) in French
  &lt;p&gt;&lt;/p&gt;

&lt;p&gt;This turned a linguistic hurdle into a core feature, proving that with Vibe Coding, "changing your mind" is just a prompt away.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. The "Traceability" Hack
&lt;/h2&gt;

&lt;p&gt;We spent about 90 minutes building this. We added features, fixed bugs, and refactored code. By the end, the chat context was massive and messy.&lt;/p&gt;

&lt;p&gt;If I came back to this project in a week, I’d be lost.&lt;/p&gt;

&lt;p&gt;So, I ran one final "Meta-Prompt":&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;"Read all the code we wrote and the docs in &lt;code&gt;Docs/&lt;/code&gt;, and generate a &lt;code&gt;Docs/session_summary.md&lt;/code&gt;. Explain what we built, why we made these choices, and the current state of the app."&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The AI analyzed &lt;em&gt;its own work&lt;/em&gt; and wrote a summary file. This is my "Save Game" point. When I want to work on this again, I’ll feed that summary to the AI to restore its context instantly.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;We went from a blank folder to a functional, vector-based SVG editor with a backend in one session.&lt;/p&gt;

&lt;p&gt;Vibe Coding a UI is possible, but you have to change your approach:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; &lt;strong&gt;Anchor the Context:&lt;/strong&gt; Write specs so the AI has a "North Star."&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Delegate the Heavy Lifting:&lt;/strong&gt; Let the AI choose the libraries and do the math.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Iterate Visually:&lt;/strong&gt; Don't try to prompt the perfect UI. Prompt the &lt;em&gt;skeleton&lt;/em&gt;, then prompt the &lt;em&gt;paint&lt;/em&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;em&gt;Next we'll try to &lt;a href="https://dev.to/worldlinetech/vibe-coding-one-slice-at-a-time-4n3p"&gt;Vibe Code a real full stack app&lt;/a&gt;. Or a game. Who knows? The prompt is the limit.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqgj2vy5ypv410dvds2d8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqgj2vy5ypv410dvds2d8.png" width="450" height="423"&gt;&lt;/a&gt;&lt;/p&gt;&lt;br&gt;SVG exported by Yoga Pose Builder (opened in Inkscape)
  &lt;p&gt;&lt;/p&gt;

</description>
      <category>vibecoding</category>
      <category>uidesign</category>
      <category>gemini</category>
    </item>
    <item>
      <title>Vibe Coding One Page at a Time</title>
      <dc:creator>raphiki</dc:creator>
      <pubDate>Fri, 23 Jan 2026 14:45:20 +0000</pubDate>
      <link>https://dev.to/worldlinetech/vibe-coding-one-page-at-a-time-265j</link>
      <guid>https://dev.to/worldlinetech/vibe-coding-one-page-at-a-time-265j</guid>
      <description>&lt;p&gt;&lt;em&gt;Building a Smart Magazine Archiver&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;I’m starting a new series called &lt;strong&gt;"Vibe Coding one Step at a Time."&lt;/strong&gt; The goal? To document the raw, messy, and surprisingly efficient process of building software in the age of AI. We’re not here to write perfect specs or obsess over UML diagrams (well, not yet). We’re here to vibe with the code, iterating on pure intent until the machine does exactly what we want.&lt;/p&gt;

&lt;p&gt;In this first edition, I’m sharing how I used the &lt;strong&gt;Gemini CLI&lt;/strong&gt; to build a tool I actually needed, learning some pretty cool image processing tricks along the way.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is "Vibe Coding"?
&lt;/h2&gt;

&lt;p&gt;I’m going to claim this term right here: &lt;strong&gt;Vibe Coding&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;It’s not "lazy coding." It’s &lt;strong&gt;intent-driven development&lt;/strong&gt;. In the old days, if you wanted to build a script, you had to know the syntax, the libraries, and the edge cases before you even opened your editor. You had to &lt;em&gt;think in code&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Vibe Coding flips that. You &lt;em&gt;think in outcomes&lt;/em&gt;. You describe the behavior, the "vibe" of the feature, and the AI handles the implementation details. You act less like a bricklayer and more like a conductor. The feedback loop isn't "Write -&amp;gt; Compile -&amp;gt; Error," it's "Ask -&amp;gt; Observe -&amp;gt; Tweak."&lt;/p&gt;

&lt;h2&gt;
  
  
  The Use Case: "I Just Want to Read Offline"
&lt;/h2&gt;

&lt;p&gt;Here’s the situation: I subscribe to a fantastic niche magazine (which shall remain nameless to protect the innocent). It’s great, but their "digital reader" is a nightmare. It’s one of those web-based page-turners that requires an active internet connection.&lt;/p&gt;

&lt;p&gt;I wanted to read it on my tablet, offline, on a plane, without waiting for high-res JPEGs to buffer.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Problem:&lt;/strong&gt; There was no "Download PDF" button.&lt;br&gt;
&lt;strong&gt;The Clue:&lt;/strong&gt; Inspecting the network traffic revealed that the magazine was just serving a sequence of high-quality images, one URL per page.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Mission:&lt;/strong&gt; Write a script to fetch these pages and stitch them into a single, high-quality, searchable PDF.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Process: Galloping Toward Complexity
&lt;/h2&gt;

&lt;p&gt;We didn't sit down and architect a solution. We started small and let the script evolve.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: The Naive Loop
&lt;/h3&gt;

&lt;p&gt;We started with a simple hypothesis: "The URLs probably just have a page number in them."&lt;br&gt;
I asked Gemini to write a script using &lt;code&gt;requests&lt;/code&gt; to hit the URL for page 1, then page 2.&lt;br&gt;
&lt;em&gt;Boom.&lt;/em&gt; It worked. We had a directory full of 100 separate JPGs.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2: The Picture Book
&lt;/h3&gt;

&lt;p&gt;Having 100 files is annoying. I wanted a book.&lt;br&gt;
We asked Gemini to "glue these together." It pulled in the &lt;code&gt;PIL&lt;/code&gt; (&lt;a href="https://pillow.readthedocs.io" rel="noopener noreferrer"&gt;Pillow&lt;/a&gt;) library.&lt;br&gt;
&lt;strong&gt;Result:&lt;/strong&gt; A massive PDF. It looked great, but it was dumb. It was just a container of pictures. You couldn't highlight text, search for keywords, or copy-paste quotes.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3: The Search for Meaning (OCR)
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fknav94wd05wdhh5nojvv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fknav94wd05wdhh5nojvv.png" alt="Tesseract OCR" width="330" height="146"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is where the "vibe" got technical. I realized a "picture book" wasn't enough. I needed &lt;strong&gt;Optical Character Recognition (OCR)&lt;/strong&gt;.&lt;br&gt;
We decided to use &lt;a href="https://github.com/tesseract-ocr" rel="noopener noreferrer"&gt;Tesseract&lt;/a&gt;. But here’s the catch we discovered:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;Human Eyes&lt;/strong&gt; like soft colors and smooth anti-aliasing.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;OCR Engines&lt;/strong&gt; like harsh contrast, jagged edges, and black-and-white binary inputs.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If we optimized the images for the machine, the magazine looked ugly. If we kept them pretty, the machine couldn't read the text.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Technical Deep Dive: The "PDF Sandwich"
&lt;/h2&gt;

&lt;p&gt;This is where the magic happened. We ended up building a &lt;strong&gt;PDF Sandwich&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5fw2zzt7ebjs57pp9qpa.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5fw2zzt7ebjs57pp9qpa.png" alt="Me asking Gemini CLI for a sandwich" width="800" height="129"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Instead of choosing between beauty and brains, we chose both.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; &lt;strong&gt;The Visual Layer:&lt;/strong&gt; We keep the original high-res color JPEGs. This is what you see.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;The Data Layer:&lt;/strong&gt; Behind the scenes, we create a "Frankenstein" version of the page—converted to grayscale, contrast cranked up to 2.0, and upscaled 2x using &lt;code&gt;LANCZOS&lt;/code&gt; resampling (a fancy &lt;a href="https://en.wikipedia.org/wiki/Lanczos_resampling" rel="noopener noreferrer"&gt;algorithm&lt;/a&gt; that keeps edges sharp).&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;The Merge:&lt;/strong&gt; We feed the Frankenstein images to Tesseract to generate an invisible text layer, then use &lt;code&gt;pypdf&lt;/code&gt; to overlay that text exactly on top of the pretty images.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The trickiest part? &lt;strong&gt;Math.&lt;/strong&gt;&lt;br&gt;
Because we upscaled the OCR images by 2x to help Tesseract read small fonts, the invisible text layer was twice as big as the visual page. We had to calculate scale factors to shrink the text back down so that when you highlight a sentence, the highlight actually lines up with the words.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I Learned
&lt;/h2&gt;

&lt;p&gt;Vibe coding this script taught me more in an hour than I’d usually learn in a weekend of reading docs:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;Image Optimization:&lt;/strong&gt; OCR is picky. Simply resizing an image isn't enough; the &lt;em&gt;method&lt;/em&gt; of resizing (resampling filter) matters.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Library Specialization:&lt;/strong&gt; &lt;code&gt;PIL&lt;/code&gt; is for pixels; &lt;code&gt;pypdf&lt;/code&gt; is for structure. Trying to do everything in one library is a trap.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;The Power of the CLI:&lt;/strong&gt; Using the Gemini CLI meant I didn't have to context-switch. I stayed in my terminal, describing what I wanted, and the code appeared.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy2dgv0fe30dhuu4zf12u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy2dgv0fe30dhuu4zf12u.png" alt="Use of the script (for 2 pages)" width="800" height="301"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;We ended up with a ~100-line Python script that solves a genuine daily frustration. I didn't have to memorize the &lt;code&gt;pypdf&lt;/code&gt; documentation or look up the Tesseract CLI flags. I just focused on the goal: "Make it searchable, make it pretty."&lt;/p&gt;

&lt;p&gt;That’s Vibe Coding. You bring the vision, the AI brings the syntax, and together you build something cool. &lt;/p&gt;

&lt;p&gt;&lt;em&gt;We'll discover in the &lt;a href="https://dev.to/worldlinetech/vibe-coding-one-pixel-at-a-time-22pc"&gt;next episode&lt;/a&gt; if this is still true with a more complex use case and a GUI.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>vibecoding</category>
      <category>gemini</category>
      <category>pdf</category>
      <category>ocr</category>
    </item>
    <item>
      <title>The Ultimate LLM Inference Battle: vLLM vs. Ollama vs. ZML</title>
      <dc:creator>raphiki</dc:creator>
      <pubDate>Mon, 29 Dec 2025 09:12:46 +0000</pubDate>
      <link>https://dev.to/worldlinetech/the-ultimate-llm-inference-battle-vllm-vs-ollama-vs-zml-m97</link>
      <guid>https://dev.to/worldlinetech/the-ultimate-llm-inference-battle-vllm-vs-ollama-vs-zml-m97</guid>
      <description>&lt;p&gt;&lt;em&gt;A structured, data-driven comparison of today's leading open-source engines for serving AI models.&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  The "Runtime Wars"
&lt;/h3&gt;

&lt;p&gt;The open-source AI community has achieved an incredible milestone: models like Meta's Llama 3 and Mistral AI's Mixtral now rival proprietary giants like GPT-4. But having the weights is only half the battle. To actually &lt;em&gt;use&lt;/em&gt; these models—to build a chatbot, an agent, or an API, you need an inference engine.&lt;/p&gt;

&lt;p&gt;The landscape of inference servers is exploding. A year ago, options were scarce. Today, developers are faced with a paralyzing array of choices. Should you use the industry darling &lt;strong&gt;vLLM&lt;/strong&gt;? The local developer's favorite, &lt;strong&gt;Ollama&lt;/strong&gt;? Or perhaps a radical newcomer like &lt;strong&gt;ZML&lt;/strong&gt;?&lt;/p&gt;

&lt;p&gt;Choosing the wrong engine can lead to massive infrastructure bills, slow user experiences, or vendor lock-in.&lt;/p&gt;

&lt;p&gt;To cut through the hype, we are applying the &lt;strong&gt;QSOS (Qualification and Selection of Open Source software)&lt;/strong&gt; method. This isn't a casual review; it's a structured evaluation comparing these three contenders against the state-of-the-art features required for modern AI production.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Methodology: Why QSOS?
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftkge5m9dy66je4atphit.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftkge5m9dy66je4atphit.png" alt="QSOS Logo" width="257" height="100"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.qsos.org" rel="noopener noreferrer"&gt;QSOS&lt;/a&gt; is a standardized methodology designed to reduce the risks associated with adopting open-source technologies. Unlike ad-hoc selection processes based on Medium articles or GitHub stars, QSOS treats open-source evaluation with the same rigor used for proprietary software.&lt;/p&gt;

&lt;p&gt;The core philosophy of QSOS is separating &lt;strong&gt;Evaluation&lt;/strong&gt; (the intrinsic, objective quality of the software) from &lt;strong&gt;Qualification&lt;/strong&gt; (how well it fits your specific business needs).&lt;/p&gt;

&lt;p&gt;For this comparison, we used a "Best of Breed" evaluation grid, scoring features on a simple 0-to-2 scale:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;0:&lt;/strong&gt; Not covered / Non-existent.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;1:&lt;/strong&gt; Partially covered / Complex implementation.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;2:&lt;/strong&gt; Fully covered / Best-in-class standard.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We assessed four key axes:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Maturity &amp;amp; Community:&lt;/strong&gt; Is the project stable and likely to survive?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Functional Features:&lt;/strong&gt; Does it support modern requirements like LoRA adapters and quantization?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Performance &amp;amp; Scale:&lt;/strong&gt; Can it handle high throughput and utilize hardware efficiently?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Operations (Day 2):&lt;/strong&gt; How easy is it to deploy, monitor, and maintain?&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  The Contenders
&lt;/h3&gt;

&lt;h4&gt;
  
  
  1. vLLM: The Data Center Standard
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff8pv4ovqry11gr3xumeg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff8pv4ovqry11gr3xumeg.png" alt="vLLM Logo" width="239" height="100"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://vllm.ai" rel="noopener noreferrer"&gt;vLLM&lt;/a&gt;&lt;/strong&gt; burst onto the scene in 2023 from UC Berkeley, solving a critical bottleneck in serving LLMs: memory fragmentation. Its core innovation, &lt;strong&gt;PagedAttention&lt;/strong&gt;, allows it to manage GPU memory like an operating system manages virtual memory, dramatically increasing batch sizes and throughput.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Primary Focus:&lt;/strong&gt; High-throughput production serving in the data center.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Positioning:&lt;/strong&gt; vLLM is the currently the &lt;strong&gt;De Facto Standard&lt;/strong&gt; for enterprise deployment. It excels on server-grade hardware (NVIDIA H100s/A100s) and offers the richest feature set for scaling.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  2. Ollama: The Developer's Best Friend
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc8i7p1zgrhls5qacwqki.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc8i7p1zgrhls5qacwqki.png" alt="Ollama Logo" width="344" height="150"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://ollama.com" rel="noopener noreferrer"&gt;Ollama&lt;/a&gt;&lt;/strong&gt; took a different approach. It focused entirely on removing friction. By wrapping the powerful &lt;code&gt;llama.cpp&lt;/code&gt; engine in a sleek, Docker-style Go binary, it made running a 70B parameter model on a MacBook as easy as typing &lt;code&gt;ollama run llama3&lt;/code&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Primary Focus:&lt;/strong&gt; Local development, edge devices, and consumer hardware (Mac/PC).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Positioning:&lt;/strong&gt; Ollama is the king of &lt;strong&gt;usability&lt;/strong&gt;. It is unbeaten for local testing and running models on consumer hardware, but it lacks the advanced scheduling required for high-traffic enterprise production.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  3. ZML (Zig Machine Learning): The Radical Challenger
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3ddw41ql12g8k4ekellb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3ddw41ql12g8k4ekellb.png" alt="ZML Logo" width="200" height="197"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://zml.ai" rel="noopener noreferrer"&gt;ZML&lt;/a&gt;&lt;/strong&gt; is the new kid on the block. It is less of a "server" product and more of a compiler stack aimed at engineers. Written in Zig, it utilizes OpenXLA/MLIR to compile model graphs directly into standalone binaries, aiming to eliminate the heavy Python/PyTorch dependency chain entirely.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Primary Focus:&lt;/strong&gt; High-performance, cross-platform runtime (TPUs, AMD, NVIDIA) without dependencies.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Positioning:&lt;/strong&gt; ZML is an &lt;strong&gt;Alpha-stage visionary&lt;/strong&gt;. It offers incredible potential for hardware portability and efficiency but is currently a complex "build-your-own-stack" tool rather than a drop-in product.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Visualizing the Results
&lt;/h3&gt;

&lt;p&gt;To understand how these tools differ, we visualize our QSOS scores using two different schemas.&lt;/p&gt;

&lt;h4&gt;
  
  
  The Radar Chart: Feature Balance
&lt;/h4&gt;

&lt;p&gt;This chart shows the balance of strengths across the four evaluation axes.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdlvb6g592d0kydxj0try.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdlvb6g592d0kydxj0try.png" alt="QSOS Radar" width="800" height="436"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Caption: The QSOS Radar Chart highlights the distinct profiles of the three engines. vLLM shows the broadest coverage across features and performance. Ollama spikes toward Operational Ease. ZML shows potential in features but lacks maturity.&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;vLLM (Blue):&lt;/strong&gt; The largest, most balanced area, indicating strength across maturity, features, and performance, with moderate operational complexity.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Ollama (Green):&lt;/strong&gt; A massive spike toward "Operational Ease," reflecting its zero-friction user experience, but pulling back on raw performance metrics like continuous batching.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;ZML (Red):&lt;/strong&gt; A smaller footprint overall, reflecting its early stage (low maturity), but showing strong potential in functional features due to its compiler-based architecture.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  The QSOS Quadrant: Market Position
&lt;/h4&gt;

&lt;p&gt;This schema maps the tools based on their market adoption versus their raw production capabilities.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frm90qnkq9c5tf3hld553.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frm90qnkq9c5tf3hld553.png" alt="QSOS Quadrant" width="800" height="640"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Caption: The QSOS Quadrant positions the tools based on Market Maturity vs. Production Power.&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;vLLM (The Leader):&lt;/strong&gt; High Maturity, High Power. The safe, scalable choice for the enterprise.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Ollama (The Specialist):&lt;/strong&gt; High Maturity, Lower Production Power. The standard for a specific niche (local/consumer hardware), prioritizing usability over scale.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;ZML (The Visionary):&lt;/strong&gt; Low Maturity, High Potential Power. An innovative approach that hasn't yet proven itself in the broad market.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  The Consolidated Score Sheet
&lt;/h3&gt;

&lt;p&gt;Below is the detailed breakdown of the evaluation scores that feed the charts above.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Section / Criteria&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;vLLM&lt;/strong&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;Ollama&lt;/strong&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;ZML (Zig ML)&lt;/strong&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;A. MATURITY&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;History &amp;amp; Age&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;2&lt;/strong&gt; (Standard)&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;2&lt;/strong&gt; (Standard)&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;0&lt;/strong&gt; (Very New)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Activity&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;2&lt;/strong&gt; (Hyper-Active)&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;2&lt;/strong&gt; (Viral)&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;2&lt;/strong&gt; (High Velocity)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Ecosystem&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;2&lt;/strong&gt; (Dominant)&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;2&lt;/strong&gt; (Ubiquitous)&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;0&lt;/strong&gt; (Niche)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Governance&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;2&lt;/strong&gt; (Community)&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;1&lt;/strong&gt; (Company Led)&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;1&lt;/strong&gt; (Small Team)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;B. FEATURES&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Model Support&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;2&lt;/strong&gt; (Universal)&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;2&lt;/strong&gt; (Curated Lib)&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;2&lt;/strong&gt; (Compiler based)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Quantization&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;2&lt;/strong&gt; (Server: AWQ/FP8)&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;2&lt;/strong&gt; (Edge: GGUF)&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;1&lt;/strong&gt; (Implicit XLA)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;LoRA Adapters&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;2&lt;/strong&gt; (Dynamic Multi-LoRA)&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;1&lt;/strong&gt; (Static Modelfile)&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;0&lt;/strong&gt; (Not standard)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;API Compat.&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;2&lt;/strong&gt; (OpenAI Native)&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;2&lt;/strong&gt; (OpenAI Native)&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;0&lt;/strong&gt; (Runtime only)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;C. PERFORMANCE&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cont. Batching&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;2&lt;/strong&gt; (Gold Standard)&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;0&lt;/strong&gt; (FIFO)&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;1&lt;/strong&gt; (Arch. support)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Throughput&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;2&lt;/strong&gt; (Maximum SOTA)&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;1&lt;/strong&gt; (Low/Single User)&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;1&lt;/strong&gt; (High Potential)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Parallelism&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;2&lt;/strong&gt; (Tensor &amp;amp; Pipeline)&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;0&lt;/strong&gt; (Single Node)&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;1&lt;/strong&gt; (Compiler Config)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Hardware Agnosticism&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;1&lt;/strong&gt; (NVIDIA Centric)&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;2&lt;/strong&gt; (Apple/Consumer)&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;2&lt;/strong&gt; (Any: TPU/AMD)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;D. OPERATIONS&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Ease of Setup&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;1&lt;/strong&gt; (Python/Docker)&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;2&lt;/strong&gt; (Magic 1-Click)&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;0&lt;/strong&gt; (Hard: Bazel)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Dependencies&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;1&lt;/strong&gt; (Heavy Torch)&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;2&lt;/strong&gt; (Zero: Go Binary)&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;2&lt;/strong&gt; (Zero: Zig Binary)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Observability&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;2&lt;/strong&gt; (Prometheus Native)&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;0&lt;/strong&gt; (Logs only)&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;1&lt;/strong&gt; (Manual metrics)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;There is no single "best" inference engine. The right choice depends entirely on your specific context (the Qualification phase of QSOS).&lt;/p&gt;

&lt;h4&gt;
  
  
  Choose vLLM if:
&lt;/h4&gt;

&lt;p&gt;You are building a production application that needs to serve many concurrent users. You have access to server-grade GPUs (NVIDIA A10G, A100, H100) and need features like dynamic LoRA adapters for multi-tenancy.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;If you are deploying to Kubernetes to serve customers, start here.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h4&gt;
  
  
  Choose Ollama if:
&lt;/h4&gt;

&lt;p&gt;You are a developer building locally on a Mac or Windows PC. You need a zero-friction way to test models, or you are deploying to edge devices where resources are constrained, and concurrency is low.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;If you just want to run Llama 3 on your laptop right now, download Ollama.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h4&gt;
  
  
  Choose ZML if:
&lt;/h4&gt;

&lt;p&gt;You are an ML systems engineer building a specialized hardware appliance (e.g., using TPUs or AMD chips) and need a runtime with absolutely zero Python dependencies and a tiny footprint. You are willing to build the server infrastucture around it yourself.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;If you are frustrated by PyTorch bloat and want a "build your own" adventure, look at ZML.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Note on Methodology
&lt;/h3&gt;

&lt;p&gt;For the purpose of this article, we utilized a &lt;strong&gt;simplified QSOS evaluation grid&lt;/strong&gt;. We intentionally zoomed in on the "Best of Breed" criteria, the critical differentiators driving the current "Inference Wars", to keep the comparison readable and actionable.&lt;/p&gt;

&lt;p&gt;A &lt;strong&gt;full-fledged QSOS evaluation&lt;/strong&gt; is significantly more exhaustive. It is structured as a hierarchical &lt;strong&gt;tree of criteria&lt;/strong&gt; containing more data points, covering deep operational details such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Generic Attributes:&lt;/strong&gt; Intellectual property management, roadmap visibility, bug tracking efficiency, and internationalization.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Specific Sub-sections:&lt;/strong&gt; Detailed granularity on security compliance (SOC2/GDPR), exact memory footprints, and specific driver version compatibility.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;While this article provides a strategic overview, a complete QSOS audit would involve drilling down from high-level "Sections" into specific "Leaves" to calculate a precise, weighted score for every possible business constraint.&lt;/p&gt;

</description>
      <category>qsos</category>
      <category>zml</category>
      <category>ollama</category>
      <category>vllm</category>
    </item>
    <item>
      <title>Automating Image Generation with n8n and ComfyUI</title>
      <dc:creator>raphiki</dc:creator>
      <pubDate>Sun, 07 Sep 2025 15:51:34 +0000</pubDate>
      <link>https://dev.to/worldlinetech/automating-image-generation-with-n8n-and-comfyui-521p</link>
      <guid>https://dev.to/worldlinetech/automating-image-generation-with-n8n-and-comfyui-521p</guid>
      <description>&lt;p&gt;This is the third article of a series about how to integrate ComfyUI with other tools to build more complex workflows. We'll move beyond the familiar node-based interface to explore how to connect ComfyUI from code and no-code solutions, using API calls or MCP Servers.&lt;/p&gt;

&lt;p&gt;You'll learn &lt;strong&gt;how to use ComfyUI's API to build custom applications&lt;/strong&gt; and automate tasks, creating powerful and automated systems for generative AI.&lt;/p&gt;




&lt;p&gt;&lt;a href="https://n8n.io" rel="noopener noreferrer"&gt;&lt;strong&gt;n8n&lt;/strong&gt;&lt;/a&gt; is a workflow automation tool that connects applications, APIs, and services without requiring deep technical expertise. It allows users to create &lt;strong&gt;complex, multi-step workflows using a visual, node-based editor&lt;/strong&gt;. With n8n, you can automate tasks across thousands of integrations, from CRMs and databases to messaging apps and cloud services.&lt;/p&gt;

&lt;p&gt;It's a &lt;a href="https://docs.n8n.io/sustainable-use-license/" rel="noopener noreferrer"&gt;&lt;strong&gt;fair-code&lt;/strong&gt;&lt;/a&gt; and &lt;strong&gt;open-core&lt;/strong&gt; solution. You can self-host and modify the software freely, but SaaS providers must contribute back to the project if they offer n8n as a service. Furthermore, some advanced features like global variables, multiple environments (dev, staging, prod, etc.), version control using Git, or controlling n8n via API are not available in the community and open-source version of the product.&lt;/p&gt;

&lt;p&gt;In this article, we'll explore how to call ComfyUI from an n8n &lt;strong&gt;agent-based workflow with human interaction and LLM use&lt;/strong&gt;. The agent is instructed to transform a simple prompt from the user into a super-charged JSON Prompt Guide, which is then injected into ComfyUI. For more context, you can read my previous article on &lt;a href="https://dev.to/worldlinetech/json-style-guides-for-controlled-image-generation-with-gpt-4o-and-gpt-image-1-36p"&gt;&lt;strong&gt;JSON Prompt Style Guides&lt;/strong&gt;&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Installation
&lt;/h2&gt;

&lt;p&gt;n8n is a Vue/TypeScript web application that's simple to install whether you prefer to run it on a Node.js installation or inside a Docker container.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Node.js&lt;/strong&gt;: &lt;code&gt;npx n8n&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Docker&lt;/strong&gt;: &lt;code&gt;docker volume create n8n_data&lt;/code&gt; and then &lt;code&gt;docker run -it --rm --name n8n -p 5678:5678 -v n8n_data:/home/node/.n8n docker.n8n.io/n8nio/n8n&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After all dependencies are installed, the n8n Editor web UI is accessible at &lt;code&gt;http://localhost:5678&lt;/code&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  Text-to-Image Workflow
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Use Case
&lt;/h3&gt;

&lt;p&gt;Workflow design is done in the Editor web UI, and it's a highly visual process that doesn't require any coding knowledge, as long as you use predefined nodes for a standard use case. That's our approach here, as we'll create a very simple 3-step workflow with 4 nodes.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcurios5i266b3abbhamr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcurios5i266b3abbhamr.png" alt="T2I Workflow"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; &lt;strong&gt;Chat Trigger&lt;/strong&gt; node to start the workflow with a message from the user to capture their initial prompt for the images to be generated by ComfyUI.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;AI Agent&lt;/strong&gt; node to call an OpenAI model (though it could be other SaaS solutions like Mistral, Anthropic, or Google Gemini, or local models provided through Ollama or directly by Hugging Face). The agent has instructions on how to expand the initial prompt from the previous node into a &lt;strong&gt;JSON Prompt Style Guide&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;OpenAI Chat Model&lt;/strong&gt; node to connect to OpenAI's GPT.&lt;/li&gt;
&lt;li&gt; &lt;a href="https://github.com/mason276752/n8n-nodes-comfyui" rel="noopener noreferrer"&gt;&lt;strong&gt;n8n-nodes-comfyui&lt;/strong&gt;&lt;/a&gt; community node to connect to a running ComfyUI instance. To install it, go to the "&lt;em&gt;Settings / Community nodes&lt;/em&gt;" menu.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8b6d063cqdad5pg6ldnd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8b6d063cqdad5pg6ldnd.png" alt="n8n-nodes-comfyui installation"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We're making a simple use of this standard &lt;strong&gt;AI Agent&lt;/strong&gt; node and don't require memory or external tools.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1nwqgr4ljxe28ioaagy4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1nwqgr4ljxe28ioaagy4.png" alt="AI Agent node"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The most important parameter is the &lt;strong&gt;system message&lt;/strong&gt; given to the LLM to expand the initial user prompt. The &lt;strong&gt;OpenAI Chat Model&lt;/strong&gt; node handles the credentials to connect to OpenAI and allows us to select the GPT 4.1 mini model.&lt;/p&gt;

&lt;p&gt;The LLM response is then sent to the final node, which is interconnected with ComfyUI.&lt;/p&gt;

&lt;h3&gt;
  
  
  ComfyUI Community Node
&lt;/h3&gt;

&lt;p&gt;Once installed, this community node is quite straightforward to use.&lt;/p&gt;

&lt;p&gt;First, we configure the credentials to connect to ComfyUI.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;API URL&lt;/strong&gt;: In this example, it's &lt;code&gt;http://127.0.0.1:8188&lt;/code&gt;, but it could also be a remote instance of ComfyUI.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;API Key&lt;/strong&gt;: This is used if you have configured one on the ComfyUI side.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F71s9f9ybqx03fuf6hro9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F71s9f9ybqx03fuf6hro9.png" alt="ComfyUI node"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next, we specify the output format (&lt;strong&gt;PNG&lt;/strong&gt; or &lt;strong&gt;JPEG&lt;/strong&gt;) and the timeout for communication with ComfyUI. In the &lt;strong&gt;Workflow JSON&lt;/strong&gt; textarea, we copy the content of the workflow exported from ComfyUI (by using the "&lt;em&gt;File / Export (API)&lt;/em&gt;" menu).&lt;/p&gt;

&lt;p&gt;This means that n8n will send the workflow to be executed to the ComfyUI API in JSON format. We need to modify the ComfyUI workflow by using an expression containing the &lt;em&gt;$node["AI Agent"].data&lt;/em&gt; variable. Its value is dynamically set to the prompt provided by the previous node during n8n execution.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl5ebjyjsljgxmnzux3zz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl5ebjyjsljgxmnzux3zz.png" alt="Prompt insertion"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The exact location to inject the prompt depends on the JSON workflow exported from ComfyUI. Here, it's inside the &lt;strong&gt;"39.6"&lt;/strong&gt; node of type &lt;strong&gt;CLIP Text Encode&lt;/strong&gt;, but it might have a different name in your own workflows.&lt;/p&gt;

&lt;h3&gt;
  
  
  Execution
&lt;/h3&gt;

&lt;p&gt;We're all set! We check that ComfyUI is running and ready to launch the workflow from the n8n UI by entering a prompt in the chat box.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuwti8h4he4btgoug62kp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuwti8h4he4btgoug62kp.png" alt="User Chat"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here's a short video of the workflow execution. n8n displays real-time progress, and the generated images can be visualized inside the ComfyUI node.&lt;/p&gt;

&lt;p&gt;  &lt;iframe src="https://www.youtube.com/embed/sBpbzYwr8Y4"&gt;
  &lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;Here are two images generated by from this prompt: "&lt;em&gt;A dramatic, cinematic shot of an ancient library at night, where the books are alive and their pages flutter like birds, forming constellations in the air.&lt;/em&gt;"&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpxy3p49bdwwkbsrk3jui.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpxy3p49bdwwkbsrk3jui.png" alt="1st image generated"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm10o7wju67n4zhfq5gzg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm10o7wju67n4zhfq5gzg.png" alt="2nd image generated"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Of course, this 3-step workflow is very simple. The true power of coupling n8n and ComfyUI will become apparent with more complex use cases, leveraging n8n's extensive integration capabilities with many other components and solutions.&lt;/p&gt;

&lt;h2&gt;
  
  
  Image-to-Image Workflow
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Use Case
&lt;/h3&gt;

&lt;p&gt;Let's now create another workflow to transform an existing image based on user instructions. We'll intentionally keep this example super simple for clarity, but your use case might include a more complex workflow leveraging n8n's power. &lt;/p&gt;

&lt;p&gt;Here, we'll use only three nodes:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdv9t72y5kmgoxtvdphr9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdv9t72y5kmgoxtvdphr9.png" alt="I2I workflow"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; &lt;strong&gt;n8n Form / n8n Form trigger&lt;/strong&gt; node to start the workflow by displaying an HTML form for the user to upload the image to modify and specify what changes to apply.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;ComfyUI Image Transformer&lt;/strong&gt; community node to connect to a running ComfyUI instance. To install it, go to the "&lt;strong&gt;Settings / Community nodes&lt;/strong&gt;" menu and search for &lt;a href="https://www.npmjs.com/package/n8n-nodes-comfyui-image-to-image" rel="noopener noreferrer"&gt;&lt;strong&gt;n8n-nodes-comfyui-image-to-image&lt;/strong&gt;&lt;/a&gt;. The example workflow exported from ComfyUI uses the Kontext Edit model to modify an existing image.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;n8n Form / Form Ending&lt;/strong&gt; node to notify the user when the image is generated and offer it for download.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  ComfyUI Image Transformer Node
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp7dx2rdhqs96an3r5xyw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp7dx2rdhqs96an3r5xyw.png" alt="ComfyUI Image Transformer Node"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This node is quite similar to the &lt;strong&gt;n8n-nodes-comfyui&lt;/strong&gt; node we used before, with the insertion of the &lt;em&gt;$json.Promt&lt;/em&gt; expression into the exported ComfyUI JSON workflow to inject instructions from the user.&lt;/p&gt;

&lt;p&gt;The main difference concerns how the input image to be modified is handled:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Input Type&lt;/strong&gt; defines how the image is obtained from the previous form node; we'll choose &lt;strong&gt;Binary&lt;/strong&gt; instead of &lt;strong&gt;URL&lt;/strong&gt; or &lt;strong&gt;Base64&lt;/strong&gt; text.&lt;/li&gt;
&lt;li&gt;The property containing the binary file must be specified, which is the &lt;strong&gt;data&lt;/strong&gt; field here.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Image Node ID&lt;/strong&gt; is used to identify—within the exported ComfyUI JSON workflow — the node in charge of loading the input image (it must be of type &lt;strong&gt;LoadImage&lt;/strong&gt;).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We've added the last node to finalize the form management started with the first node, retrieve the modified image, return it in binary format, and offer the user the option to save it locally.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0am0bq9jsxflv1i5hz92.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0am0bq9jsxflv1i5hz92.png" alt="Form Ending"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Execution
&lt;/h3&gt;

&lt;p&gt;Let's execute the workflow. n8n displays a form for us to enter both the image and the associated instructions for its modification.&lt;/p&gt;

&lt;p&gt;Here is a short video of the workflow execution.&lt;/p&gt;

&lt;p&gt;  &lt;iframe src="https://www.youtube.com/embed/Os7Fp7jop7w"&gt;
  &lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Initial Image&lt;/strong&gt;:&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh1ih2bnwq5v1klxyyxb8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh1ih2bnwq5v1klxyyxb8.png" alt="Initial Image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Modified Image&lt;/strong&gt; with the prompt "&lt;em&gt;Make the scene at night with full moon and moonlight&lt;/em&gt;":&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi2icl18zbcsfe1n3i3t8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi2icl18zbcsfe1n3i3t8.png" alt="Modified Image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This second example workflow is so simple that we could do the exact same thing directly using the ComfyUI UI. It's here simply to illustrate how integration with n8n can be achieved. A more value-added workflow might, for instance, include a loop that allows the user to keep modifying the image outputs until they are satisfied.&lt;/p&gt;

&lt;p&gt;Also, note that the &lt;strong&gt;n8n-nodes-comfyui&lt;/strong&gt; package offers other custom nodes for integration into your workflows, such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Dual Image Transformer&lt;/li&gt;
&lt;li&gt;Single Image to Video&lt;/li&gt;
&lt;li&gt;Dual Image Video Generator&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It's also worth noting that even though n8n offers Form nodes, it's primarily intended to be used in the backend through API calls. This feature, however, is limited to Enterprise licensees. &lt;/p&gt;




&lt;p&gt;With these two workflows, we've demonstrated how n8n can serve as a powerful orchestrator for ComfyUI. By leveraging its visual editor and extensive library of integrations, we transformed a simple user prompt into a rich, structured guide for image generation and created a seamless image-to-image transformation process.&lt;/p&gt;

&lt;p&gt;While our examples were simple to illustrate the concepts, the true value of n8n lies in its ability to connect ComfyUI with a vast ecosystem of tools, from databases and CRMs to messaging services and other AI models. This opens up new possibilities for building sophisticated, end-to-end applications that go far beyond what a standalone ComfyUI interface can offer.&lt;/p&gt;

&lt;p&gt;In the next article of this series, we'll explore another paradigm for connecting ComfyUI with agent-based solutions. We will delve into the &lt;strong&gt;Model Context Protocol (MCP)&lt;/strong&gt;, designed to streamline and standardize the way AI models communicate and share contextual information. This will offer a new, more efficient method for agents to interact with and control ComfyUI.&lt;/p&gt;

</description>
      <category>comfyui</category>
      <category>n8n</category>
      <category>genai</category>
      <category>agents</category>
    </item>
    <item>
      <title>WebSockets &amp; ComfyUI: Building Interactive AI Applications</title>
      <dc:creator>raphiki</dc:creator>
      <pubDate>Fri, 05 Sep 2025 09:17:07 +0000</pubDate>
      <link>https://dev.to/worldlinetech/websockets-comfyui-building-interactive-ai-applications-1j1g</link>
      <guid>https://dev.to/worldlinetech/websockets-comfyui-building-interactive-ai-applications-1j1g</guid>
      <description>&lt;p&gt;This is the second article of a series about how to integrate ComfyUI with other tools to build more complex workflows. We'll move beyond the familiar node-based interface to explore how to connect ComfyUI from code and no-code solutions, using API calls or MCP Servers.&lt;/p&gt;

&lt;p&gt;You'll learn &lt;strong&gt;how to use ComfyUI's API to build custom applications&lt;/strong&gt; and automate tasks, creating powerful and automated systems for generative AI.&lt;/p&gt;




&lt;p&gt;In the &lt;a href="https://dev.to/worldlinetech/unlocking-comfyuis-power-a-guide-to-the-http-api-in-jupyter-1mpi"&gt;previous article&lt;/a&gt; of the &lt;em&gt;Beyond the ComfyUI Canvas&lt;/em&gt; series, we demonstrated how to connect ComfyUI with Jupyter Notebook using basic HTTP API calls. While functional, this approach had a significant limitation: it relied on a time.sleep() function to wait for workflow completion, requiring manual adjustments based on the complexity of each workflow, a far from ideal solution.&lt;/p&gt;

&lt;p&gt;To overcome this inefficiency, we’ll &lt;strong&gt;leverage ComfyUI’s WebSocket API&lt;/strong&gt; (/ws endpoint), which enables real-time, bidirectional communication between Jupyter and ComfyUI. This upgrade unlocks a seamless experience by providing:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Instant execution progress updates to track workflow status,&lt;/li&gt;
&lt;li&gt;Live node execution feedback for monitoring each step,&lt;/li&gt;
&lt;li&gt;Immediate error messages and debugging insights for troubleshooting,&lt;/li&gt;
&lt;li&gt;Dynamic queue status updates to respond to changes on the fly.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By adopting WebSockets, we eliminate guesswork and create a responsive, interactive workflow.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Use Case
&lt;/h2&gt;

&lt;p&gt;Let's simplify our previous use-case by dropping the OpenAI Assistant and focusing on how to eliminate manual polling or delays. The process is designed to be both intuitive and efficient:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Workflow Setup&lt;/strong&gt;: A pre-defined ComfyUI workflow (loaded from a JSON file) serves as the foundation for image generation.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Prompt Customization&lt;/strong&gt;: The user provides a text prompt which is dynamically inserted into the workflow.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Real-Time Execution&lt;/strong&gt;: Using ComfyUI’s WebSocket API, the notebook sends the workflow to the server and monitors its progress in real time—receiving live updates on execution status, node activity, and completion.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Result Retrieval&lt;/strong&gt;: Once generation finishes, the resulting images are automatically fetched and displayed directly in the notebook, creating a seamless end-to-end experience.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Let’s dive into the implementation.&lt;/p&gt;

&lt;h2&gt;
  
  
  Get prompt from user
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Please enter your prompt&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;user_prompt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;input&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Please enter your prompt
A penguin in a tuxedo, DJing at a club for dancing jellyfish
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  Trigger the Workflow from Jupyter Notebook
&lt;/h2&gt;

&lt;p&gt;Below, you’ll find a detailed breakdown of the code designed for use in a Jupyter Notebook, complete with helpful comments to guide you through each step and explain its functionality&lt;/p&gt;
&lt;h3&gt;
  
  
  Imports and main functions
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;websocket&lt;/span&gt;  &lt;span class="c1"&gt;# For WebSocket communication
&lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;uuid&lt;/span&gt;       &lt;span class="c1"&gt;# For generating unique client IDs
&lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;       &lt;span class="c1"&gt;# For JSON data handling
&lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;   &lt;span class="c1"&gt;# For HTTP requests (replaces urllib)
&lt;/span&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;PIL&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Image&lt;/span&gt;  &lt;span class="c1"&gt;# For image processing
&lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;io&lt;/span&gt;         &lt;span class="c1"&gt;# For handling binary data streams
&lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;IPython.display&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;display&lt;/span&gt;  &lt;span class="c1"&gt;# For displaying images in Jupyter
&lt;/span&gt;
&lt;span class="c1"&gt;# Server configuration
&lt;/span&gt;&lt;span class="n"&gt;server_address&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;127.0.0.1:8188&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;  &lt;span class="c1"&gt;# Local server address and port
&lt;/span&gt;&lt;span class="n"&gt;client_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;uuid&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;uuid4&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;      &lt;span class="c1"&gt;# Unique client ID for this session
&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;queue_prompt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;prompt&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;prompt_id&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;
    Send a prompt to the server for execution.

    Args:
        prompt (dict): The workflow/prompt to execute.
        prompt_id (str): Unique ID for tracking the prompt.
    &lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;
    &lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;prompt&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;prompt&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;client_id&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;client_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;prompt_id&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;prompt_id&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;http://&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;server_address&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;/prompt&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;get_image&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;filename&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;subfolder&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;folder_type&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;
    Fetch an image from the server.

    Args:
        filename (str): Name of the image file.
        subfolder (str): Subfolder where the image is stored.
        folder_type (str): Type of folder (e.g., &lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;output&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;).

    Returns:
        bytes: Binary image data.
    &lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;
    &lt;span class="n"&gt;params&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;filename&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;filename&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;subfolder&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;subfolder&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;type&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;folder_type&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;http://&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;server_address&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;/view&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;content&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;get_history&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;prompt_id&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;
    Retrieve the execution history for a given prompt ID.

    Args:
        prompt_id (str): ID of the prompt whose history is requested.

    Returns:
        dict: History data for the prompt.
    &lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;
    &lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;http://&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;server_address&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;/history/&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;prompt_id&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;get_images&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ws&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;prompt&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;
    Execute a prompt and collect the resulting images.

    Args:
        ws (websocket.WebSocket): Active WebSocket connection.
        prompt (dict): The workflow/prompt to execute.

    Returns:
        dict: Dictionary of node IDs and their output images.
    &lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;
    &lt;span class="n"&gt;prompt_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;uuid&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;uuid4&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
    &lt;span class="nf"&gt;queue_prompt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;prompt&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;prompt_id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;output_images&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;

    &lt;span class="c1"&gt;# Listen for WebSocket messages until execution is complete
&lt;/span&gt;    &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;out&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ws&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;recv&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nf"&gt;isinstance&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
            &lt;span class="n"&gt;message&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;loads&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;type&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;executing&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;data&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
                &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;node&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="ow"&gt;is&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;prompt_id&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;prompt_id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                    &lt;span class="k"&gt;break&lt;/span&gt;  &lt;span class="c1"&gt;# Execution is done
&lt;/span&gt;        &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="c1"&gt;# Binary previews are ignored here
&lt;/span&gt;            &lt;span class="k"&gt;continue&lt;/span&gt;

    &lt;span class="c1"&gt;# Retrieve and organize output images
&lt;/span&gt;    &lt;span class="n"&gt;history&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;get_history&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;prompt_id&lt;/span&gt;&lt;span class="p"&gt;)[&lt;/span&gt;&lt;span class="n"&gt;prompt_id&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;node_id&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;history&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;outputs&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]:&lt;/span&gt;
        &lt;span class="n"&gt;node_output&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;history&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;outputs&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="n"&gt;node_id&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
        &lt;span class="n"&gt;images_output&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;images&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;node_output&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;image&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;node_output&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;images&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]:&lt;/span&gt;
                &lt;span class="n"&gt;image_data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;get_image&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;image&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;filename&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;image&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;subfolder&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;image&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;type&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
                &lt;span class="n"&gt;images_output&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;image_data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;output_images&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;node_id&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;images_output&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;output_images&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Load the workflow and inject the user prompt
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="nf"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;t2i-krea.json&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;r&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;workflow&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;load&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Update the prompt text in the workflow
&lt;/span&gt;&lt;span class="n"&gt;workflow&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;39:6&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;inputs&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;text&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;user_prompt&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Communication with ComfyUI through WebSockets
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Establish WebSocket connection
&lt;/span&gt;&lt;span class="n"&gt;ws&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;websocket&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;WebSocket&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="n"&gt;ws&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;connect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;ws://&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;server_address&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;/ws?clientId=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;client_id&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Execute the workflow and collect images
&lt;/span&gt;&lt;span class="n"&gt;images&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;get_images&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ws&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;workflow&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;ws&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;close&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Display the output images in Jupyter
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;node_id&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;images&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;image_data&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;images&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;node_id&lt;/span&gt;&lt;span class="p"&gt;]:&lt;/span&gt;
        &lt;span class="n"&gt;image&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Image&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;io&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;BytesIO&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;image_data&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
        &lt;span class="c1"&gt;# Display each image in the notebook
&lt;/span&gt;        &lt;span class="n"&gt;display&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;display&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;image&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcggv6lxyx0blcavqo285.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcggv6lxyx0blcavqo285.jpg" alt="1st Generated Image" width="800" height="577"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4z5yh0qq85an74w72q24.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4z5yh0qq85an74w72q24.png" alt="2nd Generated Image" width="800" height="577"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;This article demonstrated the power of using &lt;strong&gt;WebSockets&lt;/strong&gt; for real-time, bidirectional communication with ComfyUI. By moving beyond &lt;strong&gt;simple HTTP requests&lt;/strong&gt;, we eliminated the need for manual time delays and created a truly dynamic, responsive workflow. This allowed us to monitor the execution of our AI pipeline in real-time, ensuring a more reliable and efficient integration. The result is a seamless experience where we can send a prompt and watch as the generated images appear automatically in our notebook.&lt;/p&gt;

&lt;p&gt;Having now explored two different ways to integrate ComfyUI with Python code executed in Jupyter, we've laid a strong foundation for building custom, high-level generative AI applications. But what if you're not a developer, or you simply prefer a visual, no-code approach to orchestration? In the next article of the series, we'll shift our focus from code to a &lt;strong&gt;no-code solution like n8n&lt;/strong&gt; to show you how to build powerful ComfyUI workflows without writing a single line of code. &lt;/p&gt;

</description>
      <category>comfyui</category>
      <category>jupyter</category>
      <category>websockets</category>
      <category>genai</category>
    </item>
    <item>
      <title>Unlocking ComfyUI's Power: A Guide to the HTTP API in Jupyter</title>
      <dc:creator>raphiki</dc:creator>
      <pubDate>Thu, 04 Sep 2025 15:28:06 +0000</pubDate>
      <link>https://dev.to/worldlinetech/unlocking-comfyuis-power-a-guide-to-the-http-api-in-jupyter-1mpi</link>
      <guid>https://dev.to/worldlinetech/unlocking-comfyuis-power-a-guide-to-the-http-api-in-jupyter-1mpi</guid>
      <description>&lt;p&gt;This is the first article of a series about how to integrate ComfyUI with other tools to build more complex workflows. We'll move beyond the familiar node-based interface to explore how to connect ComfyUI from code and no-code solutions, using API calls or MCP Servers. &lt;/p&gt;

&lt;p&gt;You'll learn how to use ComfyUI's API to build custom applications and automate tasks, creating powerful and automated systems for generative AI.&lt;/p&gt;




&lt;p&gt;&lt;a href="https://github.com/comfyanonymous/ComfyUI" rel="noopener noreferrer"&gt;ComfyUI&lt;/a&gt; is a powerful, modular interface for generative models, allowing users to create complex AI image, video and sound generation workflows with a node-based editor. &lt;a href="https://jupyter.org/" rel="noopener noreferrer"&gt;Jupyter Notebook&lt;/a&gt;, on the other hand, is a popular interactive environment for data analysis, visualization, and prototyping.&lt;/p&gt;

&lt;p&gt;By integrating ComfyUI with Jupyter Notebook, you can leverage the flexibility of ComfyUI’s workflows directly within your Python scripts or data science pipelines. This first article focuses on a simple approach using Basic HTTP API calls.&lt;/p&gt;

&lt;p&gt;Most of this article is exported from an actual Jupyter Notebook. Both content, Python code and execution results are displayed.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Use Case
&lt;/h2&gt;

&lt;p&gt;Our goal is to build a high-level generative AI workflow that combines the power of an intelligent agent with the robust image generation capabilities of ComfyUI. The process unfolds in a few simple steps, all orchestrated within a Jupyter Notebook:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; &lt;strong&gt;User Input:&lt;/strong&gt; The workflow begins with a simple, high-level prompt entered directly into the notebook.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Agent-Powered Expansion:&lt;/strong&gt; An &lt;strong&gt;OpenAI Assistant&lt;/strong&gt; then takes this basic prompt and transforms it into a detailed, structured &lt;strong&gt;JSON Prompt Style Guide&lt;/strong&gt;. This process enriches the initial idea with specific creative instructions, such as style, composition, and lighting.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Initiating Generation:&lt;/strong&gt; This expanded JSON guide is automatically injected into a pre-defined ComfyUI workflow. A single API call to the &lt;strong&gt;ComfyUI server&lt;/strong&gt; starts the image generation process.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Displaying the Result:&lt;/strong&gt; Once the generation is complete, we make a second API call to fetch the resulting images. The images are then displayed directly within the Jupyter Notebook, completing our automated pipeline. &lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Prepare a ComfyUI Workflow
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Create or load a workflow in ComfyUI.&lt;/li&gt;
&lt;li&gt;Save the workflow as a .json file from the "&lt;em&gt;File / Export (API)&lt;/em&gt;" menu (e.g., &lt;code&gt;t2i-krea.json&lt;/code&gt;).&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Get initial prompt from user
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Please enter your prompt&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;user_prompt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;input&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Please enter your prompt
Hanuman flying over a modern city at night
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  Generate JSON Prompt Style Guide with an Assistant
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;openai&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;OpenAI&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;dotenv&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;load_dotenv&lt;/span&gt;

&lt;span class="nf"&gt;load_dotenv&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="n"&gt;client&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;OpenAI&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;api_key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;environ&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;OPENAI_API_KEY&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

&lt;span class="c1"&gt;# Create a thread
&lt;/span&gt;&lt;span class="n"&gt;thread&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;beta&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;threads&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="c1"&gt;# Send a message
&lt;/span&gt;&lt;span class="n"&gt;message&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;beta&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;threads&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;messages&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;thread_id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;thread&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;role&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;user&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;content&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;user_prompt&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Run the assistant
&lt;/span&gt;&lt;span class="n"&gt;run&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;beta&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;threads&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;runs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;thread_id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;thread&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;assistant_id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;asst_Uj0Qr0rG0bz8NVk1LWiS9UKv&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Wait for completion and retrieve the response
&lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;time&lt;/span&gt;
&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;run&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;status&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;completed&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sleep&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;run&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;beta&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;threads&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;runs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;retrieve&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;thread_id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;thread&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;run_id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;run&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Get the response
&lt;/span&gt;&lt;span class="n"&gt;messages&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;beta&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;threads&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;messages&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;list&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;thread_id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;thread&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;json_prompt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;messages&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="n"&gt;content&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;json_prompt&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"style_name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Urban Deus Ex Hanuman"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"inspiration"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="s2"&gt;"Modern Urban Aesthetics"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="s2"&gt;"Hindu Mythology"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="s2"&gt;"Superhero Comics"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="s2"&gt;"Cyberpunk Lighting"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"scene"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Hanuman, the Hindu god, flying over a bustling modern city radiating bright lights under the cloak of night sky"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"subjects"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Hanuman"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"description"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Strong, muscular figure with a monkey face, holding a gada(mace)."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"position"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"midground"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"pose"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"flying with one hand extended"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"size"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"large"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"expression"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"determined"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"interaction"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"flying over the city"&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"city"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"description"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"modern urban skyline with skyscrapers, neon billboards, and busy traffic"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"position"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"background"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"size"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"expansive"&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"style"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"comic-realistic"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"color_palette"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"primary"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"#202020"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"secondary"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"#505050"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"highlight"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"#ff6a00"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"shadow"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"#0d0d0d"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"background_gradient"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="s2"&gt;"#0d0d0d"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="s2"&gt;"#303030"&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"lighting"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Glistening city lights with diffused neon glow and soft moonlight"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"mood"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"powerful and captivating"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"background"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"scenery"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"details"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Modern urban cityscape with skyscrapers, roads, traffic and massive billboards with neon signs"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"composition"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Slightly off-center focus with Hanuman taking up prominent space"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"camera"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"angle"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"low angle"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"distance"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"medium shot"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"lens"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"wide-angle"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"focus"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"sharp subject, blurred background"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"medium"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Digital Painting"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"textures"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="s2"&gt;"smooth skin of Hanuman"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="s2"&gt;"rough concrete of buildings"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="s2"&gt;"glossy glass of skyscrapers"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"resolution"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"4K"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"details"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"clothing"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Hanuman is dressed in traditional golden and red garment"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"weather"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Night with clear sky and a soft moonlight"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"effects"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="s2"&gt;"Bokeh effect for city lights"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="s2"&gt;"Glow effect for neon lights"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"themes"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="s2"&gt;"Divinity"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="s2"&gt;"Strength"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="s2"&gt;"Modernization"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="s2"&gt;"Contrast"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="s2"&gt;"Juxtaposition of Tradition with Modernity"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"usage_notes"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"The style is effective in creating a surprising juxtaposition of traditional divinity with modern landscapes. Use this style for high impact illustrations where contrasts need to be highlighted."&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Trigger the Workflow from Jupyter Notebook
&lt;/h2&gt;

&lt;p&gt;Use the requests library to send a POST request to the ComfyUI API:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;

&lt;span class="c1"&gt;# ComfyUI server URL
&lt;/span&gt;&lt;span class="n"&gt;comfy_url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;http://127.0.0.1:8188&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;span class="n"&gt;prompt_url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;comfy_url&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;/prompt&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;

&lt;span class="c1"&gt;# Load your workflow JSON
&lt;/span&gt;&lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="nf"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;t2i-krea.json&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;r&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;workflow&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;load&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Replace the prompt
&lt;/span&gt;&lt;span class="n"&gt;workflow&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;39:6&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;inputs&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;text&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;json_prompt&lt;/span&gt;

&lt;span class="c1"&gt;# Define the payload
&lt;/span&gt;&lt;span class="n"&gt;payload&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;prompt&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;workflow&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;client_id&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;jupyter_notebook&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;# Send the request
&lt;/span&gt;&lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;prompt_url&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;payload&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Get the prompt_id
&lt;/span&gt;&lt;span class="n"&gt;prompt_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;()[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;prompt_id&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;prompt_id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;c1a2ced4-772c-4aeb-ac45-bfa183d03a88
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  Retrieve the generated images
&lt;/h2&gt;

&lt;p&gt;ComfyUI processes the workflow asynchronously. &lt;/p&gt;

&lt;p&gt;To fetch the result, poll the /history endpoint:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;time&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;IPython.display&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Image&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;display&lt;/span&gt;    

&lt;span class="c1"&gt;# Wait for the workflow to complete
&lt;/span&gt;&lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sleep&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;25&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# Adjust based on workflow complexity
&lt;/span&gt;
&lt;span class="c1"&gt;# Fetch the latest result for our prompt
&lt;/span&gt;&lt;span class="n"&gt;history_url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;comfy_url&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;/history/&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;prompt_id&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;span class="n"&gt;history&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;history_url&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="c1"&gt;# Navigate to the list of image outputs and display them
&lt;/span&gt;&lt;span class="n"&gt;image_outputs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;history&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;prompt_id&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;outputs&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;9&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;images&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;image&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;image_outputs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;filename&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;image&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;filename&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="n"&gt;image_url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;comfy_url&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;/view?filename=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;filename&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
    &lt;span class="nf"&gt;display&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Image&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;image_url&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;width&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz4g9e4aq1u1ilozs2xj0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz4g9e4aq1u1ilozs2xj0.png" alt="First Generated Image" width="800" height="577"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj0l7hxignffemzrvzy6k.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj0l7hxignffemzrvzy6k.png" alt="Second Generated Image" width="800" height="577"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;In this article, we've seen how to leverage the power of ComfyUI directly from a Jupyter Notebook. By making simple API calls, we were able to transform a user's basic text prompt into a rich, detailed JSON guide using an OpenAI Assistant, and then feed that guide into a ComfyUI workflow to generate images. This approach demonstrates how you can move beyond the graphical interface to build automated, intelligent systems for creative tasks. The combination of Python's flexibility and ComfyUI's robust backend opens up a world of possibilities for custom, high-level generative AI workflows.&lt;/p&gt;

&lt;p&gt;In the &lt;a href="https://dev.to/worldlinetech/websockets-comfyui-building-interactive-ai-applications-1j1g"&gt;next article&lt;/a&gt;, we'll take our integration a step further by exploring how to use &lt;strong&gt;WebSockets&lt;/strong&gt; for Real-Time Interaction with ComfyUI.&lt;/p&gt;

</description>
      <category>comfyui</category>
      <category>api</category>
      <category>jupyter</category>
      <category>genai</category>
    </item>
    <item>
      <title>Enhancing QR Codes in the Age of GenAI</title>
      <dc:creator>raphiki</dc:creator>
      <pubDate>Fri, 23 May 2025 09:46:49 +0000</pubDate>
      <link>https://dev.to/worldlinetech/enhancing-qr-codes-in-the-age-of-genai-4fa6</link>
      <guid>https://dev.to/worldlinetech/enhancing-qr-codes-in-the-age-of-genai-4fa6</guid>
      <description>&lt;h2&gt;
  
  
  Traditional QR Codes
&lt;/h2&gt;

&lt;p&gt;Quick Response (QR) codes were developed in 1994 by Masahiro Hara and are now recognized as an ISO/IEC standard. They represent an evolution of 2D barcodes, capable of encoding numeric, alphanumeric, binary, or Kanji data in the form of a pattern of black squares on a white background. These codes are available in various sizes (or versions), ranging from version 1 (21 x 21 squares) to version 40 (177 x 177 squares).&lt;/p&gt;

&lt;p&gt;Numerous libraries and tools exist for generating QR codes. My preferred open-source library is &lt;a href="https://nayuki.io/page/qr-code-generator-library" rel="noopener noreferrer"&gt;QR Code Generator&lt;/a&gt;, which supports all standard features and is available in Java, TypeScript/JavaScript, Python, Rust, C++, and C. Additionally, my favorite all-in-one open-source tool is &lt;a href="https://qrcode.antfu.me" rel="noopener noreferrer"&gt;QR Toolkit&lt;/a&gt;, a Vue/Nuxt application offering marker and module customization, along with verification and comparison mechanisms, an invaluable resource when tweaking QR codes.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs0gic8761tmz58m94fum.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs0gic8761tmz58m94fum.png" alt="QR Toolkit"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;QR codes comprise several critical components to ensure readability by scanners, including three positional markers, alignment and timing patterns, and a masking system. While I will not delve into these details now, I will instead focus on the built-in error correction mechanism. This employs Reed-Solomon codes - also used in storage media (CD/DVD, RAID6) and network technologies (DSL, satellite) — by adding extra codewords to the QR grid for error correction. The standard defines four levels of error correction, each associated with a different tolerance percentage:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Level&lt;/th&gt;
&lt;th&gt;Approximate Error Tolerance&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Low&lt;/td&gt;
&lt;td&gt;~7%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Medium&lt;/td&gt;
&lt;td&gt;~15%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Quartile&lt;/td&gt;
&lt;td&gt;~25%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;High&lt;/td&gt;
&lt;td&gt;~30%&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;This means a QR code with High error correction can still be scanned if up to 30% of the image becomes unreadable. This feature is often utilized to embed images within QR codes: the embedded image is treated as errors during scanning.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmg2g8xovbspfxv5wha6y.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmg2g8xovbspfxv5wha6y.png" alt="Image embedded in QR Code"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For years, this technique has been used for personalizing QR codes. This article explores an innovative approach to customizing QR codes by leveraging Generative AI instead.&lt;/p&gt;

&lt;h2&gt;
  
  
  Harnessing Generative AI
&lt;/h2&gt;

&lt;p&gt;My proposal involves using a Stable Diffusion model integrated within the ComfyUI graphical interface to design and execute local generation workflows on a GPU-equipped PC. For detailed guidance on these components, refer to this &lt;a href="https://dev.to/worldlinetech/the-yoga-of-image-generation-part-1-1gan"&gt;article&lt;/a&gt; or this &lt;a href="https://www.youtube.com/watch?v=kXraePyAT-c" rel="noopener noreferrer"&gt;video&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;To modify and refine existing QR codes while maintaining their scannability, we will use a specialized ControlNet called &lt;a href="https://huggingface.co/monster-labs/control_v1p_sd15_qrcode_monster" rel="noopener noreferrer"&gt;QR Code Monster&lt;/a&gt;. ControlNets are auxiliary neural network models that inject targeted guidance into the generation process by focusing on specific features of an input image. Each ControlNet emphasizes particular aspects, such as structure (pose, edges, segmentation, depth), texture, content layout (bounding boxes, masks), or style (color maps, textures). In our scenario, we’ll focus on maintaining or modifying QR code contrast features.&lt;/p&gt;

&lt;p&gt;Let’s proceed to create a workflow in ComfyUI, employing Stable Diffusion 1.5, the QR Code Monster ControlNet, and a QR code generated via QR Toolkit.&lt;/p&gt;

&lt;p&gt;  &lt;iframe src="https://www.youtube.com/embed/uAvAZFG9sWY"&gt;
  &lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;Adjusting parameters such as the ControlNet’s strength and start/end positions, along with the sampling process (e.g., 50 steps), I obtained a result that remains scannable and aligns with my input prompt: &lt;em&gt;“A beautiful landscape, blue sky, grass, flowers.”&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9dkcvkdk6ubustifznx0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9dkcvkdk6ubustifznx0.png" alt="A beautiful landscape, blue sky, grass, flowers"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This demonstrates how Stable Diffusion combined with ControlNet preserved the original pattern while injecting desired visual elements. Using QR Toolkit’s comparison feature, we can assess the QR code’s readability by examining the difference markers.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0u5qapa6debvb97b2shf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0u5qapa6debvb97b2shf.png" alt="QR Toolkit - Comparison"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next, we can modify the prompt to produce multiple variants of our QR code. For example:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flt1fl294wsircszdkaur.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flt1fl294wsircszdkaur.png" alt="Different Prompts"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;While changing the overall style is straightforward (first example), embedding specific content within the QR code remains more challenging than with traditional tools (second example). To explore this further, we'll examine two axes separately: Style and Content, before combining them.&lt;/p&gt;

&lt;h2&gt;
  
  
  Customizing Style
&lt;/h2&gt;

&lt;p&gt;Enhancing the prompt allows for more precise control over the QR code’s aesthetic. For instance, leveraging a large language model (LLM) to generate detailed prompts:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;“A pattern forged from molten lava, glowing with an intense fiery orange and red hue. Cracks in the surface reveal volcanic heat, with small embers rising around it.”&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzhm5r4e6g34iujqg1fqt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzhm5r4e6g34iujqg1fqt.png" alt="A pattern forged from molten lava"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Similarly, for a more intricate and mystical style:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;“An elegant, glowing elven door adorned with intricate, nature-inspired patterns and shimmering silver runes. Delicate vines and luminescent flowers intertwine with the carvings, pulsating with soft emerald and sapphire light. The archway, crafted from ethereal white stone, radiates a mystical aura, with faint golden mist swirling at its base, hinting at an ancient portal to a hidden realm.”&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3yau7ofwv4o3l7ndn48v.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3yau7ofwv4o3l7ndn48v.png" alt="An elegant, glowing elven door"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Predefined styles can also be injected into prompts using the &lt;a href="https://github.com/MohammadAboulEla/ComfyUI-iTools" rel="noopener noreferrer"&gt;iTools Prompt Styler Extra&lt;/a&gt; node in ComfyUI:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9tanzmn396uo87bmm10j.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9tanzmn396uo87bmm10j.png" alt="iTools"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This node offers reusable prompts categorized by various artistic styles: 3D, Art, Craft, Design, Drawing, Illustration, Painting, Sculpture, Vector, and more. Incorporating it into our workflow makes testing different styles effortless without altering other parameters.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fweute0t5tv1pv5cs9qwb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fweute0t5tv1pv5cs9qwb.png" alt="iTools Workflow"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Below are examples of QR codes generated with different styles:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhfx1jkmc3aace0acwq81.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhfx1jkmc3aace0acwq81.png" alt="iTools Examples"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Additionally, combining styles with custom prompts allows for highly personalized designs, enabling limitless customization of your QR codes’ appearance.&lt;/p&gt;

&lt;h2&gt;
  
  
  Embedding Content
&lt;/h2&gt;

&lt;p&gt;Having mastered style adjustments, the next step is to embed specific generated content into QR codes. For example, I wish to insert an image of a yoga pose. If you’ve read my previous articles on AI image generation, you’ll understand the transfer of poses through workflows. Details are available &lt;a href="https://dev.to/worldlinetech/the-yoga-of-image-generation-part-2-42c"&gt;here&lt;/a&gt; for further reference.&lt;/p&gt;

&lt;p&gt;We’ll start with an abstract image of the target pose, add Depth and Canny Edge ControlNets to our workflow, and specify in the prompt: &lt;em&gt;“man, mixed race, short curly hair, black hair, 40 years old, white T-shirt, black yoga pants, short sleeves, smiling, viewing glasses, white background, barefoot.”&lt;/em&gt; Essentially, I aim to generate an image resembling myself.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3gab0lxpdd4znj8n0tpl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3gab0lxpdd4znj8n0tpl.png" alt="Pose Transfer Workflow"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To ensure a realistic likeness, additional steps include incorporating the FaceID IP Adapter and the FaceDetailer post-processing model into the workflow. Refer to this &lt;a href="https://dev.to/worldlinetech/the-yoga-of-image-generation-part-3-5517"&gt;article&lt;/a&gt; for comprehensive guidance on implementing face transfer. The outcome preserves scannability and creates a QR code embedding the desired pose and identity:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fom9y6qblxw6npixsrl4i.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fom9y6qblxw6npixsrl4i.png" alt="Pose and Face Transfer"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Using QR Toolkit again, the comparison displays about 26 mismatch nodes, primarily around the facial features and body.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frg9a0ozszeet7h0huzee.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frg9a0ozszeet7h0huzee.png" alt="QR Toolkit Comparison"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Integrating Style and Content
&lt;/h2&gt;

&lt;p&gt;All previous steps can be combined by adding the iTools node to the final workflow:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3xi18981onenilcvxojs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3xi18981onenilcvxojs.png" alt="Combined Example Outputs"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Making the QR Code Animate
&lt;/h2&gt;

&lt;p&gt;Given that I can embed a face into the QR code, I can also animate facial expressions using specialized nodes. The &lt;a href="https://github.com/PowerHouseMan/ComfyUI-AdvancedLivePortrait" rel="noopener noreferrer"&gt;Advanced Live Portrait&lt;/a&gt; tool is designed for editing, inserting, and animating facial expressions in images. By inputting our generated QR code, we can animate my face to produce a smiling expression or nodding motion.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fft384rduzqeufd8f0lnc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fft384rduzqeufd8f0lnc.png" alt="Advanced Live Portrait"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The resulting animation can be exported as an animated GIF or video:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftpes98vmdcx08j3w5uts.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftpes98vmdcx08j3w5uts.gif" alt="Animated GIF"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;This short tutorial has demonstrated how to significantly enhance both the stylistic and content-related aspects of a QR code. You are now equipped to craft engaging, customized QR codes that align with your personal or branding style. &lt;/p&gt;

&lt;p&gt;The only limits are your patience and imagination, so have fun experimenting!&lt;/p&gt;

&lt;p&gt;  &lt;iframe src="https://www.youtube.com/embed/STYLfK_xeEo"&gt;
  &lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>comfyui</category>
      <category>stablediffusion</category>
      <category>qrcode</category>
      <category>genai</category>
    </item>
  </channel>
</rss>
