generative-ai-js
generative-ai-js copied to clipboard
Error: You do not have permission to access tuned model
Expected Behavior
User has access to tuned models after using Application Default Credentials (ADC) and exporting default credentials
Actual Behavior
User does not have an access to a model. Request failed with error Error fetching from https://generativelanguage.googleapis.com/v1/tunedModels/MODEL_NAME:generateContent: [403 Forbidden] You do not have permission to access tuned model MODEL_NAME
Steps to Reproduce the Problem
- Follow this steps https://ai.google.dev/docs/oauth_quickstart
- Export path as GOOGLE_APPLICATION_CREDENTIALS
- Create new generative model with tuned model
const model = this.ai.getGenerativeModel({
model: "tunedModels/MODEL_NAME",
})
- Use tuned model as usually
await model.generateContent(`Some text`);
Specifications
- Version: 0.6.0
- Platform: MacOS
-
To be clear, this SDK doesn't use oauth, so setting GOOGLE_APPLICATION_CREDENTIALS won't do anything. I see instructions on that page that say it works with the Node client SDK: https://ai.google.dev/gemini-api/docs/oauth In the sample code, it's importing from
@google-ai/generativelanguagewhich is the deprecated autogenerated Node library, which did work with OAuth. I'll try to get this removed or fixed. -
Since this SDK is unable to use OAuth, we can't authenticate to the tuned models. We are working on a way to make tunedModels accessible using only the API key. I'll try to update when this is in place.
-
In the meantime, the only way to access tuned models using this SDK is to change the permissions of the tuned model to make everyone a reader. I don't have detailed steps on how to set this, and it does seem a little dangerous, so maybe it's best to wait until we've made tuned models accessible by API key.
Sorry, I know this is pretty inconvenient, from the confusing docs to the fact that we allow you to call the tuned models endpoint, but don't have an official way to set permissions. Hopefully we can get this fixed soon.
@hsubox76 Can you tell me where I can find information for the 3rd point you mentioned? (making everyone a reader)
@hsubox76 thank you for your answer
Indeed, instructions mention another library, and that confused me too. I hope you will find a way to make tuned models accessible by API. For the time being I had to use @google-ai/generativelanguage codebase, since, it looks like this is an only way for now.
Noo, this hasn't been addressed yet. Wasted an hour with GOOGLE_APPLICATION_CREDENTIALS.
Still facing this problem? Not fixed yet?
Hey, I solved the same issue in Flutter by passing the Oauth token from Google Sign in as Authorization header. maybe you can try a similar thing. Explained in detail here - https://medium.com/@Ayush_b58/accessing-tuned-gemini-model-in-flutter-30d07843d2e2
Any progress in NodeJS here? I'm trying to do the same thing.
y to make tuned models accessible by API. For the time being I had to use
@google-ai/generativelanguage
hey mate hello, could you please describe a lil about exactly what's the approach to follow with the code base???
Any update on this ? Anyone able to make it work ?
@hsubox76 thank you for your answer Indeed, instructions mention another library, and that confused me too. I hope you will find a way to make tuned models accessible by API. For the time being I had to use
@google-ai/generativelanguagecodebase, since, it looks like this is an only way for now.
How did you solve this ? Can you share like a snippet ? I am trying passing service account and api key both but still failing.
Hi @logankilpatrick Please do something about this it's been 4 months and the issue is not fixed yet.
@hsubox76 Why don't you fix this? It's such a time-waster.
Can anyone please fix this issue Google doesn't give a f about their customers facing this issue and they are doing nothing to fix this.
I wish Google would lay off 90% of its workforce so their engineer is busy doing stuff rather than posting memes on X.
You should now be able to access Tuned models via API keys. See the button titled Add API access underneath your tuned model details.
Thanks folks for your patience, there are a lot of moving parts to get features like this working. For future issues please remember to keep comments on topic and about the issue itself.