{"record":{"id":"df2a4308dc0ed6a7","repo":"Mintplex-Labs/anything-llm","slug":"e-message-df2a43","errorCode":null,"errorMessage":"e.message","messagePattern":"e\\.message","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/utils/AiProviders/giteeai/index.js","lineNumber":131,"sourceCode":"    let textResponse = message?.content;\n    if (\n      !!message?.reasoning_content &&\n      message.reasoning_content.trim().length > 0\n    )\n      textResponse = `<think>${message.reasoning_content}</think>${textResponse}`;\n    return textResponse;\n  }\n\n  async getChatCompletion(messages = null, { temperature = 0.7 }) {\n    const result = await LLMPerformanceMonitor.measureAsyncFunction(\n      this.openai.chat.completions\n        .create({\n          model: this.model,\n          messages,\n          temperature,\n        })\n        .catch((e) => {\n          throw new Error(e.message);\n        })\n    );\n\n    if (\n      !result?.output?.hasOwnProperty(\"choices\") ||\n      result?.output?.choices?.length === 0\n    )\n      throw new Error(\n        `Invalid response body returned from GiteeAI: ${JSON.stringify(result.output)}`\n      );\n\n    return {\n      textResponse: this.#parseReasoningFromResponse(result.output.choices[0]),\n      metrics: {\n        prompt_tokens: result.output.usage.prompt_tokens || 0,\n        completion_tokens: result.output.usage.completion_tokens || 0,\n        total_tokens: result.output.usage.total_tokens || 0,\n        outputTps: result.output.usage.completion_tokens / result.duration,","sourceCodeStart":113,"sourceCodeEnd":149,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/server/utils/AiProviders/giteeai/index.js#L113-L149","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Read e.message for the HTTP status and detail Gitee returned","If 401/403, regenerate GITEE_AI_API_KEY","If quota-related, top up or switch models in GITEE_AI_MODEL_PREF","Confirm the model id is currently listed by Gitee AI"],"exampleFix":"// before\n.catch((e) => { throw new Error(e.message); })\n\n// after\n.catch((e) => { throw e; })","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  return await llm.getChatCompletion(messages, { temperature });\n} catch (e) {\n  const msg = e.message;\n  if (/401|403|invalid.*key/i.test(msg)) throw new AuthError(msg);\n  if (/429|quota|insufficient_balance/i.test(msg)) throw new QuotaError(msg);\n  if (/model/i.test(msg)) throw new UnknownModelError(msg);\n  throw e;\n}","preventionTips":["Re-throw the original SDK error to retain the HTTP status","Confirm the model id against Gitee's catalog before sending","Watch quota and rotate keys before hard expiry"],"tags":["giteeai","openai-sdk","error-wrapping","chat-completion","authentication"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}