feat(components): add extra_body support to OpenAI-compatible chat models#6250
feat(components): add extra_body support to OpenAI-compatible chat models#6250manaskumar3003 wants to merge 2 commits intoFlowiseAI:mainfrom
Conversation
…del nodes
Adds an "Additional Body Params (JSON)" input to all OpenAI-compatible
chat model nodes. The JSON is merged into LangChain's modelKwargs, which
is spread into the final request body sent to the provider — matching
the semantics of the OpenAI SDK's extra_body parameter.
Enables use cases such as vLLM-served Qwen3 models where reasoning
behavior is controlled via non-standard fields, e.g.:
{ "chat_template_kwargs": { "enable_thinking": false } }
Affected nodes: ChatOpenAI, ChatOpenAICustom, ChatLocalAI,
AzureChatOpenAI, ChatOpenRouter, ChatCerebras, ChatCometAPI,
ChatNvdiaNIM, ChatSambanova, ChatLitellm, ChatFireworks.
The field is optional and additive — existing flows are unaffected.
Invalid JSON throws a clear error at node init.
There was a problem hiding this comment.
Code Review
This pull request introduces an "Additional Body Params" (extraBody) input field to various chat model components, allowing users to merge custom JSON fields into the API request body. This feature is implemented across multiple nodes including AzureChatOpenAI, ChatOpenAI, and several others. The feedback provided suggests a minor code simplification for merging these additional parameters into the model configuration, as spreading null or undefined values within an object literal is natively safe and does not require a null-coalescing fallback.
| if (extraBody) { | ||
| try { | ||
| const parsedExtraBody = typeof extraBody === 'object' ? extraBody : JSON.parse(extraBody) | ||
| obj.modelKwargs = { ...(obj.modelKwargs ?? {}), ...parsedExtraBody } |
There was a problem hiding this comment.
According to the general rules, spreading null or undefined within an object literal is safe and does not require a ?? {} fallback. You can simplify this line.
| obj.modelKwargs = { ...(obj.modelKwargs ?? {}), ...parsedExtraBody } | |
| obj.modelKwargs = { ...obj.modelKwargs, ...parsedExtraBody } |
References
- Spreading
nullorundefinedwithin an object literal is safe and does not require a?? {}fallback, as it evaluates to an empty object.
| if (extraBody) { | ||
| try { | ||
| const parsedExtraBody = typeof extraBody === 'object' ? extraBody : JSON.parse(extraBody) | ||
| obj.modelKwargs = { ...(obj.modelKwargs ?? {}), ...parsedExtraBody } |
There was a problem hiding this comment.
According to the general rules, spreading null or undefined within an object literal is safe and does not require a ?? {} fallback. You can simplify this line.
| obj.modelKwargs = { ...(obj.modelKwargs ?? {}), ...parsedExtraBody } | |
| obj.modelKwargs = { ...obj.modelKwargs, ...parsedExtraBody } |
References
- Spreading
nullorundefinedwithin an object literal is safe and does not require a?? {}fallback, as it evaluates to an empty object.
| if (extraBody) { | ||
| try { | ||
| const parsedExtraBody = typeof extraBody === 'object' ? extraBody : JSON.parse(extraBody) | ||
| obj.modelKwargs = { ...(obj.modelKwargs ?? {}), ...parsedExtraBody } |
There was a problem hiding this comment.
According to the general rules, spreading null or undefined within an object literal is safe and does not require a ?? {} fallback. You can simplify this line.
| obj.modelKwargs = { ...(obj.modelKwargs ?? {}), ...parsedExtraBody } | |
| obj.modelKwargs = { ...obj.modelKwargs, ...parsedExtraBody } |
References
- Spreading
nullorundefinedwithin an object literal is safe and does not require a?? {}fallback, as it evaluates to an empty object.
| if (extraBody) { | ||
| try { | ||
| const parsedExtraBody = typeof extraBody === 'object' ? extraBody : JSON.parse(extraBody) | ||
| obj.modelKwargs = { ...(obj.modelKwargs ?? {}), ...parsedExtraBody } |
There was a problem hiding this comment.
According to the general rules, spreading null or undefined within an object literal is safe and does not require a ?? {} fallback. You can simplify this line.
| obj.modelKwargs = { ...(obj.modelKwargs ?? {}), ...parsedExtraBody } | |
| obj.modelKwargs = { ...obj.modelKwargs, ...parsedExtraBody } |
References
- Spreading
nullorundefinedwithin an object literal is safe and does not require a?? {}fallback, as it evaluates to an empty object.
| if (extraBody) { | ||
| try { | ||
| const parsedExtraBody = typeof extraBody === 'object' ? extraBody : JSON.parse(extraBody) | ||
| obj.modelKwargs = { ...(obj.modelKwargs ?? {}), ...parsedExtraBody } |
There was a problem hiding this comment.
According to the general rules, spreading null or undefined within an object literal is safe and does not require a ?? {} fallback. You can simplify this line.
| obj.modelKwargs = { ...(obj.modelKwargs ?? {}), ...parsedExtraBody } | |
| obj.modelKwargs = { ...obj.modelKwargs, ...parsedExtraBody } |
References
- Spreading
nullorundefinedwithin an object literal is safe and does not require a?? {}fallback, as it evaluates to an empty object.
| if (extraBody) { | ||
| try { | ||
| const parsedExtraBody = typeof extraBody === 'object' ? extraBody : JSON.parse(extraBody) | ||
| obj.modelKwargs = { ...(obj.modelKwargs ?? {}), ...parsedExtraBody } |
There was a problem hiding this comment.
According to the general rules, spreading null or undefined within an object literal is safe and does not require a ?? {} fallback. You can simplify this line.
| obj.modelKwargs = { ...(obj.modelKwargs ?? {}), ...parsedExtraBody } | |
| obj.modelKwargs = { ...obj.modelKwargs, ...parsedExtraBody } |
References
- Spreading
nullorundefinedwithin an object literal is safe and does not require a?? {}fallback, as it evaluates to an empty object.
| if (extraBody) { | ||
| try { | ||
| const parsedExtraBody = typeof extraBody === 'object' ? extraBody : JSON.parse(extraBody) | ||
| obj.modelKwargs = { ...(obj.modelKwargs ?? {}), ...parsedExtraBody } |
There was a problem hiding this comment.
According to the general rules, spreading null or undefined within an object literal is safe and does not require a ?? {} fallback. You can simplify this line.
| obj.modelKwargs = { ...(obj.modelKwargs ?? {}), ...parsedExtraBody } | |
| obj.modelKwargs = { ...obj.modelKwargs, ...parsedExtraBody } |
References
- Spreading
nullorundefinedwithin an object literal is safe and does not require a?? {}fallback, as it evaluates to an empty object.
| if (extraBody) { | ||
| try { | ||
| const parsedExtraBody = typeof extraBody === 'object' ? extraBody : JSON.parse(extraBody) | ||
| obj.modelKwargs = { ...(obj.modelKwargs ?? {}), ...parsedExtraBody } |
There was a problem hiding this comment.
According to the general rules, spreading null or undefined within an object literal is safe and does not require a ?? {} fallback. You can simplify this line.
| obj.modelKwargs = { ...(obj.modelKwargs ?? {}), ...parsedExtraBody } | |
| obj.modelKwargs = { ...obj.modelKwargs, ...parsedExtraBody } |
References
- Spreading
nullorundefinedwithin an object literal is safe and does not require a?? {}fallback, as it evaluates to an empty object.
| if (extraBody) { | ||
| try { | ||
| const parsedExtraBody = typeof extraBody === 'object' ? extraBody : JSON.parse(extraBody) | ||
| obj.modelKwargs = { ...(obj.modelKwargs ?? {}), ...parsedExtraBody } |
There was a problem hiding this comment.
According to the general rules, spreading null or undefined within an object literal is safe and does not require a ?? {} fallback. You can simplify this line.
| obj.modelKwargs = { ...(obj.modelKwargs ?? {}), ...parsedExtraBody } | |
| obj.modelKwargs = { ...obj.modelKwargs, ...parsedExtraBody } |
References
- Spreading
nullorundefinedwithin an object literal is safe and does not require a?? {}fallback, as it evaluates to an empty object.
| if (extraBody) { | ||
| try { | ||
| const parsedExtraBody = typeof extraBody === 'object' ? extraBody : JSON.parse(extraBody) | ||
| obj.modelKwargs = { ...(obj.modelKwargs ?? {}), ...parsedExtraBody } |
There was a problem hiding this comment.
According to the general rules, spreading null or undefined within an object literal is safe and does not require a ?? {} fallback. You can simplify this line.
| obj.modelKwargs = { ...(obj.modelKwargs ?? {}), ...parsedExtraBody } | |
| obj.modelKwargs = { ...obj.modelKwargs, ...parsedExtraBody } |
References
- Spreading
nullorundefinedwithin an object literal is safe and does not require a?? {}fallback, as it evaluates to an empty object.
…delKwargs
Spreading null/undefined inside an object literal is a no-op per spec, so
`{ ...(obj.modelKwargs ?? {}), ...parsedExtraBody }` simplifies to
`{ ...obj.modelKwargs, ...parsedExtraBody }`.
Addresses review feedback from gemini-code-assist.
AI Code Trust — ship readinessScore: 100 · Verdict: SAFE · Model: deterministic-v1 No blocking issues detected by automated checks. Top issues:
|
feat(components): add extra_body support to OpenAI-compatible chat model nodes
Adds an "Additional Body Params (JSON)" input to all OpenAI-compatible
chat model nodes. The JSON is merged into LangChain's modelKwargs, which
is spread into the final request body sent to the provider — matching
the semantics of the OpenAI SDK's extra_body parameter.
Enables use cases such as vLLM-served Qwen3 models where reasoning
behavior is controlled via non-standard fields, e.g.:
{ "chat_template_kwargs": { "enable_thinking": false } }
Affected nodes: ChatOpenAI, ChatOpenAICustom, ChatLocalAI,
AzureChatOpenAI, ChatOpenRouter, ChatCerebras, ChatCometAPI,
ChatNvdiaNIM, ChatSambanova, ChatLitellm, ChatFireworks.
The field is optional and additive , existing flows are unaffected.
Invalid JSON throws a clear error at node init.