{"record":{"id":"3fc0738d2ccdb968","repo":"Mintplex-Labs/anything-llm","slug":"res-status-res-statustext-params-json-3fc073","errorCode":null,"errorMessage":"${res.status} - ${res.statusText}. params: ${JSON.stringify({ auth: this.middleTruncate(process.env.AGENT_EXA_API_KEY, 5), q: query })}","messagePattern":"(.+?) - (.+?)\\. params: (.+?)\\)\\}","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/utils/agents/aibitat/plugins/web-browsing.js","lineNumber":1069,"sourceCode":"            const url = \"https://api.exa.ai/search\";\n            const { response, error } = await fetch(url, {\n              method: \"POST\",\n              headers: {\n                \"Content-Type\": \"application/json\",\n                \"x-api-key\": process.env.AGENT_EXA_API_KEY,\n              },\n              body: JSON.stringify({\n                query: query,\n                type: \"auto\",\n                numResults: 10,\n                contents: {\n                  text: true,\n                },\n              }),\n            })\n              .then((res) => {\n                if (res.ok) return res.json();\n                throw new Error(\n                  `${res.status} - ${res.statusText}. params: ${JSON.stringify({ auth: this.middleTruncate(process.env.AGENT_EXA_API_KEY, 5), q: query })}`\n                );\n              })\n              .then((data) => {\n                return { response: data, error: null };\n              })\n              .catch((e) => {\n                this.super.handlerProps.log(`Exa Search Error: ${e.message}`);\n                return { response: null, error: e.message };\n              });\n\n            if (error)\n              return `There was an error searching for content. ${error}`;\n\n            const data = [];\n            response.results?.forEach((searchResult) => {\n              const { title, url, text, publishedDate } = searchResult;\n              data.push({","sourceCodeStart":1051,"sourceCodeEnd":1087,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/server/utils/agents/aibitat/plugins/web-browsing.js#L1051-L1087","documentation":"Thrown by the Exa (formerly Metaphor) search provider when a POST to the Exa API returns a non-OK status. Authentication uses AGENT_EXA_API_KEY as a Bearer token in the Authorization header. The request body specifies query, type, numResults, and contents. The error captures status, statusText, a truncated key, and the query.","triggerScenarios":"Exa returns 401 (invalid or missing Bearer token), 429 (rate limit per plan), 400 (malformed request — wrong type value, unsupported contents config), or 5xx. An unset AGENT_EXA_API_KEY sends an empty Bearer token, always triggering 401.","commonSituations":"AGENT_EXA_API_KEY not configured; key from a free plan exhausted; API schema change (Exa renamed from Metaphor, endpoint/field names may have changed); concurrent requests exceeding the plan's requests-per-minute limit.","solutions":["Verify AGENT_EXA_API_KEY is set to a valid key from dashboard.exa.ai.","A 401 means the Bearer token is wrong — check the truncated value in the error.","A 429 means the plan rate limit is hit — upgrade or reduce search frequency.","For 400 errors, verify the request body fields match Exa's current API spec (type, numResults, contents)."],"exampleFix":"// before\nheaders: { Authorization: `Bearer ${process.env.AGENT_EXA_API_KEY}`, ... },\nbody: JSON.stringify({ query, type: \"auto\", numResults: 10, contents: { text: true } }),\n// throw on non-OK\n\n// caller-side fix\nif (!process.env.AGENT_EXA_API_KEY) {\n  return \"AGENT_EXA_API_KEY is not configured.\";\n}","handlingStrategy":"validation","validationCode":"if (!process.env.AGENT_EXA_API_KEY) {\n  throw new Error(\"AGENT_EXA_API_KEY is not set. Configure it to use Exa search.\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  const results = await exaSearch(query);\n  return results;\n} catch (e) {\n  if (e.message.startsWith(\"401\")) {\n    return \"Exa API key invalid. Check AGENT_EXA_API_KEY.\";\n  }\n  if (e.message.startsWith(\"429\")) {\n    await new Promise(r => setTimeout(r, 3000));\n    return await exaSearch(query); // retry once\n  }\n  throw e;\n}","preventionTips":["Verify AGENT_EXA_API_KEY is set before using Exa search.","Monitor plan rate limits (requests per minute).","Keep up with Exa API schema changes (renamed from Metaphor — field names may evolve).","Validate the request body fields against the current Exa API spec."],"tags":["exa","web-search","http","api-key","rate-limit","agent-tool"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}