generative-ai-docs
generative-ai-docs copied to clipboard
google.api_core.exceptions.PermissionDenied: 403
Description of the bug:
Trying to use AI Studio locally with the Gemini tuned model with the following code:
"""
At the command line, only need to run once to install the package via pip:
$ pip install google-generativeai
"""
import google.generativeai as genai
genai.configure(api_key="YOUR_API_KEY")
# Set up the model
generation_config = {
"temperature": 0.9,
"top_p": 1,
"top_k": 1,
"max_output_tokens": 8192,
}
safety_settings = [
{
"category": "HARM_CATEGORY_HARASSMENT",
"threshold": "BLOCK_MEDIUM_AND_ABOVE"
},
{
"category": "HARM_CATEGORY_HATE_SPEECH",
"threshold": "BLOCK_MEDIUM_AND_ABOVE"
},
{
"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
"threshold": "BLOCK_MEDIUM_AND_ABOVE"
},
{
"category": "HARM_CATEGORY_DANGEROUS_CONTENT",
"threshold": "BLOCK_MEDIUM_AND_ABOVE"
},
]
model = genai.GenerativeModel(model_name="tunedModels/sdfs-dfsf-sdfsadf",
generation_config=generation_config,
safety_settings=safety_settings)
prompt_parts = [
BLABLABLA
]
response = model.generate_content(prompt_parts)
print(response.text)
Actual vs expected behavior:
Expect return a generated response but get:
envs\gemini\lib\site-packages\google\api_core\grpc_helpers.py", line 78, in error_remapped_callable
raise exceptions.from_grpc_error(exc) from exc
google.api_core.exceptions.PermissionDenied: 403 You do not have permission to access tuned model tunedModels/sdfsdfasdfasdfa.
Any other information you'd like to share?
No response
same error
@zzj0402, This repository is for issues related to website(https://ai.google.dev/) like documentation bugs or improvements. For issues related to AI Studio, we would suggest you to use "Send Feedback" option in AI Studio. Ref: Screenshot below. Thank you!
Same error here. I assume oauth is somewhat related to this issue, and I think people need some additional guidance. https://ai.google.dev/docs/oauth_quickstart
Marking this issue as stale since it has been open for 14 days with no activity. This issue will be closed if no further activity occurs.
""" At the command line, only need to run once to install the package via pip:
$ pip install google-generativeai """
import google.generativeai as genai
genai.configure(api_key="YOUR_API_KEY")
Set up the model
generation_config = { "temperature": 1, "top_p": 0.95, "top_k": 0, "max_output_tokens": 8192, }
safety_settings = [ { "category": "HARM_CATEGORY_HARASSMENT", "threshold": "BLOCK_MEDIUM_AND_ABOVE" }, { "category": "HARM_CATEGORY_HATE_SPEECH", "threshold": "BLOCK_MEDIUM_AND_ABOVE" }, { "category": "HARM_CATEGORY_SEXUALLY_EXPLICIT", "threshold": "BLOCK_MEDIUM_AND_ABOVE" }, { "category": "HARM_CATEGORY_DANGEROUS_CONTENT", "threshold": "BLOCK_MEDIUM_AND_ABOVE" }, ]
model = genai.GenerativeModel(model_name="gemini-1.5-pro-latest", generation_config=generation_config, safety_settings=safety_settings)
convo = model.start_chat(history=[ ])
convo.send_message("YOUR_USER_INPUT") print(convo.last.text)
rbrisita:fix_doc
Reenvs\gemini\lib\site-packages\google\api_core\grpc_helpers.py", line 78, in error_remapped_callable raise exceptions.from_grpc_error(exc) from exc google.api_core.exceptions.PermissionDenied: 403 You do not have permission to access tuned model tunedModels/sdfsdfasdfasdfa.ference i
Marking this issue as stale since it has been open for 14 days with no activity. This issue will be closed if no further activity occurs.
This issue is still there, the code given in ai studio doesn't work with the ai studio api key.
Package versions: google-ai-generativelanguage==0.6.4 google-api-core==2.19.0 google-api-python-client==2.130.0 google-auth==2.29.0 google-auth-httplib2==0.2.0 google-generativeai==0.5.4 googleapis-common-protos==1.63.0 langchain-google-genai==1.0.5
Error: raise exceptions.from_grpc_error(exc) from exc google.api_core.exceptions.PermissionDenied: 403 You do not have permission to access tuned model tunedModels/nextnum-k7f103e3mv0y.
Marking this issue as stale since it has been open for 14 days with no activity. This issue will be closed if no further activity occurs.
This issue was closed because it has been inactive for 28 days. Please post a new issue if you need further assistance. Thanks!
Same error. Not able to access the fine tuned model.
gcloud auth application-default login --client-id-file client_secret.json --scopes='https://www.googleapis.com/auth/cloud-platform,https://www.googleapis.com/auth/generative-language.tuning' Try this command, first get a client_secret: https://ai.google.dev/gemini-api/docs/oauth But i am stuck in a weird situation. This method works when i run a standalone python script but it doesnt work when i add the gemini model in a django api.