19 lines
425 B
TypeScript
19 lines
425 B
TypeScript
|
|
import { GoogleGenAI } from "@google/genai";
|
||
|
|
import * as dotenv from "dotenv";
|
||
|
|
dotenv.config();
|
||
|
|
|
||
|
|
const test = async () => {
|
||
|
|
const ai = new GoogleGenAI({});
|
||
|
|
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();
|