When calling the API of the workflow (using the gpt4o - mini model of openrouter with visual capabilities), the mime_type is different from that in the orchestration mode, resulting in abnormal operation. #373

Closed
opened 2026-02-16 10:19:11 -05:00 by yindo · 4 comments
Owner

Originally created by @Dhaizei on GitHub (Jun 17, 2025).

Self Checks

  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

1.4.0

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

When using the workflow to call gpt4o - mini of openairouter with the visual function, the processing of images is normal in the orchestration mode of Dify. However, when calling the API of the workflow, first uploading the image and then calling the workflow, it is found that it cannot run normally. After inspection, it is caused by "mime_type": "application/jpeg" and "mime_type": "image/jpeg". The former is called by the workflow, and the latter is called in the orchestration mode.

✔️ Expected Behavior

No response

Actual Behavior

No response

Originally created by @Dhaizei on GitHub (Jun 17, 2025). ### Self Checks - [x] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [x] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [x] I confirm that I am using English to submit this report (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). - [x] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:) - [x] Please do not modify this template :) and fill in all the required fields. ### Dify version 1.4.0 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce When using the workflow to call gpt4o - mini of openairouter with the visual function, the processing of images is normal in the orchestration mode of Dify. However, when calling the API of the workflow, first uploading the image and then calling the workflow, it is found that it cannot run normally. After inspection, it is caused by "mime_type": "application/jpeg" and "mime_type": "image/jpeg". The former is called by the workflow, and the latter is called in the orchestration mode. ### ✔️ Expected Behavior _No response_ ### ❌ Actual Behavior _No response_
yindo closed this issue 2026-02-16 10:19:11 -05:00
Author
Owner

@Dhaizei commented on GitHub (Jun 17, 2025):

[openrouter] Error: PluginInvokeError: {"args":{"description":"[models] Error: API request failed with status code 400: {"error":{"message":"Provider returned error","code":400,"metadata":{"raw":"{\"error\":{\"code\":\"BadRequest\",\"message\":\"Invalid image URL. The URL must be a valid HTTP or HTTPS URL, or a data URL with base64 encoding.\",\"param\":null,\"type\":null}}","provider_name":"Azure"}},"user_id":"user_2yOGX4UJwPDQkfpuQUd2FKXbUvK"}"},"error_type":"InvokeError","message":"[models] Error: API request failed with status code 400: {"error":{"message":"Provider returned error","code":400,"metadata":{"raw":"{\"error\":{\"code\":\"BadRequest\",\"message\":\"Invalid image URL. The URL must be a valid HTTP or HTTPS URL, or a data URL with base64 encoding.\",\"param\":null,\"type\":null}}","provider_name":"Azure"}},"user_id":"user_2yOGX4UJwPDQkfpuQUd2FKXbUvK"}"}

@Dhaizei commented on GitHub (Jun 17, 2025): [openrouter] Error: PluginInvokeError: {"args":{"description":"[models] Error: API request failed with status code 400: {\"error\":{\"message\":\"Provider returned error\",\"code\":400,\"metadata\":{\"raw\":\"{\\\"error\\\":{\\\"code\\\":\\\"BadRequest\\\",\\\"message\\\":\\\"Invalid image URL. The URL must be a valid HTTP or HTTPS URL, or a data URL with base64 encoding.\\\",\\\"param\\\":null,\\\"type\\\":null}}\",\"provider_name\":\"Azure\"}},\"user_id\":\"user_2yOGX4UJwPDQkfpuQUd2FKXbUvK\"}"},"error_type":"InvokeError","message":"[models] Error: API request failed with status code 400: {\"error\":{\"message\":\"Provider returned error\",\"code\":400,\"metadata\":{\"raw\":\"{\\\"error\\\":{\\\"code\\\":\\\"BadRequest\\\",\\\"message\\\":\\\"Invalid image URL. The URL must be a valid HTTP or HTTPS URL, or a data URL with base64 encoding.\\\",\\\"param\\\":null,\\\"type\\\":null}}\",\"provider_name\":\"Azure\"}},\"user_id\":\"user_2yOGX4UJwPDQkfpuQUd2FKXbUvK\"}"}
Author
Owner

@dosubot[bot] commented on GitHub (Jun 17, 2025):

The root cause of your issue is that Dify handles image MIME types differently between workflow (API/upload) and orchestration (in-app) modes. In workflow mode, the MIME type from the client upload is accepted as-is—so if your client/browser sends "application/jpeg" instead of the standard "image/jpeg", Dify passes that through. Orchestration mode, on the other hand, always normalizes JPEGs to "image/jpeg" on the server side. This mismatch can cause downstream errors with providers like gpt4o-mini, which expect the standard MIME type and a valid image URL or base64 data URL.

For the "Invalid image URL" error, Dify's workflow mode may generate a URL or data URL that doesn't meet the provider's requirements (must be a valid HTTP/HTTPS URL or a base64-encoded data URL). If the MIME type is non-standard or the URL is malformed, Azure/OpenRouter will reject it with a 400 error "Invalid image URL".

