Nodes/geocine-comfyui/OpenAI Compatible LLM
ComfyUI Node

OpenAI Compatible LLM

Put a Chat Model Inside Your Graph

By geocine·Created 2 years ago·Updated 2 months ago· 1
OpenAI Compatible LLM
    • response
    prompt
    system_prompt
    api_key
    base_urlhttp://localhost:1234/v1
    modelgpt-4.1-mini
    temperature0.7
    max_tokens512

    The most genuinely modern thing in this pack is an LLM call. OpenAI Compatible LLM takes a prompt and a system prompt, calls any OpenAI-compatible chat endpoint, and hands the response back as a string inside your workflow. That's the missing piece for the prompt-automation loops everyone keeps building: write a rough idea, have a model turn it into a polished prompt, feed the result to the text encoder.

    The name is accurate and important: it's not locked to OpenAI. The base_url input defaults to http://localhost:1234/v1 - that's the default port for LM Studio - so out of the box it's built for a local model server, and it works just as well with Ollama's OpenAI-compatible endpoint, vLLM, OpenRouter, or OpenAI itself. Point it at whatever speaks the OpenAI wire protocol and it'll talk.

    How it works

    The Python is a straightforward client call:

    from openai import OpenAI
    client = OpenAI(base_url=base_url.strip(), api_key=(api_key or "").strip() or "not-needed")
    messages = [{"role": "system", "content": system_prompt}, {"role": "user", "content": prompt}]
    response = client.chat.completions.create(model=model, messages=messages,
                                              temperature=temperature, max_tokens=max_tokens)
    

    Two details worth knowing. First, the openai package is the pack's only pip dependency - the node imports it lazily and raises a clear "install openai" error if it's missing. Second, an empty api_key becomes the literal string "not-needed", because local servers like LM Studio ignore the key anyway. So for local use you can leave the key field blank and it just works; for real OpenAI you put your actual key in.

    Inputs and outputs

    The ones you'll actually set:

    • prompt - the user message. This is where your generation task or raw idea goes.
    • system_prompt - the instruction layer. This is where the "you are a prompt engineer, output only the prompt" behavior lives. Empty is fine if you don't need one.
    • base_url - the server's OpenAI-compatible root, default http://localhost:1234/v1.
    • model - the model name as your server reports it. "gpt-4.1-mini" is just the default; against LM Studio you need the exact name from its model list.
    • api_key - blank for local, required for hosted.
    • temperature (0–2, default 0.7) and max_tokens (default 512) - the usual dials.

    The output:

    • response - a plain STRING with the model's reply, ready for a preview node or a Text Replace to clean up.

    Install

    It ships in geocine-comfyui. Unlike the rest of the pack, this node has a real dependency - make sure openai is installed (the pack's install normally handles it):

    • ComfyUI Manager → search geocine-comfyui → install → restart
    • or Comfy CLI: comfy node install geocine-comfyui
    • or manually:
    cd ComfyUI/custom_nodes
    git clone https://github.com/geocine/geocine-comfyui
    python -m pip install openai
    

    then restart ComfyUI.

    Common issues

    "ModuleNotFoundError: openai" - install the package (above). "Connection refused" - your server isn't running or the base_url is wrong; LM Studio needs to be running with its local server enabled on port 1234. "model not found" - the model string must exactly match what the server exposes; check LM Studio's model dropdown rather than guessing. It's slow or blocks the graph - this is a synchronous call; the whole queue waits on the LLM. For a quick local 4B model that's a few seconds; for a hosted 100B it's a real pause, so plan the workflow around it. And note it re-runs every execution with no caching - deterministic-looking pipelines will change output if the model does, which is the point, but it means you can't freeze a result without saving it yourself. Pair it with Preview Text (format_json on) and a Text Replace to unwrap markdown, and it slots into a prompt pipeline cleanly.

    Categorygeocine/llm

    Inputs (7)

    NameTypeDefaultDescription
    promptSTRING
    system_promptSTRING
    api_keySTRING
    base_urlSTRINGhttp://localhost:1234/v1
    modelSTRINGgpt-4.1-mini
    temperatureFLOAT0.70–2
    max_tokensINT5121–32768

    Outputs (1)

    NameTypeDescription
    responseSTRING