BaiduTrans(DevApi)
Translate Chinese prompts to English before the text encoder chokes on them
- STRING
Most Stable Diffusion and Flux text encoders were trained almost entirely on English. Feed them Chinese and they mumble - garbled tokens, ignored words, or a prompt that only half survives. So if you think in Chinese, you translate to English first. That's the entire job of BaiduTrans(DevApi), and it's the honest way to do it: it calls Baidu's official translation API (fanyi-api.baidu.com), the same product businesses pay for, with a free tier of a million characters a month.
It's one of three translation nodes in the ComfyUI_BaiduTranslate pack by chflame163, the prolific Chinese dev behind the big dzNodes and LayerStyle utility packs. The other two are the no-key scraper BaiduTrans(v2Trans) and the newer all-in-one TextTranslate. This one is the "give it a real API key" option: reliable, quota'd, officially sanctioned instead of scraped. If you're going to translate a lot of prompts, this is the backend you want underneath you.
How it works
There's no model on your machine here. Pick a target language, and the node builds an MD5 "sign" from your appid, the source text, a random salt, and your secret key, then POSTs to http://api.fanyi.baidu.com/api/trans/vip/translate and reads back trans_result. Baidu's servers do the actual translating. The cost of that convenience is the standard API-node tradeoff: your prompt text leaves your machine and goes to Baidu. For a prompt that's fine; don't route anything sensitive through it.
The inputs that matter
Only two inputs, both required:
text- your Chinese or English prompt, multiline. You can paste whole paragraphs.Translate_to_language-enorzh.enis the one you'll use 90% of the time: Chinese in, clean English prompt out, ready for the CLIP/T5 encoder.
The single output is a plain STRING. Wire it straight into a CLIPTextEncode text port or any prompt-concatenation node. There's no built-in preview, so to eyeball the translation, chain a Preview Text node off the output - the author suggests the AlekPet pack, which has one.
Installing and adding your keys
ComfyUI Manager is the easy route: search "ComfyUI_BaiduTranslate", install, restart. Manually it's the usual dance:
cd ComfyUI/custom_nodes
git clone https://github.com/chflame163/ComfyUI_BaiduTranslate
cd ComfyUI_BaiduTranslate
pip install -r requirements.txt # just requests + pyexecjs
Then grab a free key at https://fanyi-api.baidu.com/ - register as a developer, enable the standard tier in the console, and you'll get an appid and a secret. Here's where the README and the code disagree, and the code wins: the README's old-node section tells you to edit baidu_devapi.json, but the shipped code only ever reads apikey.json. Put both values in that file:
{"baidu_dev_appid": "your_appid", "baidu_dev_appkey": "your_secret", "niutrans_apikey": "00000000000000000000000000000000"}
Restart ComfyUI and you're live. The console prints your key asterisk-masked (12*****34) so it won't leak into your logs in full.
Where people get burned
- The error message is in Chinese. When the API call fails, the node returns
百度翻译API错误!("Baidu translation API error"). If you see that, it's almost always a typo'd or empty key, or quota exhausted. The free tier is 1M chars/month - fine for prompts, easy to blow through if you feed it caption datasets. - This node is superseded. The author now ships
TextTranslate, which wraps this exact API plus two other backends, and says the old nodes "will no longer be updated." Starting fresh? Install the pack and reach forTextTranslateinstead. Reach for this one only if a saved workflow already references it and you don't want to touch the graph.
One light aside: it's mildly funny that the pack that exists to fix garbled Chinese prompts has its own README-in-Chinese-only moment where the docs and the code disagree about where your key lives. Trust the code: apikey.json, every time.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| text | STRING | — | |
| Translate_to_language | COMBO | en | 2 options: en, zh |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| STRING | STRING | — |