google-cloud-platformgoogle-apigoogle-oauthgoogle-gemini

Uncaught (in promise) Error: [403 ] You do not have permission to access tuned model tunedModels/thefine-tuned-model-f64sf654sf


I have tuned a model using gemini and trying to access the model using plain js using google chrome(loged in to my google account through which I have tuned the model). When I executing the js it shows error like in the title.

import { GoogleGenerativeAI } from "@google/generative-ai";

// Fetch your API_KEY
const API_KEY = "MyApIKey";

// Access your API key (see "Set up your API key" above)
const genAI = new GoogleGenerativeAI(API_KEY);


async function run() {
    // For text-only input, use the gemini-pro model
    //const model = genAI.getGenerativeModel({ model: "gemini-pro"});
    const model = genAI.getGenerativeModel({ model: "tunedModels/thefine-tuned-model-f64sf654sf" });

    const prompt = "Some prompt for asking questions?"

    const result = await model.generateContent(prompt);
    const response = await result.response;
    const text = response.text();
    console.log(text);
}

run();

This js code is used in an html file inside the script tag.

I want to get the prompt working. Please suggest any solutions.


Solution

  • Tuned model may contain your data, it needs stricter access control than API keys. You need to set up user authentication with OAuth credentials as documented here.

    It is also mentioned in the model tuning troubleshooting section.