mirror of
https://github.com/deepseek-ai/DeepSeek-R1.git
synced 2026-11-05 00:47:42 +00:00
[GH-ISSUE #91] JSONDecodeError: Expecting value: line 5 column 1 (char 4) #77
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
deepseek-ai/DeepSeek-R1#77
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @jrohsc on GitHub (Jan 27, 2025).
Original GitHub issue: https://github.com/deepseek-ai/DeepSeek-R1/issues/91
I'm getting a
JSONDecodeError: Expecting value: line 5 column 1 (char 4)error by running the exact same code posted on the API documentation. Is there a way to fix this error?from openai import OpenAI
client = OpenAI(api_key="", base_url="https://api.deepseek.com")
Round 1
messages = [{"role": "user", "content": "9.11 and 9.8, which is greater?"}]
response = client.chat.completions.create(
model="deepseek-reasoner",
messages=messages
)
reasoning_content = response.choices[0].message.reasoning_content
content = response.choices[0].message.content
@jrohsc commented on GitHub (Jan 27, 2025):
Is there a way to get the reasoning tokens from the huggingface version on DeepSeek-R1-Distill-Qwen-7B?
@zhuofengli commented on GitHub (Jan 28, 2025):
I hit the same issue and adding
max_tokenhelped@globalcargo commented on GitHub (Jan 28, 2025):
We already use
max_tokenas part of our api submit - makes no difference we get the " Expecting value: line 5 column 1 (char 4)" error on api calls both to V3 and R1. That said, platform api for both models worked perfectly fine until Sunday night (before media hysteria started), so hoping this is a ddos related issue and will resolve.@pedayako commented on GitHub (Jan 28, 2025):
I think it's an issue involving the deepseek-reasoner because I'm experiencing the same problem, and before the hysteria, the model and API calls were working fine. I believe things will normalize soon
@jrohsc commented on GitHub (Jan 28, 2025):
I recommend everyone to try the fireworks ai API. You still might have to pay for the api but I think it is the only API that works.
@globalcargo commented on GitHub (Jan 28, 2025):
We've used deepseek's hosted API on their platform since they launched and it has worked reliably for all previous models, I don't see a need to pay a third party extra.
@pedayako commented on GitHub (Jan 28, 2025):
I'm pretty sure. I think the best solution is to just wait until the services are working well again.
@zhuofengli commented on GitHub (Jan 28, 2025):
When I set max_token to a low number like 300, it works, but not for a high number like 4000
@devanshg03 commented on GitHub (Jan 29, 2025):
I seem to have the same issue regardless of my setting for
max_tokensor even if I exclude it. Even using their official python example below. I wonder if there isn't proper error handling on the server side, and thus, it doesn't decode properly when there is an error?@pedayako commented on GitHub (Jan 29, 2025):
I think there's nothing wrong with your code. The model's reasoning seems to have an issue since the attacks. If you try with the chat model, it will probably work well.
@globalcargo commented on GitHub (Jan 30, 2025):
As of right now both models (V3 and R-1) seems to be back online again and working via the platform API. No more JSONDecodeError. We did not modify our code. So this seems to confirm what others have posited, that this was an issue related to the attacks. Feel free to close this issue for now.
@zhangzx-uiuc commented on GitHub (Jan 30, 2025):
I still get JSONDecodeError occasionally..
@lsjlsj5846 commented on GitHub (Jan 31, 2025):
I also get JSONDecodeError now; setting
max_tokensdoes not help fixing this issue.@kenshiro-o commented on GitHub (Feb 4, 2025):
Same issue here. It may be due to the unexpected high load their servers have been under for a while...
Worth checking again in a few days
@reyynaldi commented on GitHub (Feb 5, 2025):
its kinda weird to say but im glad everyone got the same problem too 😭 i thought its just me. Ya i hope everythings going to work like they used to be again. Anyway, ive tried using openrouter api for deepseek (both reasoner and chat model), while it works, its annoyingly slow, like one simple prompt could take like 40s second. crazy.
@liuhanzuo commented on GitHub (Feb 6, 2025):
I think that the problem is basically caused by the api platform. However, add a max_tokens indeed helps, but can not prevent the problem of connection error. Since the connection error is not that frequently, I think retry for several times would help
@mc-brgb commented on GitHub (Feb 6, 2025):
Same issue here, first query would usually work then consistently get the JSON decoder error with both chat and reasoner model. It was working fine before the media attention.
@globalcargo commented on GitHub (Feb 6, 2025):
We are observing the same thing whereby as the conversation history increases and thus input tokens increase, eventually after two or three turns the model will fail with the JSON decoder error. This happens for both the regular V3 as well as the R1 model.
@Junjie-Chu commented on GitHub (Feb 7, 2025):
Same problems here. I guess this is something due to high workload of their servers.
@pranavmalikk commented on GitHub (Feb 7, 2025):
Same problems here
@agoyang commented on GitHub (Feb 7, 2025):
I have encountered this problem for several consecutive days. It seems that the first few requests every day are fine, and then this error is reported all the time.
@zyuanat commented on GitHub (Feb 7, 2025):
response = client.chat.completions.create(
model="deepseek-chat",
messages=[
{"role": "system", "content": "You are a helpful assistant"},
{"role": "user", "content": "Hello"},
],
stream=False
)
The same problem persisted for days, with even the example request raising "raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)"
Occasionally it's normal, but most of the time it continues to report errors like this. Especially with multiple calls.
@crescentluna commented on GitHub (Feb 7, 2025):
same problems, still don't work
@hpclass commented on GitHub (Feb 7, 2025):
我也遇到同样的问题,使用https://api.deepseek.com/v1进行请求的时候间歇性抛出”line 1 column 1 (char 0)“,也有能正常返回结果的时候,使用第三方代理API则正常,怀疑是服务器有问题。。。
@yulijia commented on GitHub (Feb 7, 2025):
I am an international user, I got the line 1 column 1 (char 0) error every minute today.
@baocai27 commented on GitHub (Feb 8, 2025):
JSONDecodeError: Expecting value: line 1 column 1 (char 0)
same problem QAQ
@mc-brgb commented on GitHub (Feb 8, 2025):
It seems to be working way better today, I did not get any error so far
@yulijia commented on GitHub (Feb 8, 2025):
I run my script using Colab and try to ask Deepseek one question each minute. I received the first 5 answers without error, but after 5 answers, it returned the error.
@pranavmalikk commented on GitHub (Feb 9, 2025):
This works for a slightly longer time period, but i still received the error several times eventually after running my script for a few hours.
@pythonbabaa commented on GitHub (Feb 11, 2025):
Consistently getting the JSON decoder error line 1. Makes me frustrated.
@xpfeifei commented on GitHub (Feb 13, 2025):
虽然json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0) 每次调用时都会报这个问题 ,但是添加了 max_tokens=300后 调用就正常了 没有这个错误出现了
@baocai27 commented on GitHub (Feb 13, 2025):
Yep, if you set the max_token a small number, the condition will relax. But once the max_tokens is bigger, this error will appear again
@pythonbabaa commented on GitHub (Feb 13, 2025):
Getting same (empty) response even after setting max_tokens = 300
@link89 commented on GitHub (Feb 14, 2025):
I am pretty sure that there are some gateways in DeepSeek's backend servers have a timeout of 60s . For a request that takes more than 60s , for example, too many tokens to generate, will hit the timeout limit and return with empty content.
I think deepseek should increase this timeout to, for example 120s, to reduce the chance of such error.
By the way, add the following prompt can alleviate the issue to some extent. Like solving 90% of the failure cases in my test.
Provide your final answer in a concise manner without showing any internal reasoning or chain-of-thought. Only output the final result.
@pythonbabaa commented on GitHub (Feb 14, 2025):
Despite this how can we deploy such system in production if there is even one empty response.
@KhalylDammas commented on GitHub (Feb 19, 2025):
Absolutely, instead of returning time-out error code,
deepseek APIreturns 200 OK, paired with an empty response,and since, openai api python package (as per my research) casts the response to a json
response.json()while the response is empty, that's where the issue originates.In the end of the day, we have nothing to do until Deepseek lift their
Degraded Performanceprotective measures from their API...@kirby-jack commented on GitHub (Mar 5, 2025):
Im also getting this issue for a seemingly simple request.
@github-actions[bot] commented on GitHub (Apr 11, 2025):
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you believe this issue is still relevant, please leave a comment to keep it open. Thank you for your contributions!
@Mor-Li commented on GitHub (Apr 25, 2025):
一样的问题,我最近两天一直遇到,应该就是思考token过多了 然后每隔10min他就会强制给我断掉然后出现json decode error
@github-actions[bot] commented on GitHub (Jun 14, 2025):
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you believe this issue is still relevant, please leave a comment to keep it open. Thank you for your contributions!
@github-actions[bot] commented on GitHub (Jun 29, 2025):
false