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_SEARCHAPI_API_KEY, 5), q: query })} What it means
Thrown by the SearchApi.io provider when fetch() to https://www.searchapi.io/api/v1/search returns a non-OK HTTP status. The request authenticates via a Bearer token (AGENT_SEARCHAPI_API_KEY) in the Authorization header. The error captures status, statusText, a truncated key, and the query. The downstream .catch logs and returns a failure string.
Source
Thrown at server/utils/agents/aibitat/plugins/web-browsing.js:456
const engine = process.env.AGENT_SEARCHAPI_ENGINE;
const params = new URLSearchParams({
engine: engine,
q: query,
});
const url = `https://www.searchapi.io/api/v1/search?${params.toString()}`;
const { response, error } = await fetch(url, {
method: "GET",
headers: {
Authorization: `Bearer ${process.env.AGENT_SEARCHAPI_API_KEY}`,
"Content-Type": "application/json",
"X-SearchApi-Source": "AnythingLLM",
},
})
.then((res) => {
if (res.ok) return res.json();
throw new Error(
`${res.status} - ${res.statusText}. params: ${JSON.stringify({ auth: this.middleTruncate(process.env.AGENT_SEARCHAPI_API_KEY, 5), q: query })}`
);
})
.then((data) => {
return { response: data, error: null };
})
.catch((e) => {
this.super.handlerProps.log(`SearchApi Error: ${e.message}`);
return { response: null, error: e.message };
});
if (error)
return `There was an error searching for content. ${error}`;
const data = [];
if (response.hasOwnProperty("knowledge_graph"))
data.push(response.knowledge_graph?.description);
if (response.hasOwnProperty("answer_box"))
data.push(response.answer_box?.answer);View on GitHub (pinned to 526360e320)
Solutions
- Confirm AGENT_SEARCHAPI_API_KEY is set and non-empty in the server environment.
- Inspect the truncated key — if it reads 'undef...' the env var is not configured.
- A 402/429 response indicates plan limits — upgrade or wait for the quota window.
- A 401 means the Bearer token is invalid — rotate the key from the SearchApi dashboard.
- For 400 errors, check that the engine and query parameters sent to SearchApi are valid.
Example fix
// before
headers: { Authorization: `Bearer ${process.env.AGENT_SEARCHAPI_API_KEY}`, ... },
// ... throw on non-OK
// caller-side fix — guard the key
if (!process.env.AGENT_SEARCHAPI_API_KEY) {
return "AGENT_SEARCHAPI_API_KEY is not set. Configure it to use SearchApi.";
} Defensive patterns
Strategy: validation
Validate before calling
if (!process.env.AGENT_SEARCHAPI_API_KEY) {
throw new Error("AGENT_SEARCHAPI_API_KEY is not set. Configure it to use SearchApi.");
} Try / catch
try {
const results = await searchApiSearch(query);
return results;
} catch (e) {
if (/^40[12]/.test(e.message)) {
return "SearchApi auth/quota error. Verify AGENT_SEARCHAPI_API_KEY and plan credits.";
}
throw e;
} Prevention
- Verify AGENT_SEARCHAPI_API_KEY is set and active before using the search skill.
- Monitor plan credit consumption.
- Validate the engine parameter is supported by SearchApi before sending.
- Implement backoff for 429 responses.
When it happens
Trigger: SearchApi.io returns 401 (missing/wrong AGENT_SEARCHAPI_API_KEY), 402 (plan limit or payment required), 429 (rate limited), 400 (bad engine or query parameter), or 5xx (upstream outage). The Authorization header is empty or malformed when the env var is unset.
Common situations: AGENT_SEARCHAPI_API_KEY not set in environment; key expired or revoked; free plan credits exhausted; rapid concurrent agent searches exceeding the rate limit; incorrect engine parameter in the request.
Related errors
- ${res.status} - ${res.statusText}. params: ${JSON.stringify(
- ${res.status} - ${res.statusText}. params: ${JSON.stringify(
- ${res.status} - ${res.statusText}. params: ${JSON.stringify(
- ${res.status} - ${res.statusText}. params: ${JSON.stringify(
- ${res.status} - ${res.statusText}. params: ${JSON.stringify(
AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13).
Data as JSON: /api/errors/5cb3e634a50b4cf2.
Report an issue: GitHub.