Nodes/ComfyUI_ChatGLM_API/ZhipuaiApi_Character
ComfyUI Node

ZhipuaiApi_Character

Character roleplay with Zhipu's charglm-3 — the oddest node in the pack

By smthemex·Created 2 years ago·Updated 2 years ago· 25
ZhipuaiApi_Character
    • text
    bot_name苏梦远
    user_name陆星辰
    user_info我是陆星辰,是一个男性,是一位知名编剧,苏梦远是我在剧中创作的虚拟二次元角色。她是一位白发傲娇猫娘,并视我为好朋友。
    bot_info苏梦远,本名苏喵喵,是一位虚拟的二次元白发傲娇猫娘,她爱吃小鱼干,喜欢温暖的地方,喜欢打滚,讨厌游泳。
    assistant_prompt陆星辰,我希望下一个剧本,我能变身美少女战士,喵。
    user_prompt苏梦远,你本来就是美少女,但不是战士而已。

    Every now and then a custom node shows up that makes you do a double-take, and this is it: an AI-roleplay chatbot node, shipped inside a ComfyUI API pack. ZhipuaiApi_Character builds a character card, sends it to Zhipu's charglm-3 model, and returns the character's in-character reply. Out of the box it's configured as a Chinese tsundere catgirl named 苏梦远 - a white-haired catgirl who loves dried fish and hates swimming - written by a playwright, presumably starring in one of his scripts. It's weird, it's charming, and it's a perfect demo of how far "an LLM node in ComfyUI" can go.

    How it works

    Raw HTTP to Zhipu's roleplay endpoint (/api/paas/v3/model-api/charglm-3/invoke) with your API key as a short-lived JWT. The request carries a meta block - bot name, user name, and free-text info strings for both sides - plus a prompt made of one assistant turn (the bot's opening line) and one user turn (your reply). The API returns the bot's next in-character response, and the node strips quotes and newlines before handing it back.

    The inputs that matter

    All five are simple strings, and the defaults are a working example you can just hit "queue" on:

    • bot_name / user_name - the character's name and yours.
    • bot_info / user_info - the persona cards. Multiline, and this is where the personality lives: write the character's backstory, quirks, and speech patterns here. The defaults show the format well.
    • assistant_prompt / user_prompt - the two turns that start the conversation. In the default, the playwright asks to become a magical girl in the next script and the catgirl reminds him he's not one. The reply comes back as your scene's next line.

    Output: a single STRING named text. Realistically you'll wire it to a show-text or preview node to read it - it's a roleplay node, not a conditioning feeder. But nothing stops you from plumbing the reply into a prompt and generating a portrait of the scene, which is presumably the ComfyUI-flavored endgame.

    Installing it (and the key)

    cd ComfyUI/custom_nodes
    git clone https://github.com/smthemex/ComfyUI_ChatGLM_API
    

    Restart, then add a Zhipu API key from open.bigmodel.cn to the pack's config.json:

    {
      "Zpai_API_KEY": "your key"
    }
    

    That's ComfyUI/custom_nodes/ComfyUI_ChatGLM_API/config.json, auto-created with a placeholder if missing. This is a paid API call, though charglm-3 is priced as a cheap model in Zhipu's lineup and new accounts start with free tokens.

    Common issues

    • "API key is required" - the placeholder is still in config.json. This is the #1 failure for every cloud node in the pack.
    • NSFW gets your account banned. The README's warning applies here with extra force - character roleplay is exactly the kind of thing that drifts into content Zhipu filters under Chinese law. Keep the scenes PG and you're fine.
    • The reply can arrive oddly formatted - the node strips quotes and \n, so multiline roleplay occasionally comes back squished into one line. Cosmetic, not fatal.

    It's a novelty node, and it knows it - the defaults are a self-aware joke about a playwright writing a catgirl into his own script. If you want to prototype a character voice, test an NPC's personality, or just amuse yourself between render batches, it works out of the box. If you need serious multi-turn roleplay, you'd want a proper character-chat stack instead; this is the ComfyUI-shaped toy version.

    CategoryChatGlm_Api

    Inputs (6)

    NameTypeDefaultDescription
    bot_nameSTRING苏梦远
    user_nameSTRING陆星辰
    user_infoSTRING我是陆星辰,是一个男性,是一位知名编剧,苏梦远是我在剧中创作的虚拟二次元角色。她是一位白发傲娇猫娘,并视我为好朋友。
    bot_infoSTRING苏梦远,本名苏喵喵,是一位虚拟的二次元白发傲娇猫娘,她爱吃小鱼干,喜欢温暖的地方,喜欢打滚,讨厌游泳。
    assistant_promptSTRING陆星辰,我希望下一个剧本,我能变身美少女战士,喵。
    user_promptSTRING苏梦远,你本来就是美少女,但不是战士而已。

    Outputs (1)

    NameTypeDescription
    textSTRING