generative-ai-js icon indicating copy to clipboard operation
generative-ai-js copied to clipboard

Error: You do not have permission to access tuned model

Open IvanMMM opened this issue 1 year ago • 8 comments

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

  1. Follow this steps https://ai.google.dev/docs/oauth_quickstart
  2. Export path as GOOGLE_APPLICATION_CREDENTIALS
  3. Create new generative model with tuned model
const model = this.ai.getGenerativeModel({
  model: "tunedModels/MODEL_NAME",
})
  1. Use tuned model as usually
await model.generateContent(`Some text`);

Specifications

  • Version: 0.6.0
  • Platform: MacOS

IvanMMM avatar Apr 15 '24 12:04 IvanMMM

  1. 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/generativelanguage which is the deprecated autogenerated Node library, which did work with OAuth. I'll try to get this removed or fixed.

  2. 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.

  3. 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 avatar Apr 24 '24 17:04 hsubox76

@hsubox76 Can you tell me where I can find information for the 3rd point you mentioned? (making everyone a reader)

MadCoderme avatar Apr 24 '24 18:04 MadCoderme

@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.

IvanMMM avatar Apr 30 '24 05:04 IvanMMM

Noo, this hasn't been addressed yet. Wasted an hour with GOOGLE_APPLICATION_CREDENTIALS.

zhefciad avatar Apr 30 '24 16:04 zhefciad

Still facing this problem? Not fixed yet?

pnedelko avatar Jun 14 '24 15:06 pnedelko

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

Ayush783 avatar Jun 28 '24 07:06 Ayush783

Any progress in NodeJS here? I'm trying to do the same thing.

gTutini avatar Jul 10 '24 05:07 gTutini

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???

churromorales20 avatar Aug 07 '24 23:08 churromorales20

Any update on this ? Anyone able to make it work ?

humzawaseem avatar Aug 26 '24 21:08 humzawaseem

@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.

How did you solve this ? Can you share like a snippet ? I am trying passing service account and api key both but still failing.

humzawaseem avatar Aug 26 '24 21:08 humzawaseem

Hi @logankilpatrick Please do something about this it's been 4 months and the issue is not fixed yet.

Iven2132 avatar Aug 31 '24 13:08 Iven2132

@hsubox76 Why don't you fix this? It's such a time-waster.

Iven2132 avatar Aug 31 '24 14:08 Iven2132

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.

Iven2132 avatar Sep 04 '24 06:09 Iven2132

You should now be able to access Tuned models via API keys. See the button titled Add API access underneath your tuned model details.

API Key Access

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.

ryanwilson avatar Sep 06 '24 16:09 ryanwilson