Error
<code> google.auth.exceptions.DefaultCredentialsError: Your default credentials were not found. To set up Application Default Credentials, see https://cloud.google.com/docs/authentication/external/set-up-adc for more information.
</code>
<code> google.auth.exceptions.DefaultCredentialsError: Your default credentials were not found. To set up Application Default Credentials, see https://cloud.google.com/docs/authentication/external/set-up-adc for more information.
</code>
google.auth.exceptions.DefaultCredentialsError: Your default credentials were not found. To set up Application Default Credentials, see https://cloud.google.com/docs/authentication/external/set-up-adc for more information.
Source code
<code> import vertexai
from vertexai.preview.generative_models import GenerativeModel, Image
PROJECT_ID = "PROJECT_ID"
REGION = "us-central1"
api_key="xxxxx"
vertexai.init(project=PROJECT_ID, location=REGION,api_key=api_key)
IMAGE_FILE = "C:\Users\User\Downloads\food.jpg"
image = Image.load_from_file(IMAGE_FILE)
generative_multimodal_model = GenerativeModel("gemini-1.5-flash-002")
response = generative_multimodal_model.generate_content(["What is shown in this image?", image])
print(response)
</code>
<code> import vertexai
from vertexai.preview.generative_models import GenerativeModel, Image
PROJECT_ID = "PROJECT_ID"
REGION = "us-central1"
api_key="xxxxx"
vertexai.init(project=PROJECT_ID, location=REGION,api_key=api_key)
IMAGE_FILE = "C:\Users\User\Downloads\food.jpg"
image = Image.load_from_file(IMAGE_FILE)
generative_multimodal_model = GenerativeModel("gemini-1.5-flash-002")
response = generative_multimodal_model.generate_content(["What is shown in this image?", image])
print(response)
</code>
import vertexai
from vertexai.preview.generative_models import GenerativeModel, Image
PROJECT_ID = "PROJECT_ID"
REGION = "us-central1"
api_key="xxxxx"
vertexai.init(project=PROJECT_ID, location=REGION,api_key=api_key)
IMAGE_FILE = "C:\Users\User\Downloads\food.jpg"
image = Image.load_from_file(IMAGE_FILE)
generative_multimodal_model = GenerativeModel("gemini-1.5-flash-002")
response = generative_multimodal_model.generate_content(["What is shown in this image?", image])
print(response)
What is the right way to set the google key from the code?
It uses gemini API key or Google Cloud API Key?