Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Frequent JSONDecodeError with DeepSeek API #599

Closed
zyuanat opened this issue Feb 7, 2025 · 10 comments
Closed

[BUG] Frequent JSONDecodeError with DeepSeek API #599

zyuanat opened this issue Feb 7, 2025 · 10 comments

Comments

@zyuanat
Copy link

zyuanat commented Feb 7, 2025

"raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)"

This problem frequently occurs when I use the deepseek-API and has been going on for several days. Even the deepseek sample request (shown below) has this error frequently.

from openai import OpenAI

client = OpenAI(api_key="<DeepSeek API Key>", base_url="https://api.deepseek.com")

response = client.chat.completions.create(
    model="deepseek-chat",
    messages=[
        {"role": "system", "content": "You are a helpful assistant"},
        {"role": "user", "content": "Hello"},
    ],
    stream=False
)
@baocai27
Copy link

baocai27 commented Feb 8, 2025

我在调用api的时候也遇到了这个问题,应该是服务本身的问题,合理猜测服务器负载太高了

@mowentian
Copy link
Contributor

For API-related performance updates, please visit: https://status.deepseek.com/

@2261176860
Copy link

你好,问题解决了吗,我现在运行还是这个结果。示例代码有时能运行有时会报以上这个错误,自己写的代码则是从来没有成功过

@fabioquinzi
Copy link

fabioquinzi commented Feb 11, 2025

same here, it just happens randomly every now and then, I just added retry logic to go through, but it's quite unpredictable at the moment. the Status says everything is up and running correctly, while it isn't really.
Although it's useful to know this error specifically is due to some faults of the API itself and not of the code used to invoke the API

@zyuanat
Copy link
Author

zyuanat commented Feb 11, 2025

你好,问题解决了吗,我现在运行还是这个结果。示例代码有时能运行有时会报以上这个错误,自己写的代码则是从来没有成功过

没解决,我这边的情况和你说的简直一模一样

@zyuanat
Copy link
Author

zyuanat commented Feb 11, 2025

same here, it just happens randomly every now and then, I just added retry logic to go through, but it's quite unpredictable at the moment. the Status says everything is up and running correctly, while it isn't really. Although it's useful to know this error specifically is due to some faults of the API itself and not of the code used to invoke the API

Exactly, I was misled into thinking it was some json formatting issues with my own code and wasted 2 days debugging it

@link89
Copy link

link89 commented 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.

2025-02-14 11:45:37,243 httpx: HTTP Request: POST https://api.deepseek.com/chat/completions "HTTP/1.1 200 OK"
2025-02-14 11:46:37,239 json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
2025-02-14 11:46:37,614 httpx: HTTP Request: POST https://api.deepseek.com/chat/completions "HTTP/1.1 200 OK"
2025-02-14 11:47:37,627 json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
2025-02-14 11:47:37,962 httpx: HTTP Request: POST https://api.deepseek.com/chat/completions "HTTP/1.1 200 OK"

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.

@shanghaiyangming
Copy link

目前还是这样,api不稳定,我和楼主的错误是一样的……不是一直出错,一阵OK 同样的代码 就报错了,所以显然是服务的问题。希望官网能早日解决

@thiagodsd
Copy link

Same here. It is a consistent pattern when using R1/Reasoner - whether through the web browser chat, the Python/OpenAI API, or direct HTTP requests. The first call works fine, but after that, it stops functioning for an extended period.

@hydeyr999
Copy link

我也是 应该就是服务器的问题 太不稳定了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants