Files
ContentGen_BE/test-gemini-image.ts
Harun CAN 6627c213ec
Some checks are pending
Backend Deploy 🚀 / build-and-deploy (push) Waiting to run
main
2026-04-05 21:11:00 +03:00

27 lines
748 B
TypeScript

import { GoogleGenAI } from '@google/genai';
import * as dotenv from 'dotenv';
dotenv.config();
const ai = new GoogleGenAI({ apiKey: process.env.GEMINI_API_KEY });
async function listModels() {
console.log('Listing models...');
try {
let hasImagen = false;
let hasPreview = false;
// Iterate over pagination using valid SDK method if possible, but let's just use REST if not found.
// However, the new `@google/genai` has ai.models.list()
const response = await ai.models.list();
for await (const m of response) {
if (m.name.includes('image') || m.name.includes('imagen')) {
console.log(m.name);
}
}
} catch (error) {
console.error('Error listing models:', error);
}
}
listModels();