OpenAI API - Options
Every Dial on Your API Call, Behind a Switch — and Why Sending Nothing Is the Default
- other_options
- Options
You're running this pack for one of two jobs: rewriting a rough idea into a structured prompt, or describing an image so you can caption a LoRA set or seed an img2img run. Both live or die on the sampling settings - this node is where you set them.
First thing to know: it sends nothing by default. Every numeric setting sits behind its own Use … boolean, and they all start off. A fresh Options node wired into a request is, on the wire, identical to no Options node at all - your provider's defaults, whatever they are. That's deliberate - local engines and OpenAI disagree about sane numbers - but don't mistake it for broken.
What it does
Options builds one flat dictionary, output as the pack's custom OAIAPI_OPTIONS type, which you wire into the Options input of Chat Completion or Batched Chat Completion. (Batched takes one set for all of them.)
At request time, six keys get pulled out as real arguments - seed, temperature, max_tokens, top_p, frequency_penalty, presence_penalty - and everything left over is forwarded as the request's extra_body - so any key you invent rides straight into the body.
Merge rules: later wins, so chain a second Options node into the first one's Options input and the closer node's switched-on settings override it (upstream payloads are copied, not mutated); and Extra Body beats everything, since it's applied last - {"temperature": 0.9} overrides a switched-on 0.7 in the same node.
Instructions Role is the odd one out - no Use switch, always sent. Off (system) is the default; on (developer) is what OpenAI's reasoning-era models expect. System prompt being ignored on o1-and-newer? That switch.
The settings worth touching
- Temperature - for rewriting and captioning, keep it low: 0.2 to 0.6. The 1.0 default is a chat model's idea of a good time, and an enhancer that invents subjects you never mentioned isn't helping.
- Max Tokens (default 512) - cap it. A rambler pads your conditioning, and you're paying per token for it. With the switch off, no limit goes out, so a local model runs to its context wall. The widget's 1,000,000 ceiling is deliberate: ComfyUI would otherwise clamp you to its own 2048 default.
- Top P - nucleus sampling, and the tooltip is honest that it's an alternative to temperature. Pick one. 0.9–0.95, not 0.1.
- Frequency / Presence Penalty - the "why does my enhancer keep repeating that phrase" knobs. Small positives, 0.1–0.5.
- Seed - the source still sends
seedbut flags it deprecated, and reproducibility is best-effort on hosted endpoints; local llama.cpp/vLLM servers honour it more literally.
Extra Body
The node's placeholder tells you the point: {"repetition_penalty": 1.1} - a vLLM/llama.cpp parameter OpenAI has no concept of. No widget for it, so it goes here and rides through extra_body into the JSON body. Same trick for top_k, min_p, or max_completion_tokens when your backend wants the newer name.
It must be a valid JSON object - the node checks it at load time (or when a connected value resolves) and fails loudly with extra body is not a valid JSON: …. Single quotes and trailing commas aren't JSON, and a bare number or string is rejected outright.
Install
cd /path/to/ComfyUI/custom_nodes
git clone https://github.com/lany42/comfyui-openai-api.git
cd comfyui-openai-api
/path/to/ComfyUI/.venv/bin/python -m pip install -r requirements.txt
# restart ComfyUI
Dependencies are light - openai>=2.7.1, numpy, Pillow - which is why people pick this pack over fatter API nodes. The canonical repo is at git.colorized.life; GitHub is the mirror. Or search comfyui-openai-api in ComfyUI Manager (publisher Comfpod OpenAI API). No model downloads, either. It targets Python 3.13 and ComfyUI's newer V3 node API, so on an old install the nodes may not register at all.
Where people get burned
"I set temperature and nothing changed." The Use Temperature switch is off. The most common confusion with this node, and it's by design.
Red "missing node type" boxes in an imported workflow. This fork renamed everything to the Comfpod_OpenAPI_ prefix and registers no aliases for the upstream OAIAPI_* IDs - those class_type values need editing by hand. Worse, the upstream single-purpose nodes (Seed, Temperature, Max Tokens, Top P, both penalties, Developer Role, Extra Body) are gone; collapse each chain into one Options node.
A 400 from a strict endpoint. Unknown Extra Body keys get merged into the body, and some servers reject unknown fields. If a local engine only errors when Extra Body is filled in, it's the key, not the node.
One more thing: a local OpenAI-compatible server puts your LLM and your diffusion model in a fight over the same VRAM, which is why plenty of people run the LLM on a second box - and why the settings that matter there, repetition_penalty and top_k, both live in Extra Body.
Inputs (15)
| Name | Type | Default | Description |
|---|---|---|---|
| use_seed | BOOLEAN | false | Send the seed for reproducible results. When off, the seed is not sent. |
| seed | INT | 42 | Repeated requests with the same seed and parameters will return the same result |
| use_temperature | BOOLEAN | false | Send the temperature, which controls the randomness of the generated text: lower values are more deterministic, higher values more varied. When off, the temperature is not sent. |
| temperature | FLOAT | 1.00–2 | Number between 0.0 and 2.0. Defaults to 1.0. |
| use_max_tokens | BOOLEAN | false | Send the maximum number of tokens that can be generated in the response. When off, the limit is not sent. |
| max_tokens | INT | 5121–1000000 | An upper bound for the number of tokens that can be generated for a response |
| use_top_p | BOOLEAN | false | Send top P for nucleus sampling, an alternative to sampling with temperature where the model considers the tokens with top_p probability mass. When off, top P is not sent. |
| top_p | FLOAT | 1.000–1 | 0.1 means only the tokens comprising the top 10% probability mass are considered |
| use_frequency_penalty | BOOLEAN | false | Send the frequency penalty. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim. When off, the penalty is not sent. |
| frequency_penalty | FLOAT | 0.0-2–2 | Number between -2.0 and 2.0 |
| use_presence_penalty | BOOLEAN | false | Send the presence penalty. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics. When off, the penalty is not sent. |
| presence_penalty | FLOAT | 0.0-2–2 | Number between -2.0 and 2.0 |
| instructions_role | BOOLEAN | false | Set this switch to true to set the instructions prompt role as 'developer' instead of 'system'. With o1 models and newer, OpenAI has changed the 'system' prompt role to 'developer'. |
| extra_body | STRING | A JSON object of extra body parameters to include in the request, overriding the named settings. Leave empty to add none. | |
| other_optionsopt | OAIAPI_OPTIONS | Others options to merge with |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| Options | OAIAPI_OPTIONS | Merged options to forward |