{"record":{"id":"b3ef3efc66e576c9","repo":"musistudio/claude-code-router","slug":"openrouter-providers-request-failed-response-st","errorCode":null,"errorMessage":"OpenRouter providers request failed (${response.status}): ${text.slice(0, 200)}","messagePattern":"OpenRouter providers request failed \\((.+?)\\): (.+?)","errorType":"http","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/core/src/providers/openrouter-provider-catalog.ts","lineNumber":33,"sourceCode":"  const apiRoot = openRouterApiRoot(request.baseUrl);\n  const model = stringValue(request.model);\n  const cacheKey = model ? `${apiRoot}:model:${model}` : `${apiRoot}:providers`;\n  const cached = providerCache.get(cacheKey);\n  const now = Date.now();\n  if (cached && now - cached.fetchedAt < providerCacheTtlMs) {\n    return {\n      loadedFrom: apiRoot,\n      providers: cached.providers\n    };\n  }\n\n  const endpointPath = model\n    ? modelEndpointsPath(model)\n    : \"/api/v1/providers\";\n  const response = await fetch(`${trimRight(apiRoot, \"/\")}${endpointPath}`);\n  if (!response.ok) {\n    const text = await response.text().catch(() => \"\");\n    throw new Error(`OpenRouter providers request failed (${response.status}): ${text.slice(0, 200)}`);\n  }\n\n  const payload = await response.json() as unknown;\n  const record = isRecord(payload) ? payload : {};\n  const data = model && isRecord(record.data) && Array.isArray(record.data.endpoints)\n    ? record.data.endpoints\n    : Array.isArray(record.data)\n      ? record.data\n      : [];\n  const providers = model\n    ? mergeProviderActivity(\n      normalizeOpenRouterEndpointProviders(data),\n      await loadYesterdayProviderTokenTotals(apiRoot, apiKey, model)\n    )\n    : normalizeOpenRouterProviders(data);\n  providerCache.set(cacheKey, { fetchedAt: now, providers });\n  return {\n    loadedFrom: apiRoot,","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/musistudio/claude-code-router/blob/99f24806c6a2c660b16e53e95211c517448a6c90/packages/core/src/providers/openrouter-provider-catalog.ts#L15-L51","documentation":"getOpenRouterProviderCatalog fetches `${apiRoot}/api/v1/providers` (or a model endpoints path) and throws when the HTTP response is not ok, including status and first 200 chars of the body. This is the primary failure point for OpenRouter catalog discovery when the API is unreachable, rate-limited, or returns an error.","triggerScenarios":"fetch to the OpenRouter API root returning non-2xx: 401/403 (auth or wrong apiRoot), 404 (wrong apiRoot or endpoint moved), 429 (rate limit), 5xx (outage), or a proxy/gateway error page.","commonSituations":"Misconfigured apiRoot (pointing at the model endpoint base instead of the site root), OpenRouter deprecating endpoints, corporate proxies returning 407/502, or hitting rate limits while polling the catalog repeatedly.","solutions":["Check the status code in the message: 429 → back off and retry with caching; 404 → fix apiRoot (should be the OpenRouter site root, not /api/v1); 401/403 → check proxy/auth requirements","Cache catalog results and refresh infrequently instead of on every call","Retry with exponential backoff for 5xx/429 since these are transient","Verify the endpoint still exists in the current OpenRouter docs if 404 persists"],"exampleFix":"// before\nconst catalog = await getOpenRouterProviderCatalog({ apiRoot: \"https://openrouter.ai/api/v1\" });\n// after\nconst catalog = await getOpenRouterProviderCatalog({ apiRoot: \"https://openrouter.ai\" });","handlingStrategy":"retry","validationCode":"if (!/^https:\\/\\/openrouter\\.ai/.test(apiRoot)) throw new Error('apiRoot should be the OpenRouter site root');","typeGuard":null,"tryCatchPattern":"catch (e) { if (e instanceof Error && /OpenRouter providers request failed \\((429|5\\d\\d)\\)/.test(e.message)) return await withBackoff(() => getOpenRouterProviderCatalog(opts)); throw e; }","preventionTips":["Cache catalog results with a TTL","Back off on 429/5xx instead of immediate retries","Pin apiRoot to the documented site root"],"tags":["openrouter","http","network","catalog"],"backgroundTag":"http-request-failed","analyzedSha":"99f24806c6a2c660b16e53e95211c517448a6c90","analyzedAt":"2026-08-27T04:11:01.184Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}