{"record":{"id":"5224c57d79612812","repo":"FlowiseAI/Flowise","slug":"huggingface-api-key-is-required-please-configure","errorCode":null,"errorMessage":"HuggingFace API key is required. Please configure it in the credential settings.","messagePattern":"HuggingFace API key is required\\. Please configure it in the credential settings\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/components/nodes/chatmodels/ChatHuggingFace/ChatHuggingFace.ts","lineNumber":131,"sourceCode":"    }\n\n    async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {\n        const model = nodeData.inputs?.model as string\n        const temperature = nodeData.inputs?.temperature as string\n        const maxTokens = nodeData.inputs?.maxTokens as string\n        const topP = nodeData.inputs?.topP as string\n        const hfTopK = nodeData.inputs?.hfTopK as string\n        const frequencyPenalty = nodeData.inputs?.frequencyPenalty as string\n        const endpoint = nodeData.inputs?.endpoint as string\n        const cache = nodeData.inputs?.cache as BaseCache\n        const stop = nodeData.inputs?.stop as string\n\n        const credentialData = await getCredentialData(nodeData.credential ?? '', options)\n        const huggingFaceApiKey = getCredentialParam('huggingFaceApiKey', credentialData, nodeData)\n\n        if (!huggingFaceApiKey) {\n            console.error('[ChatHuggingFace] API key validation failed: No API key found')\n            throw new Error('HuggingFace API key is required. Please configure it in the credential settings.')\n        }\n\n        if (!huggingFaceApiKey.startsWith('hf_')) {\n            console.warn('[ChatHuggingFace] API key format warning: Key does not start with \"hf_\"')\n        }\n\n        const obj: Partial<HFInput> = {\n            model,\n            apiKey: huggingFaceApiKey\n        }\n\n        if (temperature) obj.temperature = parseFloat(temperature)\n        if (maxTokens) obj.maxTokens = parseInt(maxTokens, 10)\n        if (topP) obj.topP = parseFloat(topP)\n        if (hfTopK) obj.topK = parseFloat(hfTopK)\n        if (frequencyPenalty) obj.frequencyPenalty = parseFloat(frequencyPenalty)\n        if (endpoint) obj.endpointUrl = endpoint\n        if (stop) {","sourceCodeStart":113,"sourceCodeEnd":149,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/components/nodes/chatmodels/ChatHuggingFace/ChatHuggingFace.ts#L113-L149","documentation":"ChatHuggingFace's init reads the API key via getCredentialParam('huggingFaceApiKey', ...) from the node's bound credential. If that lookup returns a falsy value, Flowise refuses to construct the model. A console.error line is emitted before the throw to mark it as a credential-validation failure.","triggerScenarios":"nodeData.credential is empty/unbound, the bound credential component lacks a huggingFaceApiKey field, the credential exists but the field is blank, or the credential name does not resolve in the current workspace. Distinct from core.ts:84 because this is the Flowise node-layer check before the LangChain wrapper is built.","commonSituations":"User added the ChatHuggingFace node but did not attach a HuggingFace credential component; selected a credential of the wrong type; renamed/deleted the credential in another workspace; copied a chatflow JSON between instances without copying credentials.","solutions":["Open the node's Credential setting and bind a HuggingFace credential whose huggingFaceApiKey field is filled.","If the credential exists but is empty, edit it and paste a key starting with 'hf_'.","Verify the credential component type matches what ChatHuggingFace expects (HuggingFace API key component).","Re-import or recreate the credential if the chatflow was copied across workspaces."],"exampleFix":"// before: nodeData.credential === ''\n\n// after: bind credential in UI, or programmatically\nnodeData.credential = 'huggingface-cred-id'\n// credential component has field huggingFaceApiKey = 'hf_xxx'","handlingStrategy":"validation","validationCode":"const credentialData = await getCredentialData(nodeData.credential ?? '', options)\nconst key = getCredentialParam('huggingFaceApiKey', credentialData, nodeData)\nif (!key) {\n  throw new Error('ChatHuggingFace node is missing a bound HuggingFace credential. Bind one in the node settings.')\n}","typeGuard":"function hasHuggingFaceCredential(cred: unknown): cred is { huggingFaceApiKey: string } {\n  return typeof (cred as any)?.huggingFaceApiKey === 'string' && (cred as any).huggingFaceApiKey.length > 0\n}","tryCatchPattern":"try {\n  return await initChatModel(nodeData, options)\n} catch (e) {\n  if (e.message === 'HuggingFace API key is required. Please configure it in the credential settings.') {\n    return { error: 'Bind a HuggingFace credential with an hf_ key, then retry.' }\n  }\n  throw e\n}","preventionTips":["Always bind a credential component before saving a ChatHuggingFace node.","Use the credential type designed for HuggingFace, not a generic key.","When copying chatflows between workspaces, copy the credentials too.","Validate key presence in a pre-deploy lint of the chatflow JSON."],"tags":["huggingface","credentials","api-key","configuration","flowise"],"backgroundTag":null,"analyzedSha":"abe4a8601a058047b350c260676826e21dd14101","analyzedAt":"2026-08-12T16:04:40.823Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}