Nodes/Comfyui-PixNodes/ChatGLM4 Translate (PixNodes)
ComfyUI Node

ChatGLM4 Translate (PixNodes)

LLM translation that keeps your context

By pixixai·Created 8 months ago·Updated 6 months ago· 24
ChatGLM4 Translate (PixNodes)
    • translated_text
    api_key
    modelglm-4-flash
    from_language简体中文(zh-CN)
    to_language英文(en)
    text

    Baidu's translator is fast and free, but it translates sentence by sentence - no awareness that "it" was a character name three paragraphs ago, no sense of style. Pix_ChatGLM4Translate takes the other route: it hands your text to Zhipu's ChatGLM-4 model and asks it to translate, which buys context-aware, style-preserving output at the cost of needing a Zhipu (BigModel) API key. The default model is glm-4-flash, and that choice is deliberate - it's Zhipu's free-tier model, so the node can cost nothing if you stay on it.

    Inputs: api_key (Zhipu API key, saved to the pack's shared api_key.json after first use), model (glm-4-flash or glm-4-flash-250414), from_language and to_language dropdowns (zh-CN, zh-TW, en, ja, ko, fr, de, ru), and text, the multiline source. One output: translated_text. The API call goes to open.bigmodel.cn's chat completions endpoint with a temperature of 0.3 - low, so the model stays close to a literal translation rather than editorializing, which is the right setting for this job and a detail the author got right.

    The prompt that drives it is worth knowing because it defines the failure modes: it asks the model to translate strictly, preserve the original format, and output only the translation - no "here is your translated text:" preamble. That's the same "strip the LLM's conversational scaffolding" problem the KB's LLM essay calls out as the defining failure of chat-LLM-in-graph nodes, and this node is explicitly structured against it. You may still occasionally get a stray sentence of commentary, but it's the exception rather than the rule.

    Key handling matches the pack standard: enter the key once, it persists to ComfyUI/user/PixNodes/api_key.json, later runs can leave it blank. On a 401/403 auth failure the stored key is wiped - again, that's the pack's deliberate "don't keep failing with a dead credential" behavior. If translations suddenly return "API Key invalid," the key was cleared; re-enter a valid one.

    When to pick this over Pix_BaiduTranslateNode: when the text is long-form, narrative, or context-sensitive - captions that need to read naturally, prompt blocks where terminology consistency matters. For a quick "get this prompt into English" task, Baidu is faster and needs no key beyond the free one. Both are API nodes carrying a credential, so the usual security hygiene applies (keep the pack updated, don't install forks).

    Install is the standard PixNodes path - ComfyUI Manager, search PixNodes, restart - or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/pixixai/Comfyui-PixNodes
    cd Comfyui-PixNodes
    pip install -r requirements.txt
    

    then restart. Requirements are just openai and Requests; the node itself uses Requests directly. No models to download, no local VRAM cost - the translation happens on Zhipu's servers.

    One practical tip: because it's an LLM call, it's slower and can be rate-limited compared to the Baidu node, and long texts get expensive if you ever switch off the free glm-4-flash. Keep glm-4-flash selected and batch your translations, and this is a quietly excellent context-aware translator for the workflow.

    CategoryPixNodes/Translate

    Inputs (5)

    NameTypeDefaultDescription
    api_keySTRING
    modelCOMBOglm-4-flash2 options: glm-4-flash, glm-4-flash-250414
    from_languageCOMBO简体中文(zh-CN)8 options: 俄文(ru), 德文(de), 日文(ja), 法文(fr), 简体中文(zh-CN), 繁体中文(zh-TW), +2
    to_languageCOMBO英文(en)8 options: 俄文(ru), 德文(de), 日文(ja), 法文(fr), 简体中文(zh-CN), 繁体中文(zh-TW), +2
    textSTRING

    Outputs (1)

    NameTypeDescription
    translated_textSTRING