ModifyModelKwargs
ModifyModelKwargs tweaks your model call
- model
- kwargs
- Litellm model
Picking the model is only half the setup. The other half is the per-call settings - temperature, max tokens, top_p, and the rest - and that's where ModifyModelKwargs comes in. It sits between your model provider and your completion node, letting you inject or override those settings on a LITELLM_MODEL as it flows through the graph.
Think of the LITELLM_MODEL value as a little envelope that carries both "which model" and "what settings." This node is how you stuff extra settings into that envelope without hand-editing JSON inside the completion node.
How it works
Three inputs, one real output:
- model (required,
LITELLM_MODEL) - the envelope you're modifying, straight fromLiteLLMModelProvider. - kwargs (optional,
DICT) - a dict of settings, if another node hands you one. - json_str_of_kwargs (optional,
STRING, multiline, default{}) - the same settings as a JSON string, which is the format you'll actually type most of the time.
The output Litellm model (LITELLM_MODEL) is your modified envelope, ready for a completion node.
Mechanically: if json_str_of_kwargs isn't "{}", it's parsed as JSON and replaces the kwargs input entirely (the JSON wins - keep that in mind if both are connected). The merged settings land in the model's kwargs, and there's a small bonus: if logit_bias is passed as a list of (token_id, bias) pairs, it's converted to the dict format the OpenAI-style APIs expect.
So, concretely:
LiteLLMModelProvider → ModifyModelKwargs (json_str_of_kwargs: {"temperature": 0.7, "max_tokens": 512}) → LiteLLMCompletion
What you'd actually set
temperature- lower for predictable caption/structured output, higher for creative writing.max_tokens- cap the reply length.top_p,frequency_penalty,presence_penalty- the usual LLM sampler dials, passed through to whatever provider the model string names.
Which keys are honored depends on the provider behind the model - Anthropic and OpenAI accept slightly different sets, and LiteLLM does its best to translate. Unknown keys generally get ignored or warn rather than hard-fail, but don't assume a key works everywhere.
Where people trip
- The JSON wins. Wire both inputs and the string silently overrides the dict. If your settings aren't taking effect, check whether
json_str_of_kwargsis still holding a default you forgot about. - Default
{}isn't "empty" in the override check. The node checks whether the string equals"{}"exactly. Set it to{}with whitespace ({ }) or a trailing newline and it counts as a real value that wipes yourkwargsdict. Minor, but it's bitten people. - Order matters for chaining. You can daisy-chain multiple
ModifyModelKwargsnodes to override specific settings per branch - later ones in the chain update the samekwargsdict. Handy for fan-out workflows where one branch wants temperature 0 and another wants 1.2.
Installing
Pack-level install as always: ComfyUI Manager → search "LiteLLM" (repo Hopping-Mad-Games/ComfyUI_LiteLLM) → Install → Restart, or clone into ComfyUI/custom_nodes and pip install -r requirements.txt. The requirements pull in litellm, boto3, sentence-transformers and a LightRAG fork, so expect a heavy first install. No API keys needed here - the keys are consumed downstream by the completion node.
Bottom line
It's the "settings node" the pack needs because the model envelope is otherwise opaque. If you're the kind of person who tweaks temperature per workflow, this is where you'll live. Just remember the JSON-wins rule and the exact-{} check, and it'll do what you expect.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| model | LITELLM_MODEL | anthropic/claude-3-haiku-20240307 | — |
| kwargsopt | DICT | [object Object] | — |
| json_str_of_kwargsopt | STRING | {} | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| Litellm model | LITELLM_MODEL | — |