@genkit-ai/googleai
Version:
Genkit AI framework plugin for Google AI APIs, including Gemini APIs.
1 lines • 2.01 kB
Source Map (JSON)
{"version":3,"sources":["../src/list-models.ts"],"sourcesContent":["/**\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// Gemini model definition\nexport interface Model {\n name: string;\n baseModelId: string;\n version: string;\n displayName: string;\n description: string;\n inputTokenLimit: number;\n outputTokenLimit: number;\n supportedGenerationMethods: string[];\n temperature: number;\n maxTemperature: number;\n topP: number;\n topK: number;\n}\n\n// Gemini list models response\ninterface ListModelsResponse {\n models: Model[];\n nextPageToken?: string;\n}\n\n/**\n * List Gemini models by making an RPC call to the API.\n *\n * https://ai.google.dev/api/models#method:-models.list\n */\nexport async function listModels(\n baseUrl: string,\n apiKey: string\n): Promise<Model[]> {\n // We call the gemini list local models api:\n const res = await fetch(\n `${baseUrl}/v1beta/models?pageSize=1000&key=${apiKey}`,\n {\n method: 'GET',\n headers: {\n 'Content-Type': 'application/json',\n },\n }\n );\n const modelResponse = JSON.parse(await res.text()) as ListModelsResponse;\n return modelResponse.models;\n}\n"],"mappings":"AA2CA,eAAsB,WACpB,SACA,QACkB;AAElB,QAAM,MAAM,MAAM;AAAA,IAChB,GAAG,OAAO,oCAAoC,MAAM;AAAA,IACpD;AAAA,MACE,QAAQ;AAAA,MACR,SAAS;AAAA,QACP,gBAAgB;AAAA,MAClB;AAAA,IACF;AAAA,EACF;AACA,QAAM,gBAAgB,KAAK,MAAM,MAAM,IAAI,KAAK,CAAC;AACjD,SAAO,cAAc;AACvB;","names":[]}