The HTTP header for Authorization is the key element that your container needs to be able to produce. As you might see, it call the gcloud CLI to get the necessary access token.
Error: ClientError("401 UNAUTHENTICATED. {'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', 'details': [{'@type': 'type.googleapis.com/google.rpc.ErrorInfo', 'reason': 'CREDENTIALS_MISSING', 'domain': 'googleapis.com', 'metadata': {'method': 'google.cloud.aiplatform.v1beta1.PredictionService.GenerateContent', 'service': 'aiplatform.googleapis.com'}}]}}")
I use Gemini API key. Is that the right key to use?
No, authentication for Vertex AI is based on GCP credentials as referred in the ADC link above. You’d need an access token instead of an API key. When you initialize the genai client you specify a project and a location parameter.
Ok, there is a small exception: Vertex AI in express mode works using a different API key than the one created in AI Studio.