Nodes/SDXL Auto Prompter/APNext Claude Text Generator
ComfyUI Node

APNext Claude Text Generator

Turn a lazy one-liner into a full prompt with Claude

By dagthomas·Created 3 years ago·Updated 17 days ago· 285
APNext Claude Text Generator
    • STRING
    input_text
    happy_talktrue
    compressfalse
    compression_level
    posterfalse
    claude_modelclaude-3-5-sonnet-20241022
    seed-1
    randomize_each_runtrue
    custom_base_prompt
    custom_title
    override
    variation_instructionGenerate different creative variations each time while maintaining the core concept.

    You type "a knight fighting a dragon." Claude hands back a paragraph with lighting, composition, atmosphere and camera language baked in. That's ClaudeTextNode - a prompt-expander that runs Anthropic's Claude models inside your ComfyUI graph, part of dagthomas's multi-provider LLM tooling. It's the text-only sibling of the vision node: no image in, just your rough idea out to Claude and a fleshed-out prompt back.

    This is one of the most-requested workflows in the whole ComfyUI world right now - people constantly ask for an "auto prompter" that takes a short idea and returns a detailed, well-structured prompt, and having an LLM write your prompt is a genuinely good idea on modern models. If your image model's text encoder is itself an LLM (Flux 2, Z-Image, Qwen), then having Claude write the instruction is a translation between two things that speak the same language. The catch, and it's a real one: this calls Anthropic's paid API, so every run costs money and needs a key.

    How it works

    The node sends your input_text to Claude with a system prompt that turns it into an image prompt, and returns the result as a string. The tone and shape are yours to control: happy_talk flips between an enthusiastic, flowery style and a terse professional one; compress (with compression_level soft/medium/hard) squeezes the output shorter when Claude gets too verbose; poster formats it as movie-poster-style copy. For batch work, variation_instruction plus randomize_each_run and a seed push Claude to give a different creative take each run instead of the same paragraph.

    The inputs and outputs that matter

    • input_text - your rough idea. This is the seed of everything.
    • claude_model - the model dropdown (Sonnet and Haiku tiers). Haiku is cheaper and faster for straightforward expansion; Sonnet is smarter for nuanced scenes.
    • compress + compression_level - your defense against overlong output. The KB is clear that past ~75–100 effective tokens most image models start to drift, so medium/hard compression is often the right call.
    • variation_instruction (optional) + randomize_each_run - the batch-variety controls.
    • Optional custom_base_prompt / override let you replace the built-in system prompt with your own.

    The single output is STRING, into a CLIP Text Encode (or a preview node so you can read what Claude wrote before committing).

    How to install it

    ComfyUI Manager: search comfyui_dagthomas, install, restart. Manual:

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

    then restart. This node needs the anthropic library (in the pack's requirements.txt) and an API key. Set ANTHROPIC_API_KEY (or CLAUDE_API_KEY) as an environment variable before launching ComfyUI - the node reads it from the environment at startup, so setting it afterward won't take.

    Where people get burned

    • No key, no output. The most common failure is a missing or unexported ANTHROPIC_API_KEY. Set it in the environment before you start ComfyUI, not in a .env the node doesn't read.
    • Hosted ComfyUI can't do this. On a serverless or shared cloud instance you usually can't set arbitrary env vars or make outbound API calls, so the cloud-LLM nodes are really a local-install feature. The pack's offline nodes (the category builders, the random file reader) are what work everywhere.
    • The model list runs ahead of reality. The dropdown lists model names that your specific key may not have access to yet; an unavailable name throws an API error at runtime. The list is just an editable JSON file (data/claude_models.json) - trim it to what your account can actually call.
    • Let it ramble and you lose quality. Claude writes lovely prose; your image model wants concise, concrete concepts. Compress it, or you're feeding the encoder a short story.
    Categorycomfyui_dagthomas/LLM

    Inputs (12)

    NameTypeDefaultDescription
    input_textSTRING
    happy_talkBOOLEANtrue
    compressBOOLEANfalse
    compression_levelCOMBO3 options: soft, medium, hard
    posterBOOLEANfalse
    claude_modelCOMBOclaude-3-5-sonnet-202410227 options: claude-sonnet-4.5, claude-sonnet-4, claude-sonnet-3.7, claude-opus-4.1, claude-opus-4, claude-haiku-3.5, +1
    seedINT-1-1–18446744073709550000
    randomize_each_runBOOLEANtrue
    custom_base_promptoptSTRING
    custom_titleoptSTRING
    overrideoptSTRING
    variation_instructionoptSTRINGGenerate different creative variations each time while maintaining the core concept.

    Outputs (1)

    NameTypeDescription
    STRINGSTRING