{"record":{"id":"eea711d7c7c277af","repo":"continuedev/continue","slug":"failed-to-fetch-anthropic-models-response-statu","errorCode":null,"errorMessage":"Failed to fetch Anthropic models: ${response.status}","messagePattern":"Failed to fetch Anthropic models: (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"core/llm/fetchModels.ts","lineNumber":163,"sourceCode":"      }));\n  } catch (error) {\n    console.error(\"Error fetching OpenRouter models:\", error);\n    return [];\n  }\n}\n\nasync function fetchAnthropicModels(apiKey?: string): Promise<FetchedModel[]> {\n  const response = await fetch(\n    \"https://api.anthropic.com/v1/models?limit=100\",\n    {\n      headers: {\n        \"x-api-key\": apiKey ?? \"\",\n        \"anthropic-version\": \"2023-06-01\",\n      },\n    },\n  );\n  if (!response.ok) {\n    throw new Error(`Failed to fetch Anthropic models: ${response.status}`);\n  }\n  const data = await response.json();\n  return (data.data ?? []).map((m: any) => ({\n    name: m.display_name ?? m.id,\n    modelId: m.id,\n    icon: \"anthropic.png\",\n    contextLength: m.max_input_tokens,\n    maxTokens: m.max_tokens,\n    supportsTools: true,\n  }));\n}\n\nasync function fetchGeminiModels(\n  apiKey?: string,\n  apiBase?: string,\n): Promise<FetchedModel[]> {\n  const base = apiBase || \"https://generativelanguage.googleapis.com/v1beta/\";\n  const url = new URL(\"models\", base);","sourceCodeStart":145,"sourceCodeEnd":181,"githubUrl":"https://github.com/continuedev/continue/blob/5522c6f44ca0ac3528b37244818fbfa39b5af470/core/llm/fetchModels.ts#L145-L181","documentation":"Thrown by fetchAnthropicModels when the Anthropic models API responds with a non-OK status. Unlike the OpenRouter/Ollama cases, this request includes an x-api-key header, so 401/403 auth failures are a common cause alongside network issues.","triggerScenarios":"Invalid or missing Anthropic API key, revoked key, or API/network errors (5xx, timeouts) hitting the models endpoint.","commonSituations":"Wrong or expired ANTHROPIC_API_KEY; key lacking access; region-locked API; proxy stripping headers.","solutions":["Verify your Anthropic API key is set and valid (test with a minimal curl to the models endpoint)","Check for typos/whitespace in the key and that it's loaded from the right env var/config","Retry on 5xx/429 with backoff; check status.anthropic.com for outages","Confirm the API base URL if overridden (proxy/gateway must forward x-api-key and anthropic-version headers)"],"exampleFix":"# before\nexport ANTHROPIC_API_KEY=sk-ant-wrong\n# after\nexport ANTHROPIC_API_KEY=sk-ant-... # valid key; verify:\ncurl -s -o /dev/null -w '%{http_code}' https://api.anthropic.com/v1/models -H \"x-api-key: $ANTHROPIC_API_KEY\" -H \"anthropic-version: 2023-06-01\"","handlingStrategy":"try-catch","validationCode":"const r = await fetch(url, { headers: { 'x-api-key': apiKey } }); if (r.status === 401 || r.status === 403) throw new Error('invalid Anthropic key');","typeGuard":null,"tryCatchPattern":"catch (e) { if (e.message.includes('Failed to fetch Anthropic models')) { validateKeyOrPromptUser(); } else throw e; }","preventionTips":["Validate keys at startup with a cheap models call","Load keys from env without stray whitespace","Handle 429/5xx with backoff"],"tags":["anthropic","api-key","network","model-list"],"backgroundTag":"api-authentication-failed","analyzedSha":"5522c6f44ca0ac3528b37244818fbfa39b5af470","analyzedAt":"2026-08-27T11:28:54.683Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}