Hugging Face FLUX.1-schnell works in HTTP Request node but fails in AI Agent HTTP request

Hi n8n community,

I’m running into an issue using the Hugging Face black-forest-labs/FLUX.1-schnell image generation model in n8n.

Here’s what I’ve observed:

  • HTTP Request node:

    • Method: POST

    • URL: https://api-inference.huggingface.co/models/black-forest-labs/FLUX.1-schnell

    • Headers:

      Authorization: Bearer <YOUR_TOKEN>
      
    • Body (raw JSON):

    {
      "inputs": "A white hat hacker working on a computer, futuristic, secure, digital security, cyber security"
    }
    

    Result: Works perfectly, image is returned.

  • AI Agent HTTP Request(as tool):

    • Using the same parameters and body, generated via $fromAI() or similar templating.

    • Correct Content-Type and Authorization headers are included.
      Result: Fails with:

    Bad request - please check your parameters
    

What I’ve checked:

Question:
Has anyone successfully used Hugging Face image models in AI Agent HTTP Request nodes? Could this be a templating/formatting issue specific to AI Agent, or is there something else required for image generation endpoints?

Any advice would be greatly appreciated.

Thanks!

Hi @Vivek_Saradva

I tried the HTTP node as you said, but I got the following error:


This means the Accept header needs configeration:

Once I added it, it worked correctly (in the HTTP node).

However, this explains the issue when using HTTP as a tool to generate image(binary),
If you add that header in the HTTP Tool, it will work, but you’ll see the following:
image

This means that tools inside the AI Agent cannot return a binary file.

The solution?
Redesign your workflow so that image generation is handled with an HTTP node (not as a tool), placing it either before or after the AI Agent depending on your logic, and If you still want to use it as a tool, wrap it in a sub-workflow and make sure it returns text rather than a binary..

1 Like

Okay, thanks @mohamed3nan that guidance was helpful. I will redesign my workflow and use HTTP Request as node instead of using as a tool :+1:

1 Like