Add TokenMix chat model node#6520
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a new ChatTokenMix chat model node and its corresponding TokenMix API credential configuration, enabling integration with the TokenMix OpenAI-compatible Inference API. The review feedback points out a potential runtime issue where an empty or missing temperature parameter could evaluate to NaN and cause API errors. It is recommended to conditionally assign the temperature property only when it is a valid, non-empty value.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| const obj: ChatOpenAIFields = { | ||
| temperature: parseFloat(temperature), | ||
| modelName, | ||
| openAIApiKey: tokenMixApiKey, | ||
| apiKey: tokenMixApiKey, | ||
| streaming: streaming ?? true | ||
| } |
There was a problem hiding this comment.
If the optional temperature parameter is not provided or is left empty, parseFloat(temperature) will evaluate to NaN. Passing NaN as the temperature to the ChatOpenAI constructor will cause API errors or unexpected behavior at runtime.
To prevent this, only assign the temperature property if it is a valid number/string and not nullish or empty, adhering to the loose equality standard for nullish checks.
| const obj: ChatOpenAIFields = { | |
| temperature: parseFloat(temperature), | |
| modelName, | |
| openAIApiKey: tokenMixApiKey, | |
| apiKey: tokenMixApiKey, | |
| streaming: streaming ?? true | |
| } | |
| const obj: ChatOpenAIFields = { | |
| modelName, | |
| openAIApiKey: tokenMixApiKey, | |
| apiKey: tokenMixApiKey, | |
| streaming: streaming ?? true | |
| } | |
| if (temperature != null && temperature !== '') { | |
| obj.temperature = parseFloat(temperature) | |
| } |
References
- In JavaScript/TypeScript, use loose equality (
== nullor!= null) as a standard idiom for a 'nullish' check that covers bothnullandundefined.
Description
Adds a TokenMix chat model node. TokenMix is an OpenAI-compatible API gateway that exposes DeepSeek, Qwen, Kimi, GLM, MiniMax and other models through a single endpoint (
https://api.tokenmix.ai/v1) and one API key.Because the gateway is OpenAI-compatible, the node wraps
@langchain/openai'sChatOpenAIwith the TokenMix base URL — the same approach as the existing OpenRouter node. It includes vision (image upload) support viaIVisionChatModal, configurable base path, streaming, and the standard sampling parameters.New files
packages/components/nodes/chatmodels/ChatTokenMix/ChatTokenMix.ts— node definitionpackages/components/nodes/chatmodels/ChatTokenMix/FlowiseChatTokenMix.ts—ChatOpenAIsubclass with multimodal supportpackages/components/nodes/chatmodels/ChatTokenMix/tokenmix.svg— node iconpackages/components/credentials/TokenMixApi.credential.ts— API key credentialNodes and credentials are auto-discovered, so no registry changes are required.
How it works
The user supplies a TokenMix API key (credential
tokenMixApi) and a model name (e.g.deepseek/deepseek-v4-pro). The node pointsChatOpenAI'sconfiguration.baseURLathttps://api.tokenmix.ai/v1.Local checks
The node mirrors the existing
ChatOpenRouternode structure (same imports and type surface), with no new dependencies.