FlowiseAI/Flowise · error · Error

No content received from HuggingFace API. Response: ${JSON.s

Error message

No content received from HuggingFace API. Response: ${JSON.stringify(res)}

What it means

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.

Source

Thrown at packages/components/nodes/chatmodels/ChatHuggingFace/core.ts:143

            throw error
        }
    }

    /** @ignore */
    async _call(prompt: string, options: this['ParsedCallOptions']): Promise<string> {
        try {
            const client = await this._prepareHFInference()
            // Use chatCompletion for chat models (v4 supports conversational models via Inference Providers)
            const args = {
                model: this.model,
                messages: [{ role: 'user', content: prompt }],
                ...this.invocationParams(options)
            }
            const res = await this.caller.callWithOptions({ signal: options.signal }, client.chatCompletion.bind(client), args)
            const content = res.choices[0]?.message?.content || ''
            if (!content) {
                console.error('[ChatHuggingFace] No content in response:', JSON.stringify(res))
                throw new Error(`No content received from HuggingFace API. Response: ${JSON.stringify(res)}`)
            }
            return content
        } catch (error: any) {
            console.error('[ChatHuggingFace] Error in _call:', error.message)
            // Provide more helpful error messages
            if (error?.message?.includes('endpointUrl') || error?.message?.includes('third-party provider')) {
                throw new Error(
                    `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}`
                )
            }
            if (error?.message?.includes('Invalid username or password') || error?.message?.includes('authentication')) {
                throw new Error(
                    `HuggingFace API authentication failed. Please verify your API key is correct and starts with "hf_". Original error: ${error.message}`
                )
            }
            throw error
        }
    }

View on GitHub (pinned to abe4a8601a)

Solutions

  1. Inspect the JSON in the thrown error / server logs to see the actual response shape and confirm it is a chat completion.
  2. Verify the model id is a chat/instruct model supported by HF Inference Providers (not a pure text-generation or feature-extraction model).
  3. Retry once — transient empty content can occur under load; if persistent, switch models.
  4. If the response carries function_call or tool_calls instead of content, configure the node to handle tool output rather than expecting text.

Example fix

// before
const content = res.choices[0]?.message?.content || ''
if (!content) throw new Error(...) // throws [86]

// after — log raw shape and tolerate tool-only responses
const msg = res.choices[0]?.message
if (!msg) throw new Error(`No message in HF response: ${JSON.stringify(res)}`)
const content = msg.content || msg.tool_calls?.[0]?.function?.arguments || ''
if (!content) throw new Error(`Empty HF content: ${JSON.stringify(res)}`)
Defensive patterns

Strategy: try-catch

Validate before calling

// Validate the model id is a known chat model before calling
const CHAT_MODELS = ['meta-llama/Meta-Llama-3-8B-Instruct', 'mistralai/Mistral-7B-Instruct-v0.3' /* ... */]
if (!CHAT_MODELS.includes(this.model)) {
  console.warn(`Model ${this.model} may not return chat content`)
}

Type guard

function hasNonEmptyContent(res: any): res is { choices: { message: { content: string } }[] } {
  return Boolean(res?.choices?.[0]?.message?.content)
}

Try / catch

try {
  return await model.invoke(prompt)
} catch (e) {
  if (e.message.includes('No content received from HuggingFace API')) {
    console.error('Empty content; raw response in error. Retrying once.')
    return await model.invoke(prompt)
  }
  throw e
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


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