[Python] DeepsSeek Reasoner API returning empty responses

Discussão em 'Python' iniciado por Stack, Junho 5, 2025.

  1. Stack

    Stack Membro Participativo

    I have created a class call "AiClient" where I use the deepseek API to do requests. The code has been working properly for months. Now, when I try to do a request, the completion object has all the “reasoning” content, but the message content is empty. I have already tried using "stream=True" and also changing the api-key to a new one. My DeepSeek account is still getting charge with each request, even tho the response is always empty (I have already tried 15 times).

    Here is my actual code:

    class AiClient:
    def __init__(self):
    self.base_url = "https://api.deepseek.com"
    self.api_key = DEEPSEEK_API_KEY
    self.client = OpenAI(
    base_url=self.base_url,
    api_key=self.api_key
    )

    def call(self, prompt, type: Literal["reasoner", "chat"], temperature=0.5):
    try:
    completion = self.client.chat.completions.create(
    model=f"deepseek-{type}",
    messages=[{"role": "user", "content": prompt}],
    stream=False,
    max_tokens=8192,
    temperature=temperature,
    )
    response_text = completion.choices[0].message.content.strip()
    return response_text
    except Exception as e:
    print(f"❌ Error calling DeepSeek in AI CLASS: {e}")
    return None


    The prompt is fairly big but always inside the model capacity.

    Yesterday I thought it could be the DeepSeek server getting overload, so I waited, but 24 hours passed and still no responses and I'm still getting charge. This code has already been working for months. I'm getting no error messages on the console whatsoever. The response is just empty.

    I'm doing something wrong? Should something being updated and I need to change the code?

    NOTE: I have already contacted the DeepSeek support, but is not open yet, and the responses can take up to 48 hours. I still think is a problem with my code...

    Continue reading...

Compartilhe esta Página