Mintplex-Labs/anything-llm · error · RetryError

error.message

Error message

error.message

What it means

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.

Source

Thrown at server/utils/agents/aibitat/providers/cometapi.js:100

    try {
      return await tooledStream(
        this.client,
        this.model,
        messages,
        functions,
        eventHandler,
        { provider: this }
      );
    } catch (error) {
      console.error(error.message, error);
      if (error instanceof OpenAI.AuthenticationError) throw error;
      if (
        error instanceof OpenAI.RateLimitError ||
        error instanceof OpenAI.InternalServerError ||
        error instanceof OpenAI.APIError
      ) {
        throw new RetryError(error.message);
      }
      throw error;
    }
  }

  async complete(messages, functions = []) {
    const useNative = this.supportsNativeToolCalling();

    if (!useNative) {
      return await UnTooled.prototype.complete.call(
        this,
        messages,
        functions,
        this.#handleFunctionCallChat.bind(this)
      );
    }

    try {

View on GitHub (pinned to 526360e320)

Solutions

  1. Inspect the server console — the full error object is logged before rethrow.
  2. Treat RetryError as transient: let the framework retry.
  3. Verify COMETAPI_API_KEY is valid and has quota on the CometAPI dashboard.
  4. Confirm COMETAPI_BASE_PATH and the model slug are correct for your CometAPI account.
  5. Check whether the upstream model the gateway routes to is healthy.
Defensive patterns

Strategy: retry

Validate before calling

// Confirm CometAPI base + key before streaming.
function assertCometApiEnv() {
  if (!process.env.COMETAPI_API_KEY) throw new Error('COMETAPI_API_KEY not set');
  if (!process.env.COMETAPI_BASE_PATH) throw new Error('COMETAPI_BASE_PATH not set');
}

Type guard

function isRetryableProviderError(e) {
  return e instanceof OpenAI.RateLimitError || e instanceof OpenAI.InternalServerError || e instanceof OpenAI.APIError;
}

Try / catch

// Stream path logs via console.error — use it. Retry on RetryError.
try { return await provider.stream(messages, functions, handler); }
catch (e) {
  if (e instanceof OpenAI.AuthenticationError) throw e;
  if (e instanceof RetryError) return await backoffAndRetry();
  throw e;
}

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Related errors


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