Hello! The solution pointed out by @lysonober is completely correct.
This issue is indeed related to the API limitations of the Gemini model, which is why you might not encounter an error when switching to other models (such as the GPT series).
Explanation of the Cause
The error message ValueError: contents are required is an error directly returned by the Google Gemini API.
- Gemini API Mechanism: It strictly requires the request body to include
contents(i.e., the specific list of conversation messages). - Dify Mechanism: In Dify’s LLM node, if you only configure SYSTEM (system prompt) and do not configure USER (user message), or if the USER message content is empty, the request Dify sends to Gemini will be missing the
contentspart. - Difference: Other models (such as OpenAI) might allow sending only a System Prompt or have different handling logic for empty messages, but Gemini is very strict about this, requiring at least one non-empty user message.
Solution
Please follow the instructions in @lysonober’s screenshot:
- In the problematic LLM node, click the “+ Add Message” button at the bottom.
- Set the message type to USER.
- Fill in the variable in the content box (e.g., the
{{input}}variable passed from the “Start” node).
As long as you ensure that the message sent to Gemini includes content in the User part, this error will disappear.