FlowiseAI/Flowise · error · Error

Invalid JSON in the ChatOpenAI's BaseOptions

Error message

Invalid JSON in the ChatOpenAI's BaseOptions: ${exception}

What it means

ChatOpenAI parses the BaseOptions input the same way as the other OpenAI-compatible nodes: if it is a string it is JSON.parse'd, and any SyntaxError is wrapped with this label. The parsed value becomes defaultHeaders under obj.configuration. An object input bypasses parsing.

Solutions

  1. Validate the BaseOptions string with a JSON parser before saving the node.
  2. Quote all keys/values with double quotes and drop trailing commas/comments.
  3. Prefer passing the node a plain object (the typeof === 'object' branch skips JSON.parse).
  4. Use a minimal example first ({"X-Custom":"value"}) and extend incrementally to isolate the bad token.

Example fix

// before
{ Authorization: "Bearer x", } // unquoted key + trailing comma -> throws [92]

// after
{ "Authorization": "Bearer x" }
Defensive patterns

Strategy: validation

Validate before calling

function parseBaseOptions(raw) {
  if (!raw) return undefined
  if (typeof raw === 'object') return raw
  try { return JSON.parse(raw) }
  catch (e) { throw new Error(`ChatOpenAI BaseOptions JSON invalid: ${e.message}`) }
}
const parsedBaseOptions = parseBaseOptions(nodeData.inputs?.baseOptions)

Type guard

function isHeadersObject(v: unknown): v is Record<string, string> {
  if (typeof v !== 'object' || v === null || Array.isArray(v)) return false
  return Object.values(v).every(x => typeof x === 'string')
}

Try / catch

try {
  return await initChatOpenAI(nodeData, options)
} catch (e) {
  if (e.message.includes("Invalid JSON in the ChatOpenAI's BaseOptions")) {
    throw new Error('Correct the BaseOptions JSON on the ChatOpenAI node, then redeploy.')
  }
  throw e
}

Prevention

When it happens

Trigger: The ChatOpenAI node's BaseOptions field holds invalid JSON — same shape of mistakes as [91] but on the primary ChatOpenAI node. The throw is reached only when baseOptions is a truthy string that fails to parse.

Common situations: Users configuring custom defaultHeaders (e.g. Helicone, Langfuse, OpenRouter passthrough) paste malformed JSON; copying header objects from Python dict syntax; trailing commas from a relaxed editor; smart quotes from a chat client.

Understand the failure class

Related errors


AI-assisted analysis of FlowiseAI/Flowise@abe4a8601a (2026-08-12). Data as JSON: /api/errors/6b27cf94f360b7ed. Report an issue: GitHub.

Appendix: source

Thrown at packages/components/nodes/chatmodels/ChatOpenAI/ChatOpenAI.ts:285

            delete obj.temperature
            delete obj.stop
            const reasoning: OpenAIClient.Reasoning = {}
            if (reasoningEffort) {
                reasoning.effort = reasoningEffort
            }
            if (reasoningSummary) {
                reasoning.summary = reasoningSummary
            }
            obj.reasoning = reasoning
        }

        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 multiModalOption: IMultiModalOption = {
            image: {
                allowImageUploads: allowImageUploads ?? false
            }
        }

        const model = new ChatOpenAI(nodeData.id, obj)
        model.setMultiModalOption(multiModalOption)

View on GitHub (pinned to abe4a8601a)