continuedev/continue · error · Error

await resp.text()

Error message

await resp.text()

What it means

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).

Source

Thrown at core/llm/llms/Gemini.ts:539

      },
    }));

    const resp = await this.fetch(
      new URL(`${this.model}:batchEmbedContents`, this.apiBase),
      {
        method: "POST",
        body: JSON.stringify({
          requests,
        }),
        headers: {
          "x-goog-api-key": this.apiKey,
          "Content-Type": "application/json",
        } as any,
      },
    );

    if (!resp.ok) {
      throw new Error(await resp.text());
    }

    const data = (await resp.json()) as any;

    return data.embeddings.map((embedding: any) => embedding.values);
  }
}

export default Gemini;

View on GitHub (pinned to 5522c6f44c)

Solutions

  1. Read the raw body in the message — 'API key not valid' means fix apiKey in config.json; 429 means quota/rate limit
  2. Verify the embedding model name in config.json exists and your key's project has access to it
  3. For quota errors, add retry/backoff or reduce the number of chunks embedded per request
  4. Check region restrictions on your Gemini API key

Example fix

// before
{
  "embedProvider": "gemini",
  "apiKey": "AIZA..."
}
// after
{
  "embedProvider": "gemini",
  "apiKey": "AIZA...",
  "embeddingModel": "gemini-embedding-001"
}
Defensive patterns

Strategy: try-catch

Validate before calling

const models = await sdk.llm.listModels();
if (!models.some(m => m.id === 'gemini-embedding-001')) {
  throw new Error('Embedding model unavailable for this key');
}

Type guard

function isGeminiHttpError(e: unknown): e is Error {
  return e instanceof Error && /API key not valid|quota|RESOURCE_EXHAUSTED|PERMISSION_DENIED/i.test(e.message);
}

Try / catch

try {
  await llm.embed(['text']);
} catch (e) {
  if (e instanceof Error && /RESOURCE_EXHAUSTED/.test(e.message)) {
    await backoff(); return llm.embed(['text']);
  }
  throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of continuedev/continue@5522c6f44c (2026-08-27). Data as JSON: /api/errors/3983a9d66581a22e. Report an issue: GitHub.