Simple ComfyUI custom nodes for Ideogram 4 Magic Prompt and Ideogram 4 aspect-ratio resolution selection.
Get a free Ideogram API key here: Ideogram Manage API
Ideogram 4 can use a structured JSON prompt schema, but many people struggle to write that schema correctly, even when using a local LLM agent. This node pack was made to remove that friction.
The Magic Prompt API was available, free to use, and a good fit for ComfyUI workflows. Instead of spending local compute trying to generate valid Ideogram JSON prompts, this node sends your basic prompt to Ideogram's Magic Prompt API and returns the structured JSON prompt for you. It is especially helpful for users with less compute, or anyone who wants to avoid the hassle of hand-writing or debugging the JSON prompt schema.
This requires an Ideogram API key and an internet connection. Your API key, prompt, and selected aspect ratio are sent through Ideogram's API.
- Open ComfyUI Manager.
- Click Custom Nodes Manager.
- Search for
Ideogram 4 Prompterorideogram4_prompter-ComfyUI. - Click Install.
- Restart ComfyUI.
Clone this repo into ComfyUI/custom_nodes/:
cd ComfyUI/custom_nodes
git clone https://github.com/Saganaki22/ideogram4_prompter-ComfyUI.gitThen restart ComfyUI.
No extra Python packages are required.
Inputs:
api_key: Ideogram API key. Go to Ideogram Manage API, sign up for free, click Generate API key, then paste the generated key into the node. The key is sent as theApi-Keyheader.prompt: Text prompt to enhance.aspect_ratio: Native Ideogram 4 aspect ratio selector.AUTOis first, followed by the exact Ideogram 4 ratios:1x4,1x3,1x2,9x16,10x16,2x3,3x4,4x5,1x1,5x4,4x3,3x2,16x10,16x9,2x1,3x1, and4x1.seed: Cache buster only. Change it to rerun the same prompt for a different Magic Prompt output if the result is not to your liking. It is not sent to Ideogram and is not for reproducible results.
Outputs:
magic_prompt_json: The free Ideogram Magic Prompt API response, returned as formatted JSON in a ComfyUISTRING.aspect_ratio: The resolved Ideogram 4 aspect ratio as a combo output. If the input wasAUTO, this is the aspect ratio returned by Ideogram.
Inputs:
aspect_ratio: Ideogram 4 aspect ratio combo. You can connect this from theIdeogram 4 Magic Promptnode'saspect_ratiooutput.megapixels: Target total megapixels.
Outputs:
width: Calculated width, rounded to a multiple of 8.height: Calculated height, rounded to a multiple of 8.aspect_ratio_text: The selected Ideogram 4 aspect ratio as aSTRING, useful for text preview nodes.
- Add
Ideogram 4 Magic Prompt. - Paste your Ideogram API key into
api_key. - Enter your prompt in the multiline
promptfield. - Choose an aspect ratio, or leave it on
AUTO. - Change
seedwhen you want to force another Magic Prompt API call for the same prompt. - Connect
magic_prompt_jsonto a text preview node if you want to inspect the generated JSON. - Pass
magic_prompt_jsonas the prompt string for your Ideogram workflow or sampler. - Connect
Ideogram 4 Magic Prompt.aspect_ratiotoIdeogram 4 Resolution Selector.aspect_ratio. - Set
megapixelsonIdeogram 4 Resolution Selector. - Pass the selector's
widthandheightoutputs to your Ideogram sampler.
When AUTO is selected, Ideogram chooses the aspect ratio. The Magic Prompt node outputs that resolved ratio, and the Resolution Selector calculates pixel dimensions from it using your megapixels value.
The Magic Prompt node sends your prompt to Ideogram's free Magic Prompt API:
https://api.ideogram.ai/v1/ideogram-v4/magic-prompt
Ideogram returns a structured json_prompt and an aspect_ratio. The aspect_ratio is a top-level field in the API response, not a field inside json_prompt. This node outputs the prompt as a JSON string and outputs the resolved aspect ratio so it can drive the Ideogram 4 Resolution Selector.
If AUTO is selected and Ideogram does not return a top-level aspect_ratio, the node raises an error instead of silently guessing a resolution.
Because this uses Ideogram's hosted API, it needs network access to work. The tradeoff is that it saves local compute and avoids a lot of JSON schema hassle.
An example ComfyUI workflow is included: