Mintplex-Labs/anything-llm · error · Error

e.message

Error message

e.message

What it means

Not a distinct error — the message is whatever the OpenAI SDK raised against Gitee AI's endpoint. The `.catch((e) => { throw new Error(e.message); })` wrapper re-throws only the text, discarding the SDK error class and stack.

Source

Thrown at server/utils/AiProviders/giteeai/index.js:131

    let textResponse = message?.content;
    if (
      !!message?.reasoning_content &&
      message.reasoning_content.trim().length > 0
    )
      textResponse = `<think>${message.reasoning_content}</think>${textResponse}`;
    return textResponse;
  }

  async getChatCompletion(messages = null, { temperature = 0.7 }) {
    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 GiteeAI: ${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,

View on GitHub (pinned to 526360e320)

Solutions

  1. Read e.message for the HTTP status and detail Gitee returned
  2. If 401/403, regenerate GITEE_AI_API_KEY
  3. If quota-related, top up or switch models in GITEE_AI_MODEL_PREF
  4. Confirm the model id is currently listed by Gitee AI

Example fix

// before
.catch((e) => { throw new Error(e.message); })

// after
.catch((e) => { throw e; })
Defensive patterns

Strategy: try-catch

Try / catch

try {
  return await llm.getChatCompletion(messages, { temperature });
} catch (e) {
  const msg = e.message;
  if (/401|403|invalid.*key/i.test(msg)) throw new AuthError(msg);
  if (/429|quota|insufficient_balance/i.test(msg)) throw new QuotaError(msg);
  if (/model/i.test(msg)) throw new UnknownModelError(msg);
  throw e;
}

Prevention

When it happens

Trigger: this.openai.chat.completions.create({ model, messages, temperature }) rejecting: invalid/revoked key (401), quota/billing (429/402), model id Gitee AI doesn't host, or a server-side error (5xx).

Common situations: GITEE_AI_MODEL_PREF points to a model not in Gitee's catalog; free quota exhausted; key expired; transient Gitee platform outage; request payload larger than allowed.

Related errors


AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13). Data as JSON: /api/errors/df2a4308dc0ed6a7. Report an issue: GitHub.