rpurinton / gemini-php

A PHP Library for Google Gemini AI
https://discord.gg/U9stSmpEYr
MIT License
20 stars 8 forks source link

Permission 'aiplatform.endpoints.predict' denied #2

Closed fx1234 closed 9 months ago

fx1234 commented 9 months ago

Hello,

Thank you for this great library. I always get the following error and don't know where to set the permission:

Fatal error: Uncaught Exception: Error Code: 403, Message: Permission 'aiplatform.endpoints.predict' denied on resource '//aiplatform.googleapis.com/projects/gemini-xxxxxx/locations/us-central1/publishers/google/models/gemini-pro' (or it may not exist)., Status: PERMISSION_DENIED in ../composer/vendor/rpurinton/gemini-php/src/GeminiResponse.php:19

Can you help me with that?

rpurinton commented 9 months ago

GPT4 Response:

Hey, it seems like there's a permissions issue with the service account. Let's go through the steps to sort this out:

If the issue persists, double-check that the service account keys are correctly set in your environment, and you're pointing to the right project with the correct resource identifiers. Let me know how it goes!

rpurinton commented 9 months ago

Gemini BOT — Today at 5:28 PM Certainly, here is a step-by-step guide on how to grant your service account the necessary permissions:

Your service account should now be able to access the Vertex AI API.

In addition to the above steps, you will also need to grant your service account access to the Google Cloud Storage bucket that you are using to store your model and data. The easiest way to do this is to make your bucket publicly readable.

Please let me know if you have any other questions.

rpurinton commented 9 months ago

@fx1234 :

My actual human reply: Hey :)

This sounds like the kind of error I would expect if you don't have permissions set up on your project correctly. I asked GPT4 and Gemini to provide some steps to help get you started. I have not validated or checked the accuracy of what either one said, so you could let us know if you were successful and what actual steps you used to resolve this. Thanks!

fx1234 commented 9 months ago

Hello @rpurinton,

thanks for your help.

I found a post on Stackoverflow that recommended deleting the current project in the Google Cloud Platform Console and creating a new one. I did that (with the same permissions as the old project) and .... it works now :)

So, if someone has the same problem, it may help to create a new project (with basic permissions).