Mintplex-Labs/anything-llm · error · Error

${res.status} - ${res.statusText}. params: ${JSON.stringify(

Error message

${res.status} - ${res.statusText}. params: ${JSON.stringify({ auth: this.middleTruncate(process.env.AGENT_SERPLY_API_KEY, 5), q: query })}

What it means

Thrown by the Serly search provider when fetch() returns a non-OK HTTP status. Authentication uses AGENT_SERPLY_API_KEY in the X-API-KEY header, plus optional X-Proxy-Location and X-User-Agent headers. The error captures status, statusText, a truncated key, and the query. The .catch logs 'Serly Error' and returns a failure string.

Source

Thrown at server/utils/agents/aibitat/plugins/web-browsing.js:772

              q: query,
              language: language,
              hl,
              gl: proxy_location.toUpperCase(),
            });
            const url = `https://api.serply.io/v1/search/${params.toString()}`;
            const { response, error } = await fetch(url, {
              method: "GET",
              headers: {
                "X-API-KEY": process.env.AGENT_SERPLY_API_KEY,
                "Content-Type": "application/json",
                "User-Agent": "anything-llm",
                "X-Proxy-Location": proxy_location,
                "X-User-Agent": device_type,
              },
            })
              .then((res) => {
                if (res.ok) return res.json();
                throw new Error(
                  `${res.status} - ${res.statusText}. params: ${JSON.stringify({ auth: this.middleTruncate(process.env.AGENT_SERPLY_API_KEY, 5), q: query })}`
                );
              })
              .then((data) => {
                if (data?.message === "Unauthorized")
                  throw new Error(
                    "Unauthorized. Please double check your AGENT_SERPLY_API_KEY"
                  );
                return { response: data, error: null };
              })
              .catch((e) => {
                this.super.handlerProps.log(`Serply Error: ${e.message}`);
                return { response: null, error: e.message };
              });

            if (error)
              return `There was an error searching for content. ${error}`;

View on GitHub (pinned to 526360e320)

Solutions

  1. Verify AGENT_SERLY_API_KEY is set to a valid active key from the Serly dashboard.
  2. Check the truncated key in the error — 'undef...' means the env var is missing.
  3. A 402/403/429 indicates plan limits — upgrade the plan or space out requests.
  4. If using X-Proxy-Location, ensure the value is a supported region code.

Example fix

// before
headers: { "X-API-KEY": process.env.AGENT_SERPLY_API_KEY, ... },
// throw on non-OK

// caller-side fix
if (!process.env.AGENT_SERPLY_API_KEY) {
  return "AGENT_SERPLY_API_KEY is not configured.";
}
Defensive patterns

Strategy: validation

Validate before calling

if (!process.env.AGENT_SERPLY_API_KEY) {
  throw new Error("AGENT_SERPLY_API_KEY is not set. Configure it to use Serly search.");
}

Try / catch

try {
  const results = await serlySearch(query);
  return results;
} catch (e) {
  if (e.message.startsWith("401") || e.message.includes("Unauthorized")) {
    return "Serly API key invalid. Check AGENT_SERLY_API_KEY.";
  }
  if (e.message.startsWith("429") || e.message.startsWith("402")) {
    return "Serly rate/plan limit reached. Check your plan.";
  }
  throw e;
}

Prevention

When it happens

Trigger: Serly API returns 401 (invalid X-API-KEY), 402/403 (plan limit or payment required), 429 (rate limited), 400 (bad query or proxy parameter), or 5xx. Note: Serly can also return 200 OK with {message:'Unauthorized'} which is handled by a separate check (error 413). An unset key sends an empty X-API-KEY header.

Common situations: AGENT_SERLY_API_KEY not set or expired; free tier quota used up; invalid proxy_location parameter; rapid concurrent requests hitting the per-second limit; Serly API undergoing maintenance.

Related errors


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