ModelScope-Text 文本生成节点
A real LLM inside ComfyUI, wired to your prompt
- response
Somewhere between "prompt here" and "image there," almost every ambitious ComfyUI workflow wants a brain: something that rewrites a vague idea into a strong prompt, expands a sentence into a scene, or translates a tag soup into clean natural language. Locally that means running a 7B model just for text duty. This node skips that - it's a chat-completion client for ModelScope's hosted inference, so you get DeepSeek-V3.1, Qwen3-Coder-480B, GLM-4.5, or step3 without a single local model file.
How it works
It works the way every OpenAI-SDK call works: you hand it a user_prompt and an optional system_prompt, it POSTs to https://api-inference.modelscope.cn/v1 as an OpenAI-compatible chat request, and returns the assistant's text as a STRING output named response. That string feeds directly into any prompt input in your graph - chain it into the ModelScope-Image node and you've built a text-to-prompt-to-image pipeline where the LLM does the prompting.
The inputs that matter
Inputs to care about:
- user_prompt and api_token (both required) - the token comes from modelscope.cn and auto-saves to
modelscope_config.jsonon first use, so later runs can leave it blank. - system_prompt - defaults to "You are a helpful assistant." This is the field that turns the node into a specialized tool. Set it to "You are a prompt engineer. Rewrite the user's idea as a detailed Stable Diffusion prompt." and the node becomes a prompt booster.
- model - a 17-entry dropdown. Default is
Qwen/Qwen3-Coder-480B-A35B-Instruct, which is a code model, a slightly odd default for prompt work - switch it todeepseek-ai/DeepSeek-V3.1or a Qwen3-Instruct variant unless you actually want code. The list comes from the config file, so it's editable. - max_tokens (100–8000, default 2000) and temperature (0.1–2.0, default 0.7) - standard. Crank temperature for creative prompt variation, keep it low for structured rewrites.
- stream (default true) - streams the response into the console as it arrives. Handy feedback during long generations; harmless to leave on.
- seed - here's the honest bit: this is largely placebo. The API doesn't accept a seed for chat completions; the code just seeds numpy's RNG before the call, which has no effect on the model's output. Treat it as a "make a different random-ish answer" button, not a reproducibility control.
The same "error as output" quirk from the rest of the pack applies: failures come back as the response text with "文本生成失败:" prefixed, and the real trace lands in the terminal. And the openai package is required - if it's missing, the node turns into a placeholder telling you to install it.
Installing it
Install the pack itself via ComfyUI Manager (search "ComfyUI ModelScope API Node") or:
cd ComfyUI/custom_nodes
git clone https://github.com/hujuying/ComfyUI-ModelScope-API
then restart ComfyUI.
The bottom line
Reach for this when you want prompt engineering inside the graph without babysitting a local LLM, or when you're on a machine that can't run a 7B comfortably alongside diffusion. Skip it if you already have a local LLM wired into your workflow - for pure prompt-rewriting, an 8B on your own GPU is faster than any round trip, and doesn't bill per call.
Inputs (8)
| Name | Type | Default | Description |
|---|---|---|---|
| user_prompt | STRING | 你好 | — |
| api_token | STRING | — | |
| system_promptopt | STRING | You are a helpful assistant. | — |
| modelopt | COMBO | Qwen/Qwen3-Coder-480B-A35B-Instruct | 17 options: Qwen/Qwen3-Coder-480B-A35B-Instruct, Qwen/Qwen3-Coder-480B-A35B-Chat, Qwen/Qwen3-235B-A22B-Thinking-2507, Qwen3-235B-A22B-Instruct-2507, Qwen/Qwen3-Coder-140B-A35B-Instruct, Qwen/Qwen3-Coder-70B-A35B-Instruct, +11 |
| max_tokensopt | INT | 2000100–8000 | — |
| temperatureopt | FLOAT | 0.70.1–2 | — |
| streamopt | BOOLEAN | true | — |
| seedopt | INT | -1-1–2147483647 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| response | STRING | — |