Nodes/ComfyUI-DataSet/DataSet_ClaudeAIChat
ComfyUI Node

DataSet_ClaudeAIChat

Ask Claude to Write or Rewrite Prompts, From Inside ComfyUI

By daxcay·Created 2 years ago·Updated 2 years ago· 58
DataSet_ClaudeAIChat
    • STRING
    modelclaude-3-5-sonnet-latest
    user_prompt
    max_tokens1024

    DataSet_ClaudeAIChat is a text-in, text-out node that calls the Anthropic Claude API from inside your workflow. Wire a prompt into it, and it hands back Claude's reply as a plain STRING you can feed into a prompt box, a caption, or another node. It's one of three API-backed chat nodes in the ComfyUI-DataSet pack - OpenAI and Groq are the other two - and it's the one you'd reach for if you're already paying for Claude and want richer, more "human" prompt drafting than the cheap models give you.

    The one thing that trips everyone up: there's no api key box

    Seriously, look at the node - there is no api_key input. This was a deliberate design change in the pack's Nov 2024 update: all the chat nodes now read their key from the environment, not from a widget. Claude specifically expects ANTHROPIC_API_KEY. Set it before you launch ComfyUI:

    export ANTHROPIC_API_KEY=sk-ant-...
    # or add it to your shell profile so it survives reboots
    

    Then restart ComfyUI. If you skip this, you don't get a friendly error - you get a STRING that starts with Error: because the node catches its own exceptions and returns them as output instead of failing the queue. That's a pattern you'll see everywhere in this pack, and it's the first thing to check when a chat node "returns nothing useful."

    Inputs and output

    • model - a dropdown with claude-3-5-sonnet-latest, claude-3-5-haiku-latest, and claude-3-opus-latest. Sonnet is the sensible default for captioning and prompt work; haiku if you're doing thousands of calls and want to spend less.
    • user_prompt - the actual instruction, multiline.
    • max_tokens - response length cap, default 1024.

    Output is a single STRING with Claude's reply. Note there's no system_prompt field - it exists in the source but is commented out, so the node sends your prompt as the sole user message. If you need a system persona, fold it into the prompt text: "You are a prompt engineer. Rewrite this as a detailed caption: ..." works fine.

    Why you'd use it

    For generating or normalizing training captions at scale - drop it in a loop over DataSet_TextFilesLoad, feed each caption in, pipe the result to DataSet_TextFilesSave. Or just use it as a smarter prompt generator than a wildcard node when you're stuck. It calls the Anthropic API per run, so each queue hit costs real money, but at these token lengths it's pennies.

    Install notes

    Same pack install as the rest of the DataSet suite:

    cd ComfyUI/custom_nodes
    git clone https://github.com/daxcay/ComfyUI-DataSet.git
    cd ComfyUI-DataSet && pip install -r requirements.txt
    

    The anthropic Python package comes from requirements.txt. Restart, set the env var, and you're set. And a tip from the author's other projects: Daxton Caylor (daxcay) is the same person behind ComfyUI-Nexus, the multiplayer-comfy thing that was all over r/comfyui in late 2024 - a legit community presence, though this DataSet pack is more of a niche toolkit than a blockbuster.

    Categorysd

    Inputs (3)

    NameTypeDefaultDescription
    modelCOMBOclaude-3-5-sonnet-latest3 options: claude-3-5-sonnet-latest, claude-3-5-haiku-latest, claude-3-opus-latest
    user_promptSTRING
    max_tokensINT1024

    Outputs (1)

    NameTypeDescription
    STRINGSTRING