I'm encountering issues when trying to use the @ai-sdk/google-vertex with Google Vertex AI. It appears that the documentation might be incomplete, as I found several forum posts from users facing the same challenges, with no clear solution available.
The documentation suggests using the following setup:
However, I'm seeing multiple errors when I attempt to implement this:
Project Setting Error:
[cause]: LoadSettingError [AI_LoadSettingError]: Google Vertex project setting is missing. Pass it using the 'project' parameter or the GOOGLE_VERTEX_PROJECT environment variable.
Authentication Error:
[cause]: GoogleAuthError: [VertexAI.GoogleAuthError]:
Unable to authenticate your request
Guidance in the error message suggested options like running gcloud auth login, or using authentication methods for Google Colab and service accounts, which I have tried but without success.
Permission Denied Error:
[cause]: ClientError: [VertexAI.ClientError]: got status: 403 Forbidden.
{"error":{"code":403,"message":"Permission 'aiplatform.endpoints.predict' denied on resource '//aiplatform.googleapis.com/projects/'_project-id_/locations/us-central1/publishers/google/models/gemini-1.5-pro' (or it may not exist).","status":"PERMISSION_DENIED","details":[{"@type":"type.googleapis.com/google.rpc.ErrorInfo","reason":"IAM_PERMISSION_DENIED","domain":"aiplatform.googleapis.com","metadata":{"resource":"projects/project/locations/us-central1/publishers/google/models/gemini-1.5-pro-002","permission":"aiplatform.endpoints.predict"}}]}}
I have attempted multiple approaches, including setting environment variables manually and programmatically, but none of these resolved the issue.
Code example
import { vertex } from '@ai-sdk/google-vertex';
import { generateText } from 'ai';
const { text } = await generateText({
model: vertex('gemini-1.5-pro'),
messages: [
{
role: 'user',
content: [
{
type: 'text',
text: 'What is your name?',
},
],
},
],
});
AI provider
@ai-sdk/google-vertex": "^0.0.33
Additional context
I've ensured my project and location are correct and that they match my Google Vertex setup. I've also followed the guidance in the documentation for environment variable settings and tried additional configurations per other user suggestions, including the authentication instructions provided in the error messages. None of these steps have resolved the issue, and I'm unsure if there's a configuration step or required permission missing in the SDK documentation.
Could you please provide more detailed guidance on using @ai-sdk/google-vertex with Google Vertex AI?
Description
I'm encountering issues when trying to use the @ai-sdk/google-vertex with Google Vertex AI. It appears that the documentation might be incomplete, as I found several forum posts from users facing the same challenges, with no clear solution available.
The documentation suggests using the following setup:
However, I'm seeing multiple errors when I attempt to implement this:
[cause]: LoadSettingError [AI_LoadSettingError]: Google Vertex project setting is missing. Pass it using the 'project' parameter or the GOOGLE_VERTEX_PROJECT environment variable.
Guidance in the error message suggested options like running gcloud auth login, or using authentication methods for Google Colab and service accounts, which I have tried but without success.
I have attempted multiple approaches, including setting environment variables manually and programmatically, but none of these resolved the issue.
Code example
AI provider
@ai-sdk/google-vertex": "^0.0.33
Additional context
I've ensured my project and location are correct and that they match my Google Vertex setup. I've also followed the guidance in the documentation for environment variable settings and tried additional configurations per other user suggestions, including the authentication instructions provided in the error messages. None of these steps have resolved the issue, and I'm unsure if there's a configuration step or required permission missing in the SDK documentation.
Could you please provide more detailed guidance on using @ai-sdk/google-vertex with Google Vertex AI?