Mintplex-Labs/anything-llm · error · Error

Invalid response body returned from DeepSeek

Error message

Invalid response body returned from DeepSeek: ${JSON.stringify(result.output)}

What it means

Response-shape guard in DeepSeekLLM.getChatCompletion: the API call succeeded but the payload lacked a non-empty choices array, meaning DeepSeek returned a malformed, empty, or error-shaped body that cannot yield a chat text response; the raw body is serialized for diagnosis.

Solutions

  1. Check the DeepSeek response for error details.
  2. Verify the request parameters match the DeepSeek API.
  3. Retry the request.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown when DeepSeek returns an unexpected response body.

Common situations: API changed response shape or returned an error object.


AI-assisted analysis of Mintplex-Labs/anything-llm@3aec848f28 (2026-08-18). Data as JSON: /api/errors/f2b9285c24dfdaf5. Report an issue: GitHub.

Appendix: source

Thrown at server/utils/AiProviders/deepseek/index.js:119

      );

    const result = await LLMPerformanceMonitor.measureAsyncFunction(
      this.openai.chat.completions
        .create({
          model: this.model,
          messages,
          temperature,
        })
        .catch((e) => {
          throw new Error(e.message);
        })
    );

    if (
      !result?.output?.hasOwnProperty("choices") ||
      result?.output?.choices?.length === 0
    )
      throw new Error(
        `Invalid response body returned from DeepSeek: ${JSON.stringify(result.output)}`
      );

    return {
      textResponse: this.#parseReasoningFromResponse(result.output.choices[0]),
      metrics: {
        prompt_tokens: result.output.usage.prompt_tokens || 0,
        completion_tokens: result.output.usage.completion_tokens || 0,
        total_tokens: result.output.usage.total_tokens || 0,
        outputTps: result.output.usage.completion_tokens / result.duration,
        duration: result.duration,
        model: this.model,
        provider: this.className,
        timestamp: new Date(),
      },
    };
  }

View on GitHub (pinned to 3aec848f28)