{"record":{"id":"3983a9d66581a22e","repo":"continuedev/continue","slug":"await-resp-text-3983a9","errorCode":null,"errorMessage":"await resp.text()","messagePattern":"await resp\\.text\\(\\)","errorType":"http","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"core/llm/llms/Gemini.ts","lineNumber":539,"sourceCode":"      },\n    }));\n\n    const resp = await this.fetch(\n      new URL(`${this.model}:batchEmbedContents`, this.apiBase),\n      {\n        method: \"POST\",\n        body: JSON.stringify({\n          requests,\n        }),\n        headers: {\n          \"x-goog-api-key\": this.apiKey,\n          \"Content-Type\": \"application/json\",\n        } as any,\n      },\n    );\n\n    if (!resp.ok) {\n      throw new Error(await resp.text());\n    }\n\n    const data = (await resp.json()) as any;\n\n    return data.embeddings.map((embedding: any) => embedding.values);\n  }\n}\n\nexport default Gemini;\n","sourceCodeStart":521,"sourceCodeEnd":549,"githubUrl":"https://github.com/continuedev/continue/blob/5522c6f44ca0ac3528b37244818fbfa39b5af470/core/llm/llms/Gemini.ts#L521-L549","documentation":"Thrown inside Gemini._embed when Google's Gemini embedding endpoint returns a non-2xx HTTP status. The raw response body text is used as the error message, so the message is whatever the Gemini API returned (e.g. an API key problem, invalid model name, or quota exceeded).","triggerScenarios":"Calling embed/chunk-embed with the Gemini embedding provider configured and the POST to the Gemini embedContents endpoint failing: bad/missing apiKey, embedding model name not supported by the key's project, rate limits, or malformed request payload.","commonSituations":"Using a free-tier API key that lacks access to embedding models (e.g. text-embedding-004 vs gemini-embedding-001 naming), hitting 429 quota limits, or leaving a placeholder apiKey in config.json.","solutions":["Read the raw body in the message — 'API key not valid' means fix apiKey in config.json; 429 means quota/rate limit","Verify the embedding model name in config.json exists and your key's project has access to it","For quota errors, add retry/backoff or reduce the number of chunks embedded per request","Check region restrictions on your Gemini API key"],"exampleFix":"// before\n{\n  \"embedProvider\": \"gemini\",\n  \"apiKey\": \"AIZA...\"\n}\n// after\n{\n  \"embedProvider\": \"gemini\",\n  \"apiKey\": \"AIZA...\",\n  \"embeddingModel\": \"gemini-embedding-001\"\n}","handlingStrategy":"try-catch","validationCode":"const models = await sdk.llm.listModels();\nif (!models.some(m => m.id === 'gemini-embedding-001')) {\n  throw new Error('Embedding model unavailable for this key');\n}","typeGuard":"function isGeminiHttpError(e: unknown): e is Error {\n  return e instanceof Error && /API key not valid|quota|RESOURCE_EXHAUSTED|PERMISSION_DENIED/i.test(e.message);\n}","tryCatchPattern":"try {\n  await llm.embed(['text']);\n} catch (e) {\n  if (e instanceof Error && /RESOURCE_EXHAUSTED/.test(e.message)) {\n    await backoff(); return llm.embed(['text']);\n  }\n  throw e;\n}","preventionTips":["Validate the Gemini API key with a cheap models.list call at startup","Set embeddingModel explicitly instead of relying on defaults","Batch chunks to stay under token-per-minute limits"],"tags":["gemini","embedding","http-error","api-key","quota"],"backgroundTag":"rest-api-error-response","analyzedSha":"5522c6f44ca0ac3528b37244818fbfa39b5af470","analyzedAt":"2026-08-27T11:28:54.683Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}