Error "Expecting value: line 1 column 1 (char 0)" when using Claude model through OpenRouter API
Self Checks
- [X] This is only for bug report, if you would like to ask a question, please head to Discussions.
- [X] I have searched for existing issues search for existing issues, including closed ones.
- [X] I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
- [X] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
- [X] Please do not modify this template :) and fill in all the required fields.
Dify version
0.6.14
Cloud or Self Hosted
Self Hosted (Docker)
Steps to reproduce
As shown in the attached image, when I use the Claude Sonnet 3.5 model via OpenRouter's API in Agent Assistant mode, I encounter an "Expecting value: line 1 column 1 (char 0)" error whenever the model attempts to use tools.
I'm unsure if this is a Dify or OpenRouter issue, but I really hope it can function normally.
If this is an OpenRouter-related problem, could you please inform me of the possible causes so I can check with OpenRouter?
This issue was translated with the assistance of Claude.
✔️ Expected Behavior
Works normally, able to retrieve data through tools and respond to users.
❌ Actual Behavior
"Expecting value: line 1 column 1 (char 0)"
@sinomoe Could you help to take a look at this issue?
@sinomoe Could you help to take a look at this issue?
Of course, I'll take a look at this
@xd845217xd I can't reproduce the issue, could you provide the error message and DSL?
GitHub doesn't support uploading yml files, so I've exported and converted it to a txt file.
My testing method is as follows: I ask the model a question like "What time is it now?", prompting the model to use the "current_time" tool.
Subsequently, an error message "Expecting value: line 1 column 1 (char 0)" appears in the upper right corner.
Using the OpenAI API, for example with gpt-4o, there's no issue.
The only visible error on the webpage is "Expecting value: line 1 column 1 (char 0)".
Is there any additional information I can provide?
GitHub doesn't support uploading yml files, so I've exported and converted it to a txt file.
My testing method is as follows: I ask the model a question like "What time is it now?", prompting the model to use the "current_time" tool.
Subsequently, an error message "Expecting value: line 1 column 1 (char 0)" appears in the upper right corner.
Using the OpenAI API, for example with gpt-4o, there's no issue.
The only visible error on the webpage is "Expecting value: line 1 column 1 (char 0)".
Is there any additional information I can provide?
It seems that there is an issue with claude-3.5-sonnet, as it behaves differently from the openai when calling a tool without any arguments. I will create a pull request to make it compatible.
@crazywoola take a look at this #6503
Thank you for your quick response and support.
I'm not sure if this issue is specific to Sonnet 3.5. I've also tried testing with Opus 3 and Haiku 3 models through the OpenRouter API, and I encountered the same error.
I haven't tried using the API directly through Anthropic, AWS Bedrock, or Google Vertex.
~~May I ask if you tested this through OpenRouter as well, or did you use Anthropic's API directly?~~
~~Or perhaps there's no significant difference between these methods in this context?~~
Oh, I see your PR now. It seems you also tested through OpenRouter. My apologies for the oversight.