FlowiseAI/Flowise · error · Error
Invalid JSON in the ChatOpenAI's BaseOptions:
Error message
Invalid JSON in the ChatOpenAI's BaseOptions:
What it means
Same JSON.parse branch as OpenAIEmbedding, in the Custom variant. The message text says "ChatOpenAI's" but the node is an embeddings node (OpenAIEmbeddings) — the string is a copy-paste artifact and does not change behavior.
Source
Thrown at packages/components/nodes/embeddings/OpenAIEmbeddingCustom/OpenAIEmbeddingCustom.ts:132
const openAIApiKey = getCredentialParam('openAIApiKey', credentialData, nodeData)
const obj: Partial<OpenAIEmbeddingsParams> & { openAIApiKey?: string; configuration?: ClientOptions } = {
openAIApiKey
}
if (stripNewLines) obj.stripNewLines = stripNewLines
if (batchSize) obj.batchSize = parseInt(batchSize, 10)
if (timeout) obj.timeout = parseInt(timeout, 10)
if (modelName) obj.modelName = modelName
if (dimensions) obj.dimensions = parseInt(dimensions, 10)
if (encodingFormat) obj.encodingFormat = encodingFormat
let parsedBaseOptions: any | undefined = undefined
if (baseOptions) {
try {
parsedBaseOptions = typeof baseOptions === 'object' ? baseOptions : JSON.parse(baseOptions)
} catch (exception) {
throw new Error("Invalid JSON in the ChatOpenAI's BaseOptions: " + exception)
}
}
if (basePath || parsedBaseOptions) {
obj.configuration = {
baseURL: basePath,
defaultHeaders: parsedBaseOptions
}
}
const model = new OpenAIEmbeddings(obj)
return model
}
}
module.exports = { nodeClass: OpenAIEmbeddingCustom_Embeddings }
View on GitHub (pinned to abe4a8601a)
Solutions
- Validate the baseOptions string with JSON.parse before submitting.
- Supply baseOptions as an object so the parse branch is skipped.
- If debugging, ignore the misleading 'ChatOpenAI' wording and treat as an embeddings BaseOptions error.
Example fix
// before
{ baseURL: 'http://localhost:8000/v1' }
// after
{"baseURL":"http://localhost:8000/v1"} Defensive patterns
Strategy: validation
Validate before calling
function parseBaseOptions(raw: unknown): Record<string, unknown> | undefined {
if (raw == null) return undefined
if (typeof raw === 'object') return raw as Record<string, unknown>
if (typeof raw === 'string') JSON.parse(raw)
return undefined
} Type guard
function isJsonString(v: string): v is string {
try { JSON.parse(v); return true } catch { return false }
} Try / catch
try {
parsedBaseOptions = typeof baseOptions === 'object' ? baseOptions : JSON.parse(baseOptions)
} catch (e) {
throw new Error(`BaseOptions (embeddings) is not valid JSON: ${(e as Error).message}`)
} Prevention
- Remember the message says 'ChatOpenAI' but the node is embeddings - validate the embeddings BaseOptions.
- Pass an object to skip the parse branch.
- Lint the JSON before saving the node.
- Avoid JS object-literal syntax in the field.
When it happens
Trigger: Custom OpenAI-compatible endpoint node receives a baseOptions string that fails JSON.parse (trailing comma, single quotes, malformed JSON).
Common situations: Pasting a JS object literal into the BaseOptions field; quote-style mismatch; using a custom OpenAI-compatible provider with extra headers supplied as a malformed string.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- Invalid JSON in the OpenAIEmbedding's BaseOptions:
- Invalid JSON in the OpenAI's BaseOptions:
- Invalid JSON in the Chat NVIDIA NIM's baseOptions: ${excepti
- Invalid JSON in the ChatOpenAI's BaseOptions: ${exception}
- Invalid JSON in the Additional Configuration:
AI-assisted analysis of FlowiseAI/Flowise@abe4a8601a (2026-08-12).
Data as JSON: /api/errors/0a45799b400080cd.
Report an issue: GitHub.