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_TAVILY_API_KEY, 5), q: query })} What it means
Thrown by the Tavily search provider when a POST to the Tavily API returns a non-OK status. Authentication is via the api_key field in the JSON body (not a header). The error captures status, statusText, a truncated AGENT_TAVILY_API_KEY, and the query. The .catch logs 'Tavily Search Error' and returns a failure string.
Source
Thrown at server/utils/agents/aibitat/plugins/web-browsing.js:911
`${this.caller}: Using Tavily to search for "${
query.length > 100 ? `${query.slice(0, 100)}...` : query
}"`
);
const url = "https://api.tavily.com/search";
const { response, error } = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
api_key: process.env.AGENT_TAVILY_API_KEY,
query: query,
}),
})
.then((res) => {
if (res.ok) return res.json();
throw new Error(
`${res.status} - ${res.statusText}. params: ${JSON.stringify({ auth: this.middleTruncate(process.env.AGENT_TAVILY_API_KEY, 5), q: query })}`
);
})
.then((data) => {
return { response: data, error: null };
})
.catch((e) => {
this.super.handlerProps.log(
`Tavily Search Error: ${e.message}`
);
return { response: null, error: e.message };
});
if (error)
return `There was an error searching for content. ${error}`;
const data = [];
response.results?.forEach((searchResult) => {View on GitHub (pinned to 526360e320)
Solutions
- Confirm AGENT_TAVILY_API_KEY is set to a valid key from app.tavily.com.
- A 429 means the monthly plan limit is reached — upgrade the plan or wait for the cycle reset.
- A 401 means the key is wrong — check the truncated value; 'undef...' indicates the env var is unset.
- For 400 errors, verify the query is a non-empty string.
Example fix
// before
body: JSON.stringify({ api_key: process.env.AGENT_TAVILY_API_KEY, query: query }),
// throw on non-OK
// caller-side fix
if (!process.env.AGENT_TAVILY_API_KEY) {
return "AGENT_TAVILY_API_KEY is not configured.";
} Defensive patterns
Strategy: validation
Validate before calling
if (!process.env.AGENT_TAVILY_API_KEY) {
throw new Error("AGENT_TAVILY_API_KEY is not set. Configure it to use Tavily search.");
} Try / catch
try {
const results = await tavilySearch(query);
return results;
} catch (e) {
if (e.message.startsWith("429")) {
// Tavily monthly limit — cannot retry, must wait for reset
return "Tavily monthly search limit reached. Upgrade the plan or wait for reset.";
}
if (e.message.startsWith("401")) {
return "Tavily API key invalid. Check AGENT_TAVILY_API_KEY.";
}
throw e;
} Prevention
- Verify AGENT_TAVILY_API_KEY is set before using Tavily search.
- Monitor monthly search quota (free tier is 1,000/month).
- Remember the key is in the request body, not a header — ensure it serializes correctly.
- Handle 429 as a hard monthly limit, not a transient retry scenario.
When it happens
Trigger: Tavily returns 401 (invalid or missing api_key in the body), 429 (rate limit — Tavily has strict per-plan limits), 400 (malformed query), or 5xx. Because the key travels in the body, an unset AGENT_TAVILY_API_KEY sends api_key: undefined which Tavily rejects.
Common situations: AGENT_TAVILY_API_KEY not set; free tier (1,000 searches/month) exhausted; key from a canceled account; rapid agent queries hitting the rate limit; Tavily API version change requiring a different body format.
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/411b4fe9bf61245c.
Report an issue: GitHub.