How to pass an image from a subworkflow into agent's chat

Describe the problem/error/question

I am trying to make an agent being able to pass an image created by OpenAi model into the agent’s chat.

What is the error message (if any)?

The image is created in a subworkflow, but it’s not passed into the chat

Please share your workflow

Here is the agent workflow:

Here is the subworkflow

Share the output returned by the last node

If I try to ask the agent to generate the image, he pass a broken image:

Information on your n8n setup

  • n8n version: 1.98.2
  • Database (default: SQLite): PostgreSQL
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Docker
  • Operating system: Linux

Im not 100% sure if you can pass images around like that between agents, but in an attempt to solve the problem you could:

  1. Store the generated image on disk, google drive, s3 bucket, etc and then send the url/path reference back to the main agent to then use the image.
  2. Convert the image to base64 and return that as part of the response.

Im assuming you’re trying to create automated posts here based on your prompt, so maybe a two step approach might work. Once you have an image generated and stored and the content generated, your next step is just to post it to your destination. Doing this will also avoid you eating up unecessary LLM tokens with now passing the generated image back into the model.

Yeah, the first solution you mentioned (store the image somewhere and pass the url) is probably what will I do. But since the agent is trying to pass the image, I was wondering if there was a proper way to do it.