An error occurs when using Gemini if ​​the response format is JSON and an image is uploaded. #4015

Closed
opened 2026-02-21 18:04:24 -05:00 by yindo · 2 comments
Owner

Originally created by @otty0507 on GitHub (Jun 7, 2024).

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).
  • Please do not modify this template :) and fill in all the required fields.

Dify version

0.6.10

Cloud or Self Hosted

Cloud

Steps to reproduce

スクリーンショット 2024-06-07 21 38 29

✔️ Expected Behavior

Can be used normally without errors

Actual Behavior

An error occurs

Originally created by @otty0507 on GitHub (Jun 7, 2024). ### 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] Please do not modify this template :) and fill in all the required fields. ### Dify version 0.6.10 ### Cloud or Self Hosted Cloud ### Steps to reproduce ![スクリーンショット 2024-06-07 21 38 29](https://github.com/langgenius/dify/assets/12377287/a6d2bbcb-474f-4bf4-a205-8c3fb488f472) ### ✔️ Expected Behavior Can be used normally without errors ### ❌ Actual Behavior An error occurs
yindo added the 🐞 bug label 2026-02-21 18:04:24 -05:00
yindo closed this issue 2026-02-21 18:04:25 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Jun 7, 2024):

The error you're encountering when using the Gemini model with JSON response format and image uploads in Dify version 0.6.10 could be related to specific configuration settings. Ensure the following settings are correctly configured:

  1. MULTIMODAL_SEND_IMAGE_FORMAT: Should be set to base64 or url. If set to url, ensure FILES_URL is configured as an externally accessible address.
  2. FILES_URL: Must be an externally accessible address if MULTIMODAL_SEND_IMAGE_FORMAT is set to url.
  3. UPLOAD_IMAGE_FILE_SIZE_LIMIT: Ensure the image file size does not exceed the limit (default is 10M).

Example configuration:

MULTIMODAL_SEND_IMAGE_FORMAT: base64  # or url
FILES_URL: "https://your-external-accessible-address"
UPLOAD_IMAGE_FILE_SIZE_LIMIT: 10M

These settings ensure the Gemini model can correctly process images and return JSON responses [1].

Additionally, check for any specific error messages or logs generated during the image processing step, such as:

  • "image generate error, code:{}".format(code)
  • "APPID APISecret APIKey is invalid. {}".format(e)

These logs can help identify the exact issue [2].

To continue talking to Dosu, mention @dosu.

@dosubot[bot] commented on GitHub (Jun 7, 2024): <!-- Answer --> The error you're encountering when using the Gemini model with JSON response format and image uploads in Dify version 0.6.10 could be related to specific configuration settings. Ensure the following settings are correctly configured: 1. **MULTIMODAL\_SEND\_IMAGE\_FORMAT**: Should be set to `base64` or `url`. If set to `url`, ensure `FILES_URL` is configured as an externally accessible address. 2. **FILES\_URL**: Must be an externally accessible address if `MULTIMODAL_SEND_IMAGE_FORMAT` is set to `url`. 3. **UPLOAD\_IMAGE\_FILE\_SIZE\_LIMIT**: Ensure the image file size does not exceed the limit (default is 10M). Example configuration: ```yaml MULTIMODAL_SEND_IMAGE_FORMAT: base64 # or url FILES_URL: "https://your-external-accessible-address" UPLOAD_IMAGE_FILE_SIZE_LIMIT: 10M ``` These settings ensure the Gemini model can correctly process images and return JSON responses <sup>[[1]](https://github.com/langgenius/dify-docs/blob/main/en/getting-started/install-self-hosted/environments.md)</sup>. Additionally, check for any specific error messages or logs generated during the image processing step, such as: - `"image generate error, code:{}".format(code)` - `"APPID APISecret APIKey is invalid. {}".format(e)` These logs can help identify the exact issue <sup>[[2]](https://github.com/langgenius/dify/blob/main/api/core/tools/provider/builtin/spark/spark.py)</sup>. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
Author
Owner

@takatost commented on GitHub (Jun 9, 2024):

Could you please provide more details about the error for our reference?

@takatost commented on GitHub (Jun 9, 2024): Could you please provide more details about the error for our reference?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#4015