{"record":{"id":"a6ab2bc373fafaac","repo":"Mintplex-Labs/anything-llm","slug":"error-message-a6ab2b","errorCode":null,"errorMessage":"error.message","messagePattern":"error\\.message","errorType":"exception","errorClass":"RetryError","httpStatus":null,"severity":"error","filePath":"server/utils/agents/aibitat/providers/cometapi.js","lineNumber":100,"sourceCode":"\n    try {\n      return await tooledStream(\n        this.client,\n        this.model,\n        messages,\n        functions,\n        eventHandler,\n        { provider: this }\n      );\n    } catch (error) {\n      console.error(error.message, error);\n      if (error instanceof OpenAI.AuthenticationError) throw error;\n      if (\n        error instanceof OpenAI.RateLimitError ||\n        error instanceof OpenAI.InternalServerError ||\n        error instanceof OpenAI.APIError\n      ) {\n        throw new RetryError(error.message);\n      }\n      throw error;\n    }\n  }\n\n  async complete(messages, functions = []) {\n    const useNative = this.supportsNativeToolCalling();\n\n    if (!useNative) {\n      return await UnTooled.prototype.complete.call(\n        this,\n        messages,\n        functions,\n        this.#handleFunctionCallChat.bind(this)\n      );\n    }\n\n    try {","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/server/utils/agents/aibitat/providers/cometapi.js#L82-L118","documentation":"CometAPI provider's `stream()` classifies OpenAI SDK errors. It `console.error`s the error first, then re-throws AuthenticationError, wraps RateLimitError/InternalServerError/APIError as `RetryError(error.message)`, and re-throws the rest. CometAPI is an OpenAI-compatible aggregator/gateway that routes to multiple upstream model providers, so transient failures can originate either at CometAPI itself or at the upstream it routes to.","triggerScenarios":"CometAPI returns 429 (account-level RPM/TPM); 5xx at the CometAPI gateway; upstream provider the gateway routes to is degraded and CometAPI surfaces it as APIError; bad model id (CometAPI rejects unknown model strings with APIError).","commonSituations":"COMETAPI_API_KEY quota exhausted on the aggregator; COMETAPI_BASE_PATH pointing at a stale endpoint; upstream model temporarily unavailable through the gateway; model slug not registered on the CometAPI account.","solutions":["Inspect the server console — the full error object is logged before rethrow.","Treat RetryError as transient: let the framework retry.","Verify COMETAPI_API_KEY is valid and has quota on the CometAPI dashboard.","Confirm COMETAPI_BASE_PATH and the model slug are correct for your CometAPI account.","Check whether the upstream model the gateway routes to is healthy."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Confirm CometAPI base + key before streaming.\nfunction assertCometApiEnv() {\n  if (!process.env.COMETAPI_API_KEY) throw new Error('COMETAPI_API_KEY not set');\n  if (!process.env.COMETAPI_BASE_PATH) throw new Error('COMETAPI_BASE_PATH not set');\n}","typeGuard":"function isRetryableProviderError(e) {\n  return e instanceof OpenAI.RateLimitError || e instanceof OpenAI.InternalServerError || e instanceof OpenAI.APIError;\n}","tryCatchPattern":"// Stream path logs via console.error — use it. Retry on RetryError.\ntry { return await provider.stream(messages, functions, handler); }\ncatch (e) {\n  if (e instanceof OpenAI.AuthenticationError) throw e;\n  if (e instanceof RetryError) return await backoffAndRetry();\n  throw e;\n}","preventionTips":["Read server logs — the stream path console.errors the full object.","Verify COMETAPI_API_KEY quota on the aggregator dashboard.","Confirm upstream model availability, not just the gateway's.","Retry on RetryError with exponential backoff."],"tags":["llm-provider","cometapi","retry","rate-limit","streaming","openai-sdk"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}