Closed MZRCode closed 1 week ago
Sorry, I must have made a small error when typing out that code snippet. It should be fixed now. The callback takes the entire export object, and doesn't automatically give the default. Thus, all you have to do is destructure the callback for default
inline and rename it to Gemini
again. Something like this should work:
import("gemini-ai").then(async ({ default: Gemini }) => {
let gemini = new Gemini(API_KEY);
});
I have also updated the FAQ as not to confuse future readers. https://github.com/EvanZhouDev/gemini-ai?tab=readme-ov-file#how-do-i-use-gemini-ai-in-a-cjs-environment
Thank you for pointing this out!
I'm using CommonJS and i am getting the error 'Gemini is not a constructor' even though i am doing it the way you mentioned at the bottom of the FAQ. I'm putting the necessary SS below. Have a nice day.