Use OpenRouter cannot generate image by DALL.E model

Can anybody hep me ? I am new in n8n

Describe the problem/error/question

I use OpenRouter and choose “Image” as source and Operation is “Generate Image” in AI agent ,

but I found it is an error. Please see the screen capture.

Information on your n8n setup

  • n8n version: 2.2.6
  • Database (default: SQLite): N/A
  • n8n EXECUTIONS_PROCESS setting (default: own, main): Main
  • Running n8n via (Docker, npm, n8n cloud, desktop app): n8n Cloud
  • Operating system: Win11 pro

Hi @Alan_Cheung1, welcome!

First:
you can not generate an image using OpenRouter credentials in the OpenAI node, you’ll need an OpenAI API key for this,

Second:
DALL·E is not a valid model in OpenRouter,

Finally:
to generate an image with OpenRouter, you’ll need to use an HTTP node with the correct endpoint and model name, then parse the response to retrieve the image..

Finally, I use http node instead, but still has problem. if I use openrouter Do you have an idea?

{
“model”: “black-forest-labs/flux.2-flex”,
“prompt”: “Professional 16:9 landscape illustration for this article: a girl is enjoying coca-cola”,
“width”: 1024,
“height”: 576
}

Hi @Alan_Cheung1, Good approach!

Here’s how you can do it:

To use any image model, go to the model’s page, copy the cURL, and import it into n8n:

Then parse the output and extract the Base64 data and MIME type to obtain the image,

Here is the simplest version of this:

Feel free to edit it to suit your needs.

1 Like

Great help! Many many thanks.

I try many times, but fail , when I want to defien the ratio 16:9 (e.g.), it seems fail and prompt “Invalid JSON in response body” , if i switch the model to gemini. very strange. I also refer to the image generation doc :smiling_face_with_tear:


This one is fail

{
“model”: “google/gemini-3-pro-image-preview”,
“messages”: [
{
“role”: “user”,
“content”: “Create a picture of a nano banana dish in a fancy restaurant with a Gemini theme”
}
],
“modalities”: [“image”, “text”],
“image_config”: {
“aspect_ratio”: “16:9”,
“image_size”: “4K”
}
}


This one is OK

{
“model”: “google/gemini-3-pro-image-preview”,
“messages”: [
{
“role”: “user”,
“content”: “Create a picture of a nano banana dish in a fancy restaurant with a Gemini theme”
}
}

@Alan_Cheung1 glad it works :wink:

I do not think you’re referring to the correct page,

here is the correct one:

Thanks for your help.

I also reach your mentioned page before, but I cannot find how to configure the image dimensions parameters in this page.

do you think there is another page for this parameters?

I see,

according to this part here:

add this to the object:

"image_config": {
    "aspect_ratio": "16:9"
  }

so it becomes:

{
  "model": "google/gemini-3-pro-image-preview",
  "messages": [
    {
      "role": "user",
      "content": "Generate a beautiful sunset over mountains"
    }
  ],
  "modalities": ["image", "text"],
  "image_config": {
    "aspect_ratio": "16:9"
  }
}

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.