Mintplex-Labs/anything-llm · warning · RetryError

error.message

Error message

error.message

What it means

GenericOpenAiProvider.stream() catch (genericOpenAi.js:132-143) rethrows RateLimitError/InternalServerError/APIError as RetryError(error.message), while AuthenticationError is rethrown verbatim. This provider targets any OpenAI-compatible endpoint configured via the generic-openai settings (GENERIC_OPEN_AI_BASE_PATH and friends).

Source

Thrown at server/utils/agents/aibitat/providers/genericOpenAi.js:140

    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;
    }
  }

  /**
   * Create a non-streaming completion with tool calling support.
   * Uses native tool calling when supported, otherwise falls back to UnTooled.
   */
  async complete(messages, functions = []) {
    const useNative = await this.supportsNativeToolCalling();

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

View on GitHub (pinned to 526360e320)

Solutions

  1. Verify GENERIC_OPEN_AI_BASE_PATH and the API key are correct and reachable.
  2. Check the endpoint's own logs/status for the underlying 4xx/5xx.
  3. Confirm the model id is one the endpoint actually serves.
  4. Let the AIbitat retry loop handle transient failures; add backoff if 429s are frequent.
  5. Reproduce the raw request with curl to see the exact upstream error.
Defensive patterns

Strategy: retry

Validate before calling

// Confirm the generic endpoint is reachable and the key is set before streaming.
if (!process.env.GENERIC_OPEN_AI_BASE_PATH)
  throw new Error("GENERIC_OPEN_AI_BASE_PATH is not set.");
const u = new URL(process.env.GENERIC_OPEN_AI_BASE_PATH);
const probe = await fetch(`${u.origin}/models`, {
  headers: process.env.GENERIC_OPEN_AI_API_KEY
    ? { Authorization: `Bearer ${process.env.GENERIC_OPEN_AI_API_KEY}` }
    : {},
});
if (!probe.ok) throw new Error(`Generic endpoint unreachable: ${probe.status}`);

Try / catch

const { RetryError } = require("./server/utils/agents/aibitat/error.js");
try {
  return await provider.stream(messages, functions, handler);
} catch (e) {
  if (e instanceof RetryError && attempt < MAX) {
    await new Promise((r) => setTimeout(r, 1000 * attempt));
    return await provider.stream(messages, functions, handler);
  }
  throw e;
}

Prevention

When it happens

Trigger: The configured third-party OpenAI-compatible endpoint returns 429, 5xx, or a non-auth APIError during a streaming tooled completion.

Common situations: GENERIC_OPEN_AI_BASE_PATH pointing at an unstable proxy, an upstream rate limit, an unsupported model id for that endpoint, or a request body the endpoint rejects.

Related errors


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