To work around this:

  • Make sure your client uploads images with the correct MIME type ("image/jpeg" for JPEGs).
  • If you control the upload, explicitly set the MIME type to "image/jpeg" before sending.
  • If you need to patch Dify, add a normalization step in your workflow to convert "application/jpeg" to "image/jpeg" before passing the file to the model.
  • Double-check that the image URL or data URL generated by Dify is valid and accessible by the provider (public HTTP/HTTPS or proper base64 data URL) "UploadFileParser".

This is a known limitation in how Dify currently handles MIME types in workflow mode, and similar issues have been reported by others. If you need more robust handling, you may want to add server-side MIME type normalization or validation in your deployment "helpers.py".

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Join Discord Share on X

@dosubot[bot] commented on GitHub (Jun 17, 2025): <!-- Answer --> The root cause of your issue is that Dify handles image MIME types differently between workflow (API/upload) and orchestration (in-app) modes. In workflow mode, the MIME type from the client upload is accepted as-is—so if your client/browser sends "application/jpeg" instead of the standard "image/jpeg", Dify passes that through. Orchestration mode, on the other hand, always normalizes JPEGs to "image/jpeg" on the server side. This mismatch can cause downstream errors with providers like gpt4o-mini, which expect the standard MIME type and a valid image URL or base64 data URL. For the "Invalid image URL" error, Dify's workflow mode may generate a URL or data URL that doesn't meet the provider's requirements (must be a valid HTTP/HTTPS URL or a base64-encoded data URL). If the MIME type is non-standard or the URL is malformed, Azure/OpenRouter will reject it with a 400 error ["Invalid image URL"](https://github.com/langgenius/dify/issues/16353). To work around this: - Make sure your client uploads images with the correct MIME type ("image/jpeg" for JPEGs). - If you control the upload, explicitly set the MIME type to "image/jpeg" before sending. - If you need to patch Dify, add a normalization step in your workflow to convert "application/jpeg" to "image/jpeg" before passing the file to the model. - Double-check that the image URL or data URL generated by Dify is valid and accessible by the provider (public HTTP/HTTPS or proper base64 data URL) ["UploadFileParser"](https://github.com/langgenius/dify/blob/110bb5e5a5e66f03dd7ca07920e65c46a97b5152/api/core/file/upload_file_parser.py). This is a known limitation in how Dify currently handles MIME types in workflow mode, and similar issues have been reported by others. If you need more robust handling, you may want to add server-side MIME type normalization or validation in your deployment ["helpers.py"](https://github.com/langgenius/dify/blob/110bb5e5a5e66f03dd7ca07920e65c46a97b5152/api/controllers/common/helpers.py). <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/e351240e-5cb8-46b2-9a7f-887543e002dc?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/e351240e-5cb8-46b2-9a7f-887543e002dc?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/e351240e-5cb8-46b2-9a7f-887543e002dc?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/e351240e-5cb8-46b2-9a7f-887543e002dc?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/e351240e-5cb8-46b2-9a7f-887543e002dc?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/e351240e-5cb8-46b2-9a7f-887543e002dc?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/e351240e-5cb8-46b2-9a7f-887543e002dc?feedback_type=other)</sup>&nbsp;&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/langgenius/dify/issues/21109)
Author
Owner

@alterxyz commented on GitHub (Jun 17, 2025):

Please try update your model first.

@alterxyz commented on GitHub (Jun 17, 2025): Please try update your model first.
Author
Owner

@dosubot[bot] commented on GitHub (Aug 20, 2025):

Hi, @Dhaizei. I'm Dosu, and I'm helping the dify-official-plugins team manage their backlog and am marking this issue as stale.

Issue Summary:

  • You reported a bug in Dify 1.4.0 where the workflow API using the gpt4o-mini model from OpenRouter fails due to a MIME type mismatch ("application/jpeg" vs. "image/jpeg").
  • This mismatch causes image processing errors and invalid image URL errors from Azure.
  • The workflow mode currently accepts client MIME types as-is, unlike orchestration mode which normalizes them, leading to provider rejections if non-standard types or invalid URLs are used.
  • Suggestions included ensuring correct MIME types on upload or adding normalization steps in workflows.
  • Another user recommended updating the model as a potential fix, but the issue remains unresolved.

What's Next:

  • Please let me know if this issue is still relevant with the latest version of dify-official-plugins by commenting here to keep the discussion open.
  • Otherwise, I will automatically close this issue in 5 days.

Thanks for your understanding and contribution!

@dosubot[bot] commented on GitHub (Aug 20, 2025): Hi, @Dhaizei. I'm [Dosu](https://dosu.dev), and I'm helping the dify-official-plugins team manage their backlog and am marking this issue as stale. **Issue Summary:** - You reported a bug in Dify 1.4.0 where the workflow API using the gpt4o-mini model from OpenRouter fails due to a MIME type mismatch ("application/jpeg" vs. "image/jpeg"). - This mismatch causes image processing errors and invalid image URL errors from Azure. - The workflow mode currently accepts client MIME types as-is, unlike orchestration mode which normalizes them, leading to provider rejections if non-standard types or invalid URLs are used. - Suggestions included ensuring correct MIME types on upload or adding normalization steps in workflows. - Another user recommended updating the model as a potential fix, but the issue remains unresolved. **What's Next:** - Please let me know if this issue is still relevant with the latest version of dify-official-plugins by commenting here to keep the discussion open. - Otherwise, I will automatically close this issue in 5 days. Thanks for your understanding and contribution!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify-official-plugins#373