Update date: 2025.03.31 Author: df
Google Gemini API Models list. Json format and name only list. Gemini API provides an endpoint to retrieve the models information.
Sometimes I only need a pure model list, but I couldn't find what I wanted. So I wrote this JS script to get them.
If this is out-of-date. Please @DF-wu
, I will update them as soon as possible.
// your gemini api key
let geminiKey="";
let OriginalModels={};
let nameOnlyList = [];
let realModelNames = [];
let GeminiModelsSplitByComma=""
// gemini api
fetch(`https://generativelanguage.googleapis.com/v1beta/models?key=${geminiKey}`)
.then(response => {
return response.json();
})
.then(data => {
OriginalModels = data;
console.log(data)
// get the name only list
OriginalModels.models.forEach(model => {
nameOnlyList.push(model.name);
});
// get the real model name
nameOnlyList.forEach(model => {
let name = model.split('/')[1];
realModelNames.push(name);
});
GeminiModelsSplitByComma = realModelNames.join(',');
// print
console.log(GeminiModelsSplitByComma);
console.log(nameOnlyList);
console.log(realModelNames);
})
.catch(error => console.error(error));