Nodes/ComfyUI-Jev/OpenRouter Text
ComfyUI Node

OpenRouter Text

The half of the Jev pack that writes the options

By hndrr·Created 5 days ago·Updated 4 days ago· 5
OpenRouter Text
    • text
    • response_json
    promptSuggest distinct photographic concepts for a perfume advertisement as English image generation prompts.
    system
    output_mode
    model
    api_key
    refresh0
    temperature0.70
    max_tokens2048

    What it is

    OpenRouter Text is the plain one in the Jev pack, and probably the first node you'll wire up. It's a chat completion from inside the graph: type a prompt, pick a model, get text back as a STRING you can connect to anything. No schema to write, no local model to load.

    Two things make it more than "another API node". The model list is pulled from OpenRouter's catalog when ComfyUI starts, so you're browsing real model IDs instead of guessing. And it has a candidates mode that generates complete alternative prompts as a clean array - exactly the input Jev Interpret's candidates_json wants.

    The two modes

    output_mode = text is a straight generation. Your prompt goes in as the user message (with system ahead of it if you filled it in), the model answers, you get text.

    output_mode = candidates sets a count (2–100, default 4) and gets back a JSON array of complete, standalone candidates. Under the hood the node appends its own system instruction demanding exactly N distinct candidates, each usable on its own, with no numbering or commentary - and it requests a strict JSON schema response with provider: {"require_parameters": true}, so OpenRouter only routes to providers that genuinely support Structured Outputs. Then it checks the work: the finish reason has to be stop, the array has to be exactly the length you asked for, and duplicates or empties are rejected. Truncated generations fail loudly instead of quietly handing you half a prompt.

    A chat model asked for "five prompt ideas" gives you 1. , **Option A:** and a preamble paragraph - all of which bleeds straight into your conditioning. Candidate mode doesn't have that failure mode, and line breaks survive inside each candidate, so a structured multi-line prompt isn't flattened.

    Inputs worth setting

    • prompt - the generation request. Accepts connections from Text or Format Text nodes, which is how you chain it after Jev Skill Choice.
    • system - optional instructions for the model. Wire Jev Skill Choice's text output here and the selected guidance frames the generation while prompt carries the ask.
    • output_mode - text or candidates; in candidates mode you also set count.
    • model - a text-in/text-out entry from the OpenRouter catalog, or custom to type an ID by hand. The catalog is fetched at startup with a ten-second timeout; if that fails, the node falls back to the last list it saved. Restarting ComfyUI refreshes it.
    • api_key - empty uses OPENROUTER_API_KEY, and that's the one you want. The environment variable is shared with Jev Interpret when it's set to the OpenRouter provider.
    • temperature (0.7) and max_tokens (2048, up to 131072) are the advanced knobs. Temperature is how much variety you get between candidates; max_tokens is your truncation budget.

    Outputs

    text is the payload - a STRING for any text input, or the candidates array into Jev Interpret's candidates_json. response_json is the raw API response with model name and token usage: the honest way to see what happened, and what it cost.

    Installing it

    It comes with the pack. Search ComfyUI-Jev in ComfyUI Manager and restart, or:

    cd /path/to/ComfyUI/custom_nodes
    git clone https://github.com/hndrr/ComfyUI-Jev.git
    

    ComfyUI 0.36.0+ and Python 3.10+. The pack's dependencies (aiohttp>=3.11.8, PyYAML) are already present in a normal ComfyUI install; if the node fails to import, install them into the environment ComfyUI runs in:

    python -m pip install "aiohttp>=3.11.8" PyYAML
    

    Then the key, set before you launch ComfyUI:

    export OPENROUTER_API_KEY="your-openrouter-key"
    
    $env:OPENROUTER_API_KEY="your-openrouter-key"
    

    Common issues

    • The model dropdown is empty. The startup fetch didn't happen - no network, an OpenRouter hiccup, or a fresh install with no cache. Enter the ID with custom and restart ComfyUI to retry.
    • "Generation did not finish normally." The model hit max_tokens and got cut off, and candidates are complete prompts - four of them is a lot of tokens. Raise max_tokens or lower count.
    • Candidates mode errors on your model. It requires Structured Outputs support, including for custom IDs. Plain text mode doesn't ask for the schema and works on far more models.
    • Your prompt came back with a preamble. That's text mode behaving like a chat model, because it is one. If boilerplate is getting into a conditioning path, use candidates mode and pick a clean one.
    • Re-running gives identical output. ComfyUI cached the node. Change refresh to regenerate; the sampler's seed or resolution won't do it.
    • The key is in the workflow. Anything typed into api_key is saved in the workflow JSON and the execution history - use the environment variable, or scrub the field before sharing. And this node's whole job is sending your prompt to someone else's server, so don't put anything private in it.
    CategoryJev

    Inputs (8)

    NameTypeDefaultDescription
    promptSTRINGSuggest distinct photographic concepts for a perfume advertisement as English image generation prompts.
    systemSTRINGOptional instructions for the text model.
    output_modeCOMBO2 options: [object Object], [object Object]
    modelCOMBOText models from the OpenRouter catalog, loaded when ComfyUI starts. Select custom to enter a model ID.
    api_keySTRINGEmpty uses OPENROUTER_API_KEY, shared with Jev Interpret using OpenRouter. Entered keys are saved in workflows.
    refreshINT0
    temperatureoptFLOAT0.700–2
    max_tokensoptINT20481–131072

    Outputs (2)

    NameTypeDescription
    textSTRING
    response_jsonSTRING