Skip to main content
403Not retryable
Google Gemini 403 Permission Denied
The key/account can't access the requested resource — API not enabled on the project, or a tuned model accessed without auth.
Most likely causes
- 1.Generative Language API not enabled on the Cloud project
- 2.Key from a different project than the one with access
- 3.Tuned model accessed with plain API key instead of OAuth
Fix checklist
- Enable the API in the Cloud console for the key's project
- Confirm project ID matches where access was granted
- Use OAuth for tuned-model access
Retry guidance
Not retryable.
// 403 is NOT retryable — surface it and fix the request/config.
const res = await fetch("https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-pro:generateContent", {
method: "POST",
headers: {
"content-type": "application/json",
"x-goog-api-key": process.env.GEMINI_API_KEY!,
},
body: JSON.stringify(payload),
});
if (res.status === 403) {
const body = await res.json();
// Do not retry: log the provider's message — it names the exact problem.
throw new Error(`Google Gemini 403: ${JSON.stringify(body.error ?? body)}`);
}Provider status page: status.cloud.google.com