UNPKG

plugai

Version:

PlugAI is a library that provides interfaces to various AI models like Gemini, DeepSeek, and OpenAI.

22 lines (19 loc) 616 B
import axios from 'axios'; import { BaseModel } from './baseModel'; export class Gemini extends BaseModel { private modelUrl: string = 'https://api.gemini.com/v1/query'; async request(inputData: any, url?: string): Promise<any> { try { const requestUrl = url || this.modelUrl; const response = await axios.post(requestUrl, inputData, { headers: { 'Authorization': `Bearer ${this.apiKey}`, 'Content-Type': 'application/json', }, }); return response.data; } catch (error) { throw new Error(`Gemini request failed: ${error}`); } } }