Error "Expecting value: line 1 column 1 (char 0)" when using Claude model through OpenRouter API #4701

Closed
opened 2026-02-21 18:07:37 -05:00 by yindo · 7 comments
Owner

Originally created by @xwineapplex on GitHub (Jul 20, 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).
  • 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • 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

螢幕擷取畫面 2024-07-20 212629

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

螢幕擷取畫面 2024-07-20 214459

Works normally, able to retrieve data through tools and respond to users.

Actual Behavior

"Expecting value: line 1 column 1 (char 0)"

Originally created by @xwineapplex on GitHub (Jul 20, 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] 请务必使用英文提交 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 ![螢幕擷取畫面 2024-07-20 212629](https://github.com/user-attachments/assets/b2b31a1a-89e9-4f54-9d43-c486c4f97922) 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? --- <sub>This issue was translated with the assistance of Claude.</sub> ### ✔️ Expected Behavior ![螢幕擷取畫面 2024-07-20 214459](https://github.com/user-attachments/assets/f5697f8e-410a-45b6-b5ed-770041de2239) Works normally, able to retrieve data through tools and respond to users. ### ❌ Actual Behavior "Expecting value: line 1 column 1 (char 0)"
yindo added the 🐞 bug label 2026-02-21 18:07:37 -05:00
yindo closed this issue 2026-02-21 18:07:37 -05:00
Author
Owner

@crazywoola commented on GitHub (Jul 20, 2024):

@sinomoe Could you help to take a look at this issue?

@crazywoola commented on GitHub (Jul 20, 2024): @sinomoe Could you help to take a look at this issue?
Author
Owner

@sinomoe commented on GitHub (Jul 20, 2024):

@sinomoe Could you help to take a look at this issue?

Of course, I'll take a look at this

@sinomoe commented on GitHub (Jul 20, 2024): > @sinomoe Could you help to take a look at this issue? Of course, I'll take a look at this
Author
Owner

@sinomoe commented on GitHub (Jul 20, 2024):

@xd845217xd I can't reproduce the issue, could you provide the error message and DSL?

@sinomoe commented on GitHub (Jul 20, 2024): @xd845217xd I can't reproduce the issue, could you provide the error message and DSL?
Author
Owner

@xwineapplex commented on GitHub (Jul 20, 2024):

Test-with-tools.txt

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?

@xwineapplex commented on GitHub (Jul 20, 2024): [Test-with-tools.txt](https://github.com/user-attachments/files/16323003/Test-with-tools.txt) 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?
Author
Owner

@sinomoe commented on GitHub (Jul 21, 2024):

Test-with-tools.txt

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.

@sinomoe commented on GitHub (Jul 21, 2024): > [Test-with-tools.txt](https://github.com/user-attachments/files/16323003/Test-with-tools.txt) > > 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.
Author
Owner

@sinomoe commented on GitHub (Jul 21, 2024):

@crazywoola take a look at this #6503

@sinomoe commented on GitHub (Jul 21, 2024): @crazywoola take a look at this #6503
Author
Owner

@xwineapplex commented on GitHub (Jul 21, 2024):

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.

螢幕擷取畫面 2024-07-21 152556
螢幕擷取畫面 2024-07-21 152729

@xwineapplex commented on GitHub (Jul 21, 2024): 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. ![螢幕擷取畫面 2024-07-21 152556](https://github.com/user-attachments/assets/770e9681-8c2e-4efa-854c-89ab671f2198) ![螢幕擷取畫面 2024-07-21 152729](https://github.com/user-attachments/assets/e67759dc-b8e0-47a5-b044-14f64203bf2a)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#4701