deepseek吧 关注:127,444贴子:304,756
  • 4回复贴,共1
求助

Python调用API返回为空

只看楼主收藏回复

response = client.chat.completions.create(
model="deepseek-chat",
# model="deepseek-reasoner",
messages=messages,
max_tokens=1024,
frequency_penalty=0,
temperature=1.0,
stream=False
)
这段代码会发生json解析错误的报错: Expecting value: line 1 column 1 (char 0),有没有大佬知道这是啥原因?是API返回了空数据吗?


IP属地:安徽来自Android客户端1楼2025-02-05 21:37回复
    我也是这个情况,可能是速率限制,等官方修复吧


    IP属地:山西来自Android客户端2楼2025-02-06 14:18
    回复
      2025-08-02 09:56:04
      广告
      不感兴趣
      开通SVIP免广告
      Ds的api接口不是说temperature参数没用来着?虽然加上去不会报错了就是。


      IP属地:天津来自Android客户端3楼2025-02-06 17:40
      收起回复
        我的Traceback有地方很明显是
        File ~/anaconda3/envs/openai/lib/python3.12/site-packages/openai/_response.py:265, in BaseAPIResponse._parse(self, to)
        260 # If the API responds with content that isn't JSON then we just return
        261 # the (decoded) text without performing any parsing so that you can still
        262 # handle the response however you need to.
        263 return response.text # type: ignore
        --> 265 data = response.json()
        之后才有的json报错,应该就是官方的服务器返回的内容为空。因为我也是相同的query过段时间又能得到回答。应该就是服务器繁忙了


        IP属地:新加坡4楼2025-02-26 16:02
        回复