{"record":{"id":"7f1bf99476d680cb","repo":"continuedev/continue","slug":"failed-to-fetch-gemini-models-response-status","errorCode":null,"errorMessage":"Failed to fetch Gemini models: ${response.status}","messagePattern":"Failed to fetch Gemini models: (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"core/llm/fetchModels.ts","lineNumber":185,"sourceCode":"    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);\n  url.searchParams.set(\"key\", apiKey ?? \"\");\n  const response = await fetch(url);\n  if (!response.ok) {\n    throw new Error(`Failed to fetch Gemini models: ${response.status}`);\n  }\n  const data = await response.json();\n  return (data.models ?? [])\n    .filter((m: any) => {\n      const id: string = m.name?.replace(\"models/\", \"\") ?? \"\";\n      const methods: string[] = m.supportedGenerationMethods ?? [];\n      return (\n        !id.startsWith(\"gemini-2.0\") &&\n        !id.startsWith(\"gemma-\") && // Gemma models are supported through Ollama, not the Gemini API\n        !id.startsWith(\"nano-banana\") &&\n        !id.startsWith(\"lyria\") &&\n        methods.includes(\"generateContent\") &&\n        !methods.includes(\"embedContent\") &&\n        !methods.includes(\"predict\") &&\n        !methods.includes(\"predictLongRunning\") &&\n        !methods.includes(\"bidiGenerateContent\") &&\n        !id.includes(\"tts\") &&\n        !id.includes(\"image\") &&","sourceCodeStart":167,"sourceCodeEnd":203,"githubUrl":"https://github.com/continuedev/continue/blob/5522c6f44ca0ac3528b37244818fbfa39b5af470/core/llm/fetchModels.ts#L167-L203","documentation":"Thrown by fetchGeminiModels when the Google Generative Language models endpoint returns non-OK. The API key is passed as a URL query parameter, so an invalid/missing key typically yields 400/403, while network or quota issues yield other statuses.","triggerScenarios":"Missing or malformed Gemini API key (key= empty or invalid), quota exceeded, or a custom apiBase that is wrong/unreachable.","commonSituations":"GEMINI_API_KEY unset or pasted with whitespace/newlines; using a proxy base URL that doesn't accept key-as-query-param; free-tier quota exhausted.","solutions":["Verify the API key is set, non-empty, and valid (test the same URL with curl)","Strip whitespace/newlines from the key before use","If apiBase is customized, confirm it points to a Gemini-compatible endpoint that accepts the 'key' query param","Retry on 5xx/429 with backoff and check quota in Google AI Studio"],"exampleFix":"# before\napiKey=\" sk-...\\n\"  # stray whitespace\n# after\napiKey=\"sk-...\".trim()","handlingStrategy":"try-catch","validationCode":"const u = new URL('models', base); u.searchParams.set('key', apiKey.trim()); const r = await fetch(u); if (!r.ok) throw new Error(`Gemini list failed: ${r.status}`);","typeGuard":null,"tryCatchPattern":"catch (e) { if (e.message.includes('Failed to fetch Gemini models')) { checkKeyAndQuota(); } else throw e; }","preventionTips":["Trim API keys","Verify custom apiBase compatibility","Watch free-tier quota"],"tags":["gemini","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"}