{"record":{"id":"29989bc3b4cae646","repo":"FlowiseAI/Flowise","slug":"no-content-received-from-huggingface-api-response","errorCode":null,"errorMessage":"No content received from HuggingFace API. Response: ${JSON.stringify(res)}","messagePattern":"No content received from HuggingFace API\\. Response: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/components/nodes/chatmodels/ChatHuggingFace/core.ts","lineNumber":143,"sourceCode":"            throw error\n        }\n    }\n\n    /** @ignore */\n    async _call(prompt: string, options: this['ParsedCallOptions']): Promise<string> {\n        try {\n            const client = await this._prepareHFInference()\n            // Use chatCompletion for chat models (v4 supports conversational models via Inference Providers)\n            const args = {\n                model: this.model,\n                messages: [{ role: 'user', content: prompt }],\n                ...this.invocationParams(options)\n            }\n            const res = await this.caller.callWithOptions({ signal: options.signal }, client.chatCompletion.bind(client), args)\n            const content = res.choices[0]?.message?.content || ''\n            if (!content) {\n                console.error('[ChatHuggingFace] No content in response:', JSON.stringify(res))\n                throw new Error(`No content received from HuggingFace API. Response: ${JSON.stringify(res)}`)\n            }\n            return content\n        } catch (error: any) {\n            console.error('[ChatHuggingFace] Error in _call:', error.message)\n            // Provide more helpful error messages\n            if (error?.message?.includes('endpointUrl') || error?.message?.includes('third-party provider')) {\n                throw new Error(\n                    `Cannot use custom endpoint with model \"${this.model}\" that includes a provider. Please leave the Endpoint field blank in the UI. Original error: ${error.message}`\n                )\n            }\n            if (error?.message?.includes('Invalid username or password') || error?.message?.includes('authentication')) {\n                throw new Error(\n                    `HuggingFace API authentication failed. Please verify your API key is correct and starts with \"hf_\". Original error: ${error.message}`\n                )\n            }\n            throw error\n        }\n    }","sourceCodeStart":125,"sourceCodeEnd":161,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/components/nodes/chatmodels/ChatHuggingFace/core.ts#L125-L161","documentation":"The non-streaming _call path received a response from HuggingFace, but res.choices[0]?.message?.content was empty/falsy. Flowise logs the full response via console.error and throws with the JSON-serialized response so the developer can see what the API actually returned.","triggerScenarios":"The model returned a 200 with an empty content string (content || ''  → ''), or choices[0].message.content was null/undefined. Common with chat models that emit only reasoning, function-call payloads, or content filtered by safety settings; also when the model id is wrong and the API echoes a non-chat shape.","commonSituations":"Using a non-chat / text-generation model id in a chatCompletion call; content filtered to empty by HF moderation; rate-limited or quota responses that return a body without content; model id typo resolving to a model that does not emit message.content; very new model returning content in a different field.","solutions":["Inspect the JSON in the thrown error / server logs to see the actual response shape and confirm it is a chat completion.","Verify the model id is a chat/instruct model supported by HF Inference Providers (not a pure text-generation or feature-extraction model).","Retry once — transient empty content can occur under load; if persistent, switch models.","If the response carries function_call or tool_calls instead of content, configure the node to handle tool output rather than expecting text."],"exampleFix":"// before\nconst content = res.choices[0]?.message?.content || ''\nif (!content) throw new Error(...) // throws [86]\n\n// after — log raw shape and tolerate tool-only responses\nconst msg = res.choices[0]?.message\nif (!msg) throw new Error(`No message in HF response: ${JSON.stringify(res)}`)\nconst content = msg.content || msg.tool_calls?.[0]?.function?.arguments || ''\nif (!content) throw new Error(`Empty HF content: ${JSON.stringify(res)}`)","handlingStrategy":"try-catch","validationCode":"// Validate the model id is a known chat model before calling\nconst CHAT_MODELS = ['meta-llama/Meta-Llama-3-8B-Instruct', 'mistralai/Mistral-7B-Instruct-v0.3' /* ... */]\nif (!CHAT_MODELS.includes(this.model)) {\n  console.warn(`Model ${this.model} may not return chat content`)\n}","typeGuard":"function hasNonEmptyContent(res: any): res is { choices: { message: { content: string } }[] } {\n  return Boolean(res?.choices?.[0]?.message?.content)\n}","tryCatchPattern":"try {\n  return await model.invoke(prompt)\n} catch (e) {\n  if (e.message.includes('No content received from HuggingFace API')) {\n    console.error('Empty content; raw response in error. Retrying once.')\n    return await model.invoke(prompt)\n  }\n  throw e\n}","preventionTips":["Use chat/instruct model ids, not text-generation-only ids.","Log the raw API response so empty-content failures are diagnosable.","For gated models, accept the license with the key's account first.","Retry once for transient empties; switch models if it persists."],"tags":["huggingface","empty-response","api-shape","chat-completion","debugging"],"backgroundTag":null,"analyzedSha":"abe4a8601a058047b350c260676826e21dd14101","analyzedAt":"2026-08-12T16:04:40.823Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}