{"record":{"id":"117be5f839ce2557","repo":"continuedev/continue","slug":"failed-to-fetch-openrouter-models-response-stat","errorCode":null,"errorMessage":"Failed to fetch OpenRouter models: ${response.status}","messagePattern":"Failed to fetch OpenRouter models: (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"core/llm/fetchModels.ts","lineNumber":128,"sourceCode":"        name,\n        description,\n        icon: getOllamaIcon(name),\n        supportsTools: capabilities.includes(\"tools\"),\n      });\n    }\n\n    return models;\n  } catch (error) {\n    console.error(\"Error fetching Ollama library models:\", error);\n    return [];\n  }\n}\n\nasync function fetchOpenRouterModels(): Promise<FetchedModel[]> {\n  try {\n    const response = await fetch(\"https://openrouter.ai/api/v1/models\");\n    if (!response.ok) {\n      throw new Error(`Failed to fetch OpenRouter models: ${response.status}`);\n    }\n\n    const data = await response.json();\n    if (!data.data || !Array.isArray(data.data)) {\n      return [];\n    }\n\n    return data.data\n      .filter((m: any) => m.id && m.name)\n      .map((m: any) => ({\n        name: m.name,\n        modelId: m.id,\n        icon: \"openrouter.png\",\n        contextLength: m.context_length,\n        maxTokens: m.top_provider?.max_completion_tokens,\n        supportsTools: (m.supported_parameters ?? []).includes(\"tools\"),\n      }));\n  } catch (error) {","sourceCodeStart":110,"sourceCodeEnd":146,"githubUrl":"https://github.com/continuedev/continue/blob/5522c6f44ca0ac3528b37244818fbfa39b5af470/core/llm/fetchModels.ts#L110-L146","documentation":"Thrown by fetchOpenRouterModels when GET https://openrouter.ai/api/v1/models returns a non-OK status. This endpoint normally requires no auth, so a failure indicates connectivity, rate limiting, or an outage rather than bad credentials.","triggerScenarios":"OpenRouter API unreachable or returning 429/5xx; proxy or firewall blocking openrouter.ai; temporary outage.","commonSituations":"CI environments with restricted egress; heavy polling hitting rate limits; regional blocks.","solutions":["Retry with backoff (often transient 429/5xx)","Verify connectivity: curl https://openrouter.ai/api/v1/models","Cache the model list locally and hardcode a fallback set of model names","Check openrouter.ai status page for outages"],"exampleFix":"// before\nconst models = await fetchModels();\n// after\nlet models;\nfor (let i = 0; i < 3 && !models; i++) {\n  try { models = await fetchModels(); } catch (e) { await sleep(1000 * 2 ** i); }\n}","handlingStrategy":"retry","validationCode":"const r = await fetch('https://openrouter.ai/api/v1/models'); if (!r.ok) serveCachedModelList();","typeGuard":null,"tryCatchPattern":"catch (e) { if (e.message.includes('Failed to fetch OpenRouter models')) { await sleep(2000); retry(); } else throw e; }","preventionTips":["Cache the OpenRouter catalog","Back off on 429/5xx","Hardcode fallback model names for offline use"],"tags":["openrouter","network","http","model-list"],"backgroundTag":"http-request-failed","analyzedSha":"5522c6f44ca0ac3528b37244818fbfa39b5af470","analyzedAt":"2026-08-27T11:28:54.683Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}