19 lines
502 B
TypeScript
19 lines
502 B
TypeScript
|
|
import { GoogleGenAI } from "@google/genai";
|
||
|
|
import * as dotenv from "dotenv";
|
||
|
|
dotenv.config();
|
||
|
|
|
||
|
|
const test = async () => {
|
||
|
|
const ai = new GoogleGenAI({ apiKey: process.env.VITE_GEMINI_API_KEY || process.env.GEMINI_API_KEY || '' });
|
||
|
|
try {
|
||
|
|
const response = await ai.models.generateContent({
|
||
|
|
model: "gemini-3.1-pro-preview",
|
||
|
|
contents: "Tell me a joke"
|
||
|
|
});
|
||
|
|
console.log("Success:", response.text);
|
||
|
|
} catch (err: any) {
|
||
|
|
console.error("Error:", err.message);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
test();
|