Skip to content

When send image to Anthropic model the format is not well detected (jpg instead of png) #12955

Description

@jogamned

Describe the problem/error/question

When I tried to send a png to Anthropic model Sonnet 3.5, the format jpg is sent instead of png, which causes an error.

What is the error message (if any)?

Here is the detailled error :
{ "status": 400, "headers": { "cf-cache-status": "DYNAMIC", "cf-ray": "90a2b85d3c5665ba-FRA", "connection": "keep-alive", "content-length": "172", "content-type": "application/json", "date": "Thu, 30 Jan 2025 16:08:21 GMT", "request-id": "req_01UCka4HdbiqsK3C2Th4bp5h", "server": "cloudflare", "via": "1.1 google", "x-robots-tag": "none", "x-should-retry": "false" }, "request_id": "req_01UCka4HdbiqsK3C2Th4bp5h", "error": { "type": "error", "error": { "type": "invalid_request_error", "message": "messages.0.content.0.image.source.base64.data: Image does not match the provided media type image/jpeg" } }, "attemptNumber": 1, "retriesLeft": 6 }

Please share your workflow/screenshots/recording

Image

Here is a simple workflow to reproduce the bug.
It downloads one png, and one jpeg, then asks a simple question the Sonnet.

{
  "nodes": [
    {
      "parameters": {},
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        -40,
        160
      ],
      "id": "a06f7a0f-abeb-4b1a-a7d3-7871cc9197bc",
      "name": "When clicking ‘Test workflow’"
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "Tell me what do you see",
        "messages": {
          "messageValues": [
            {
              "type": "HumanMessagePromptTemplate",
              "messageType": "imageBinary"
            }
          ]
        }
      },
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "typeVersion": 1.5,
      "position": [
        380,
        20
      ],
      "id": "0886a22e-bbb4-4991-a69c-e9471ac5d8f8",
      "name": "Basic LLM Chain"
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatAnthropic",
      "typeVersion": 1.2,
      "position": [
        380,
        180
      ],
      "id": "432b652c-20bf-47c3-a3bb-c1a0c32f88ed",
      "name": "Anthropic Chat Model",
      "credentials": {
        "anthropicApi": {
          "id": "svG0JOjGeonvNps2",
          "name": "Anthropic account"
        }
      }
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "Tell me what do you see",
        "messages": {
          "messageValues": [
            {
              "type": "HumanMessagePromptTemplate",
              "messageType": "imageBinary"
            }
          ]
        }
      },
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "typeVersion": 1.5,
      "position": [
        360,
        320
      ],
      "id": "6cf60e19-ad98-448e-84fb-ad06cc7ef181",
      "name": "Basic LLM Chain1"
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatAnthropic",
      "typeVersion": 1.2,
      "position": [
        380,
        480
      ],
      "id": "cbb7883e-2bbb-43a5-8925-2a382311dfa7",
      "name": "Anthropic Chat Model1",
      "credentials": {
        "anthropicApi": {
          "id": "svG0JOjGeonvNps2",
          "name": "Anthropic account"
        }
      }
    },
    {
      "parameters": {
        "url": "https://avatars.githubusercontent.com/u/45487711?s=200&v=4",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        200,
        20
      ],
      "id": "0feae2bb-8329-4a94-82cc-701ad8abce1b",
      "name": "Get a PNG"
    },
    {
      "parameters": {
        "url": "https://upload.wikimedia.org/wikipedia/commons/3/38/JPEG_example_JPG_RIP_001.jpg",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        180,
        320
      ],
      "id": "959ac46c-5fc9-4f08-beed-df384ec5f7b5",
      "name": "Get a Jpeg"
    }
  ],
  "connections": {
    "When clicking ‘Test workflow’": {
      "main": [
        [
          {
            "node": "Get a PNG",
            "type": "main",
            "index": 0
          },
          {
            "node": "Get a Jpeg",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Anthropic Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Basic LLM Chain",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Anthropic Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "Basic LLM Chain1",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Get a PNG": {
      "main": [
        [
          {
            "node": "Basic LLM Chain",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get a Jpeg": {
      "main": [
        [
          {
            "node": "Basic LLM Chain1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {},
  "meta": {
    "instanceId": "e9a26c824d56079aa1cb8aaba50d3851067693a84b0f7f9f6ed44920271f079d"
  }
}

Debug info

core

  • n8nVersion: 1.76.1
  • platform: docker (cloud)
  • nodeJsVersion: 20.18.1
  • database: sqlite
  • executionMode: regular
  • concurrency: 20
  • license: community

storage

  • success: all
  • error: all
  • progress: false
  • manual: true
  • binaryMode: filesystem

pruning

  • enabled: true
  • maxAge: 720 hours
  • maxCount: 25000 executions

client

  • userAgent: mozilla/5.0 (windows nt 10.0; win64; x64) applewebkit/537.36 (khtml, like gecko) chrome/131.0.0.0 safari/537.36
  • isTouchDevice: false

Generated at: 2025-01-30T13:11:54.775Z}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions