Skip to content

Documentation incorrectly states Vertex AI supports API key authentication #5739

Description

@sergenX1

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

  1. The Gemini CLI docs say Vertex AI supports API keys
  2. The linked Vertex AI documentation mentions API keys (though it may be referring to service account keys)
  3. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority/p2Important but can be addressed in a future release.

    Type

    No type

    Projects

    Status
    Closed

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions