Description
The documentation at /docs/cli/authentication.md states that Vertex AI supports Google Cloud API keys, but the actual Vertex AI service rejects API keys with "API keys are not supported by this API" error.
Current Documentation Says
Under the "Vertex AI" section:
Obtain your Google Cloud API key: Get an API Key
Set the GOOGLE_API_KEY environment variable...
This links to https://cloud.google.com/vertex-ai/generative-ai/docs/start/api-keys
Actual Behavior
When using a Google Cloud API key with Vertex AI endpoint:
curl -X POST \
"https://us-central1-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/us-central1/publishers/google/models/gemini-2.0-flash-exp:generateContent?key=API_KEY" \
-H "Content-Type: application/json" \
-d '{"contents": [{"role": "user", "parts": [{"text": "test"}]}]}'
Returns:
{
"error": {
"code": 401,
"message": "API keys are not supported by this API. Expected OAuth2 access token or other authentication credentials that assert a principal. See https://cloud.google.com/docs/authentication",
"status": "UNAUTHENTICATED"
}
}
Confusion Points
- The Gemini CLI docs say Vertex AI supports API keys
- The linked Vertex AI documentation mentions API keys (though it may be referring to service account keys)
- The actual Vertex AI API endpoint rejects API keys entirely
Suggested Fix
Update documentation to clarify:
- Vertex AI only supports OAuth2/ADC/Service Account authentication
- API keys are only supported by Google AI Studio (generativelanguage.googleapis.com)
- Remove or clarify the GOOGLE_API_KEY environment variable section under Vertex AI
Impact
Users waste time trying to configure API keys that will never work with Vertex AI, leading to frustration and confusion about why their valid API key is being rejected.
Description
The documentation at
/docs/cli/authentication.mdstates that Vertex AI supports Google Cloud API keys, but the actual Vertex AI service rejects API keys with "API keys are not supported by this API" error.Current Documentation Says
Under the "Vertex AI" section:
This links to https://cloud.google.com/vertex-ai/generative-ai/docs/start/api-keys
Actual Behavior
When using a Google Cloud API key with Vertex AI endpoint:
Returns:
{ "error": { "code": 401, "message": "API keys are not supported by this API. Expected OAuth2 access token or other authentication credentials that assert a principal. See https://cloud.google.com/docs/authentication", "status": "UNAUTHENTICATED" } }Confusion Points
Suggested Fix
Update documentation to clarify:
Impact
Users waste time trying to configure API keys that will never work with Vertex AI, leading to frustration and confusion about why their valid API key is being rejected.