Instructions to use saik0s/comfy_backup with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- llama-cpp-python
How to use saik0s/comfy_backup with llama-cpp-python:
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="saik0s/comfy_backup", filename="ComfyUI/models/text_encoders/gemma-3-12b-it-q2_k.gguf", )
llm.create_chat_completion( messages = "No input example has been defined for this model task." )
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use saik0s/comfy_backup with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf saik0s/comfy_backup:Q4_K_S # Run inference directly in the terminal: llama cli -hf saik0s/comfy_backup:Q4_K_S
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf saik0s/comfy_backup:Q4_K_S # Run inference directly in the terminal: llama cli -hf saik0s/comfy_backup:Q4_K_S
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf saik0s/comfy_backup:Q4_K_S # Run inference directly in the terminal: ./llama-cli -hf saik0s/comfy_backup:Q4_K_S
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf saik0s/comfy_backup:Q4_K_S # Run inference directly in the terminal: ./build/bin/llama-cli -hf saik0s/comfy_backup:Q4_K_S
Use Docker
docker model run hf.co/saik0s/comfy_backup:Q4_K_S
- LM Studio
- Jan
- Ollama
How to use saik0s/comfy_backup with Ollama:
ollama run hf.co/saik0s/comfy_backup:Q4_K_S
- Unsloth Studio
How to use saik0s/comfy_backup with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for saik0s/comfy_backup to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for saik0s/comfy_backup to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for saik0s/comfy_backup to start chatting
- Pi
How to use saik0s/comfy_backup with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf saik0s/comfy_backup:Q4_K_S
Configure the model in Pi
# Install Pi: npm install -g @mariozechner/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "llama-cpp": { "baseUrl": "http://localhost:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "saik0s/comfy_backup:Q4_K_S" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Hermes Agent new
How to use saik0s/comfy_backup with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf saik0s/comfy_backup:Q4_K_S
Configure Hermes
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:8080/v1 hermes config set model.default saik0s/comfy_backup:Q4_K_S
Run Hermes
hermes
- Atomic Chat new
- OpenClaw new
How to use saik0s/comfy_backup with OpenClaw:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf saik0s/comfy_backup:Q4_K_S
Configure OpenClaw
# Install OpenClaw: npm install -g openclaw@latest # Register the local server and set it as the default model: openclaw onboard --non-interactive --mode local \ --auth-choice custom-api-key \ --custom-base-url http://127.0.0.1:8080/v1 \ --custom-model-id "saik0s/comfy_backup:Q4_K_S" \ --custom-provider-id llama-cpp \ --custom-compatibility openai \ --custom-text-input \ --accept-risk \ --skip-health
Run OpenClaw
openclaw agent --local --agent main --message "Hello from Hugging Face"
- Docker Model Runner
How to use saik0s/comfy_backup with Docker Model Runner:
docker model run hf.co/saik0s/comfy_backup:Q4_K_S
- Lemonade
How to use saik0s/comfy_backup with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull saik0s/comfy_backup:Q4_K_S
Run and chat with the model
lemonade run user.comfy_backup-Q4_K_S
List all available models
lemonade list
ComfyUI OpenRouter Node
A custom node for ComfyUI that allows you to interact with OpenRouter's API, providing access to a wide range of models.
Updates
5/18/2026
Reasoning effort setting added. Make sure the model supports reasoning when using
5/9/2026 - Secure API Key Loading
You can now load your API key from a JSON config or env var instead of typing it into the node, which avoids leaking it in workflow metadata when sharing images.
- JSON config: put
{"api_key": "your_key_here"}inopenrouter_api_key.jsonin the node directory, leave the field blank - Env var: set
LLM_KEY, leave the field blank - UI field: still works if you don't share workflows
4/5/2026 - Seed, Resolution, Aspect Ratio, Temperature Fix
- Added seed input
- Added image_resolution dropdown (1K, 2K, 4K)
- Added aspect_ratio dropdown with all supported ratios, including Nano Banana 2 only extended ratios (1:4, 4:1, 1:8, 8:1)
- Fixed temperature slider
- 0.5K resolution (Nano Banana 2 only) not added - currently broken on OpenRouter's end, see this thread in the OpenRouter Discord
Multiple image inputs are supported. Make sure the model you are using supports multiple images to be sent at once. Thanks @wTechArtist for the idea!
9/5/2025 - Added image support for nano-banana and future image models
6/12/2025 - Chat Mode
Added a new Chat Mode feature that lets you store context to enable conversations with LLMs. When you enable chat mode, the node remembers your conversation history and maintains context between messages. Your chats are automatically saved in timestamped folders, so you can pick up where you left off if you come back within an hour. After that, it'll start a fresh conversation. Each chat session is stored as a JSON file with a friendly name based on your first message. Just toggle "chat_mode"
Features
- Access to all models available on OpenRouter
- Support for multiple image inputs (up to 10 images)
- NEW: Image generation support - Generate images with models like google/gemini-2.5-flash-image-preview (Nano-Banana)
- Dynamic image input visibility - additional inputs appear as you connect images
- PDF support with multiple OCR engine options
- Web search capability with
:onlinemodifier - Cheapest provider routing with
:floormodifier - Fastest provider routing with
:nitromodifier - Detailed statistics on token usage and generation speed
- Real-time OpenRouter account balance display
- Chat Mode - Maintain conversation context across multiple messages with automatic session management
Installation
- Clone this repository into your ComfyUI custom_nodes folder:
cd ComfyUI/custom_nodes
git clone https://github.com/gabe-init/ComfyUI-Openrouter_node
- Install the required dependencies:
pip install -r requirements.txt
- Restart ComfyUI
Usage
The OpenRouter node provides a simple interface to interact with various LLMs through the OpenRouter API.
API Key Security
Entering your API key directly into the node's input field in ComfyUI will embed it in the workflow metadata of every image you save. This is a security risk if you share your images.
To keep your API key secure, use one of the following methods:
JSON Config File (Recommended):
- Create a file named
openrouter_api_key.jsonin the node directory. - Add your key like this:
{"api_key": "your_key_here"}. - Leave the api_key field blank in the ComfyUI interface.
- Create a file named
Environment Variable:
- Set an environment variable named
LLM_KEYon your system. - The node will automatically pick it up if the UI field is empty.
- Set an environment variable named
If you've ever typed your key into the api_key field, clear it before saving the workflow — the value is stored in the workflow JSON. On Linux/macOS, restrict the JSON config with
chmod 600 openrouter_api_key.jsonso only your user can read it.
Inputs
Required Inputs:
- api_key: Your OpenRouter API key. Can be left blank if provided via
openrouter_api_key.jsonorLLM_KEYenvironment variable. - system_prompt: The system prompt that sets the behavior of the LLM.
- user_message_box: The user message to send to the LLM.
- model: The model to use for generation. The node automatically fetches the list of available models from OpenRouter.
- web_search: Enable web search capability by appending
:onlineto the model ID. This costs $4 per 1000 queries and automatically uses your openrouter balance. - cheapest: Route to the cheapest provider by appending
:floorto the model ID (enabled by default). - fastest: Route to the fastest provider by appending
:nitroto the model ID (disabled by default). - temperature: Controls the randomness of the model's output (0.0 to 2.0).
- reasoning_effort: Controls OpenRouter's unified reasoning parameter.
autosends no override and lets OpenRouter/model defaults apply.noneexplicitly disables reasoning.minimal,low,medium,high, andxhighrequest increasing reasoning effort where the selected model supports it. - chat_mode: Enable conversation mode to maintain context across messages (disabled by default).
- request_timeout: Maximum time, in seconds, to wait for the main OpenRouter completion request before returning an error (default: 120).
OpenRouter normalizes reasoning across providers, but behavior still depends on the selected model. Some providers map effort levels to token budgets, Gemini 3 maps effort to Google's thinking levels,
xhighmay be mapped down when unsupported, and some reasoning models do not return visible reasoning tokens.
Optional Inputs:
- image_1 through image_10: Multiple image inputs for multimodal models. The first image input (image_1) is always visible. Additional image inputs automatically appear as you connect images (up to 10 total).
- pdf_data: PDF document input for models that support document understanding.
- pdf_engine: Choose between "auto", "mistral-ocr", or "pdf-text" for PDF processing.
- user_message_input: Alternative input for the user message, useful for connecting to other nodes.
Outputs:
- Output: The text response from the LLM.
- image: An image tensor if the response contains a generated image, otherwise returns an empty tensor.
- Stats: A string detailing tokens per second, input tokens, output tokens, temperature, and the model used.
- Credits: A string showing your remaining OpenRouter account balance (e.g., "Remaining: $9.792").
Note: To display the output text in ComfyUI, you can use the ShowText nodes from ComfyUI-Custom-Scripts, but any text display node will work.
Examples
Basic Text Generation
- Add the OpenRouter node to your workflow
- Provide your API key (see API Key Security)
- Set a system prompt (e.g., "You are a helpful assistant.")
- Enter a user message (e.g., "Explain quantum computing in simple terms.")
- Select a model (e.g., "openai/gpt-4")
- Run the workflow
Image Understanding
- Add the OpenRouter node to your workflow
- Connect an image output from another node to the "image_1" input
- Provide your API key (see API Key Security)
- Set a system prompt (e.g., "You are a helpful assistant.")
- Enter a user message (e.g., "Describe this image in detail.")
- Select a multimodal model (e.g., "openai/gpt-4-vision" or "anthropic/claude-3-opus-20240229")
- Run the workflow
Multiple Image Analysis
- Connect your first image to "image_1"
- As soon as you connect it, "image_2" will automatically appear
- Connect additional images as needed (up to 6 total)
- Unused image inputs will automatically hide when disconnected
- Enter a prompt that references multiple images (e.g., "Compare these images and describe the differences.")
- Select a multimodal model that supports multiple images
- Run the workflow
Note: The user is responsible for checking if their selected model supports multiple images. Most modern multimodal models (4o, Gemini Flash, etc.) support multiple images in a single request.
Image Generation
- Add the OpenRouter node to your workflow
- Provide your API key (see API Key Security)
- Set a system prompt (e.g., "You are a helpful assistant.")
- Enter a user message with generation keywords (e.g., "Generate a beautiful sunset over mountains", "Create an image of a futuristic city", "Draw a cat wearing a hat")
- Select an image-capable model (e.g., "google/gemini-2.5-flash-image-preview" - also known as Nano-Banana)
- Run the workflow
- The generated image will appear in the "image" output, which you can connect to preview nodes or other image processing nodes
Note: The node automatically detects image generation requests based on keywords like "generate", "create", "draw", "make", "produce", "design", "render", "image of", "picture of", "photo of". For image generation, use models that support image output modalities.
Chat Mode
The Chat Mode feature allows you to maintain conversation context across multiple messages, enabling more natural and coherent conversations with the LLM.
How Chat Mode Works:
- Enable Chat Mode: Toggle the "chat_mode" option to True
- Automatic Session Management:
- Sessions are automatically created when you start a conversation
- If you send another message within 1 hour, it continues the same session
- After 1 hour of inactivity, a new session is created
- Session Storage:
- Conversations are stored in a
chatsfolder within the node directory - Each session is saved with a timestamp and the first 5 words of your initial message
- Format:
session_YYYYMMDD_HHMMSS_first_five_words
- Conversations are stored in a
- Context Preservation: The entire conversation history is sent with each request, allowing the model to maintain context
Chat Mode Example:
- Enable chat_mode in the node
- First message: "Hello, my name is Alice"
- Response: "Hello Alice! Nice to meet you. How can I help you today?"
- Second message: "What's my name?"
- Response: "Your name is Alice, as you mentioned earlier."
The conversation history is automatically managed and persisted between runs.
Managing Chat Sessions:
A utility script manage_chats.py is included to help you manage your chat sessions:
# List all chat sessions
python manage_chats.py list
# View a specific session
python manage_chats.py view session_20241206_143022_hello_how_are_you_today
# Export a session to different formats (json, txt, md)
python manage_chats.py export session_20241206_143022_hello_how_are_you_today -f md -o my_chat.md
# Clean up sessions older than 30 days
python manage_chats.py clean -d 30
Routing Options
- For cost-effective responses, enable the "cheapest" option (on by default)
- For faster responses, disable "cheapest" and enable "fastest"
- For web search capability, enable "web_search"
Troubleshooting
- Model list not loading: Check your internet connection and OpenRouter API key.
- Error in response: Check the error message in the output. It might be due to an invalid API key, model unavailability, or other API issues.
- Slow responses: Try using the
:nitromodifier by enabling the "fastest" option. - Token counting issues: The node uses tiktoken for accurate token counting, but falls back to an estimation method if there's an issue.
License
MIT License
Copyright (c) 2024
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

