FlowiseAI/Flowise · error · Error

CometAPI API Key is missing or empty. Please provide a valid

Error message

CometAPI API Key is missing or empty. Please provide a valid CometAPI API key in the credential configuration.

What it means

Thrown by ChatCometAPI.init() (line 125) when getCredentialParam('cometApiKey', ...) is falsy OR trims to an empty string. Unlike a plain truthiness check, it explicitly rejects whitespace-only values. It executes before the model-name check, so it is the first CometAPI init guard a caller hits.

Source

Thrown at packages/components/nodes/chatmodels/ChatCometAPI/ChatCometAPI.ts:125

    async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
        const temperature = nodeData.inputs?.temperature as string
        const modelName = nodeData.inputs?.modelName as string
        const maxTokens = nodeData.inputs?.maxTokens as string
        const topP = nodeData.inputs?.topP as string
        const frequencyPenalty = nodeData.inputs?.frequencyPenalty as string
        const presencePenalty = nodeData.inputs?.presencePenalty as string
        const streaming = nodeData.inputs?.streaming as boolean
        const baseOptions = nodeData.inputs?.baseOptions

        if (nodeData.inputs?.credentialId) {
            nodeData.credential = nodeData.inputs?.credentialId
        }
        const credentialData = await getCredentialData(nodeData.credential ?? '', options)
        const openAIApiKey = getCredentialParam('cometApiKey', credentialData, nodeData)

        // Custom error handling for missing API key
        if (!openAIApiKey || openAIApiKey.trim() === '') {
            throw new Error(
                'CometAPI API Key is missing or empty. Please provide a valid CometAPI API key in the credential configuration.'
            )
        }

        // Custom error handling for missing model name
        if (!modelName || modelName.trim() === '') {
            throw new Error('Model Name is required. Please enter a valid model name (e.g., gpt-5-mini, claude-sonnet-4-20250514).')
        }

        const cache = nodeData.inputs?.cache as BaseCache

        const obj: ChatOpenAIFields = {
            temperature: parseFloat(temperature),
            modelName,
            openAIApiKey,
            apiKey: openAIApiKey,
            streaming: streaming ?? true
        }

View on GitHub (pinned to abe4a8601a)

Solutions

  1. Open the ChatCometAPI node and bind a credential whose cometApiKey is a non-empty CometAPI key.
  2. Re-open the credential component, paste the CometAPI key from the CometAPI dashboard, save, then re-run.
  3. If using credentialId input, ensure nodeData.inputs.credentialId points to the correct credential reference.

Example fix

// before: cometApiKey: "   "  (whitespace) -> throws
// after:  cometApiKey: "sk-comet-<real-key>"
Defensive patterns

Strategy: validation

Validate before calling

function hasCometKey(cred: Record<string, unknown>): boolean {
  const v = cred?.cometApiKey
  return typeof v === 'string' && v.trim() !== ''
}
// before init:
if (!hasCometKey(credentialData)) throw new Error('Bind a CometAPI credential with a non-empty cometApiKey')

Type guard

type CometCred = { cometApiKey: string }
function isCometCred(c: unknown): c is CometCred {
  return typeof c === 'object' && c !== null
    && typeof (c as any).cometApiKey === 'string' && (c as any).cometApiKey.trim() !== ''
}

Try / catch

try {
  return await chatCometAPI.init(nodeData, '', options)
} catch (e) {
  if (e instanceof Error && e.message.startsWith('CometAPI API Key')) {
    // prompt user to (re)bind the CometAPI credential
  }
  throw e
}

Prevention

When it happens

Trigger: init() resolves credentialData but the cometApiKey field is undefined, an empty string, or contains only whitespace characters.

Common situations: The CometAPI credential was saved with a blank key field, the node was duplicated from another OpenAI-compatible node without updating the credential, or the user pasted only spaces.

Related errors


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