Nodes/ComfyUI_MieNodes/Set OpenRouter LLM Service Connector ๐Ÿ‘
ComfyUI Node

Set OpenRouter LLM Service Connector ๐Ÿ‘

One key, 400+ models, and the whole pack's cheapest experiment

By MieMieeeeeยทCreated 2 years agoยทUpdated 3 days agoยท 273
Set OpenRouter LLM Service Connector ๐Ÿ‘
    • llm_service_connector
    โ—„api_tokenโ–บ
    โ—„model_selectopenrouter/autoโ–บ
    โ—„custom_modelโ–บ
    โ—„config_filemie_llm_keys.jsonโ–บ
    โ—„config_keyopenrouterโ–บ
    โ—„prefer_local_configtrueโ–บ

    What it is

    If you're going to wire one LLM connector into your graph and not think about it again, make it this one. OpenRouter is an aggregator: one API key, one endpoint, and you address every vendor's models by <vendor>/<model> slug. That means the question "should the rewrite be Claude or Grok or GLM?" stops being an install decision and becomes a dropdown change on the same node.

    The aggregator pattern is already how a slice of this ecosystem handles the "no local GPU, or a free tier is cheaper than my own electricity" problem - the KB's API-node survey has OpenRouter sitting next to Together AI for free-tier routing. Same idea here, applied to text nodes instead of image models.

    How it works

    It's a standard OpenAI-compatible connector pointed at https://openrouter.ai/api/v1/chat/completions, so it sends the normal parameter set - temperature, top_p, top_k, penalties, n, max_tokens - and the model id is whatever slug you picked. Retries and timeouts come from the shared base class: 30 seconds per request, three attempts five seconds apart on timeouts, connection errors and 5xx. Reasoning-model <think> blocks get stripped from replies before they reach your downstream node.

    The one behavior to understand before you trust it: this node chooses provider and model, nothing else. openrouter/auto (the default) makes OpenRouter pick a model for you based on the request. That's great for a first smoke test with a fresh key, and bad for anything you want to reproduce - your prompt style is model-specific, and auto can route different calls to different models. Pick a concrete slug once you know what you like.

    Inputs and output

    api_token - an sk-or-... key.

    model_select - defaults to openrouter/auto. The verified cross-vendor selection in the dropdown is openai/gpt-6-astra, anthropic/claude-opus-5.5, google/gemini-3.8-flash, x-ai/grok-4.7, deepseek/deepseek-v4-pro, z-ai/glm-5.3, moonshotai/kimi-k3, qwen/qwen3.5-397b-a17b, minimax/minimax-m3, mistralai/mistral-large-2512, plus Custom.

    custom_model - for any other slug, including the :free variants OpenRouter publishes for some models. That's the cheapest way to try a workflow end-to-end without spending anything; just don't ship a production graph on a free tier, because those endpoints' availability and rate limits are whatever they feel like that week.

    config_file, config_key (default openrouter), prefer_local_config. Output: llm_service_connector.

    Installing and using it

    cd ComfyUI/custom_nodes
    git clone https://github.com/MieMieeeee/ComfyUI-MieNodes
    cd ComfyUI-MieNodes && python -m pip install -r requirements.txt
    

    Restart. Manager: search ComfyUI_MieNodes. No model downloads, no heavy dependencies.

    cp mie_llm_keys.json.example mie_llm_keys.json
    # "openrouter": "sk-or-..."
    

    Then wire the output into CallLLMService, Translator, PromptGenerator, or any of the pack's task-specific generators. Do yourself a favor and put CheckLLMServiceConnectivity on the output first - it fires one request and shows the HTTP status and reply head, which is how you catch a bad key or a slug that doesn't exist without running a whole graph.

    Remember the pack's shared rule: prefer_local_config defaults to True, so the openrouter entry in the JSON file beats the api_token box on the node. Type a key into the node, leave a stale one in the file, get a 401 - that's the order of events.

    Common issues

    Slug not found. Vendor slugs change (vendor/model, sometimes with a version tail). Custom plus the exact id from OpenRouter's model list beats guessing.

    A model that worked yesterday 404s today. Aggregators re-route upstream. This is the cost of the model-per-dropdown convenience - pin what works and be ready to move. If a graph matters, note the slug you shipped with.

    Slow first call, then fine. Some upstream providers cold-start a model on the first request. The base class retries three times, but a 30-second timeout can be tight on a cold frontier model. A second run usually sorts it out.

    Category๐Ÿ‘ MieNodes/๐Ÿ‘ LLM Service Config

    Inputs (6)

    NameTypeDefaultDescription
    api_tokenSTRINGโ€”
    model_selectCOMBOopenrouter/auto12 options: openrouter/auto, openai/gpt-6-astra, anthropic/claude-opus-5.5, google/gemini-3.8-flash, x-ai/grok-4.7, deepseek/deepseek-v4-pro, +6
    custom_modeloptSTRINGโ€”
    config_fileoptSTRINGmie_llm_keys.jsonโ€”
    config_keyoptSTRINGopenrouterโ€”
    prefer_local_configoptBOOLEANtrueโ€”

    Outputs (1)

    NameTypeDescription
    llm_service_connectorLLMServiceConnectorโ€”