Google Ai studio tuned model

please does anyone have an idea on how to integrate gemini tuned model into an angular application please i need some help here. I created the tunned model using Google AI studio

Hi @fru_blieden_ndi,

Can you a take look at this tutorial बेहतर बनाने का ट्यूटोरियल  |  Gemini API  |  Google for Developers it may help you.

I am not sure about the angular but probably you can use curl operation and tutorial has steps to fine-tune the model and get started.

Thanks!

Thanks But I have been trying to do this for over a week now to no avail i have tried everything under the sun I have read several documentations still no solution accessing the standard gemini model goes fine how ever the issue occurs when i am trying to access the fine tunned model
below is the code i use to make the request

// import { Injectable } from '@angular/core';
// import { HttpClient } from '@angular/common/http';
// import { Observable } from 'rxjs';

// @Injectable({
//   providedIn: 'root'
// })
// export class GeminiService {

//   private apiUrl = 'http://127.0.0.1:6000/predict';  // Replace with your server's IP or domain

//   constructor(private http: HttpClient) { }

//   predict(input: string): Observable<any> {
//     return this.http.post<any>(this.apiUrl, { input });
//   }
// }
import { Injectable } from '@angular/core';
import { GoogleGenerativeAI, HarmCategory, HarmBlockThreshold } from '@google/generative-ai';
import { environment } from '../../environments/environment';

@Injectable({
  providedIn: 'root'
})
export class GeminiService {
  private genAI: GoogleGenerativeAI;
  private model: any;

  constructor() {
    this.genAI = new GoogleGenerativeAI(environment.GeminiKey);
    this.model = this.genAI.getGenerativeModel({
      model: "enviroment.ModelID",
    });
  }

  async generateContent(input: string): Promise<string> {
    const generationConfig = {
      temperature: 0.9,
      topP: 1,
      maxOutputTokens: 8192,
      responseMimeType: "text/plain",
    };

    const parts = [
      { text: `input: ${input}` },
      { text: "output: " },
    ];

    try {
      const result = await this.model.generateContent({
        contents: [{ role: "user", parts }],
        generationConfig,
        // safetySettings: Adjust safety settings as needed
      });

      return result.response.text();
    } catch (error) {
      console.error('Error generating content:', error);
      throw error;
    }
  }
}`Preformatted text`
I Keep Getting error

[403 ] You do not have permission to access tuned model

Welcome @fru_blieden_ndi

For some reason tuned models can only be accessed by oAuth and not using the API key.

Thus you need to use oAuth as the authentication method.

Here’s a sample from cookbook to get you started:
cookbook/quickstarts/Tuning.ipynb at main · google-gemini/cookbook · GitHub

1 Like

please does not still work do you have a solution in any language please

What error are you getting @fru_blieden_ndi ?

my previous code gives the permisssion error and my new code i have tried to do it using Node now but no avail if i can get the working code in any language i can put my credentials there to test it

you can call it using rest api. see docs hre for request format: