@onepunya/ez-gemini
v1.3.0-saitekina
Published
A wrapper for Google Gemini (Gemini Ai) API supporting both CommonJS (CJS) and ECMAScript Modules (ESM).
Downloads
53
Maintainers
Readme
##@onepunya/ez-gemini
A wrapper for Google Gemini (Gemini Ai) API supporting both CommonJS (CJS) and ECMAScript Modules (ESM).
Installation
Install the package using npm:
npm install @onepunya/ez-gemini
#Usage
CommonJS (CJS)
Create a new file example.js and add the following code to use the package with CommonJS:
const Gemini = require('@onepunya/ez-gemini');
const gemini = new Gemini();
(async () => {
try {
const textResponse = await gemini.pro('Hello');
console.log('Text Response:', textResponse);
const imageResponse = await gemini.vision('https://example.com/image.jpg', 'Describe this image');
console.log('Response text:', imageResponse);
} catch (error) {
console.error('Error:', error);
}
})();
ECMAScript Modules (ESM)
Create a new file example.js and add the following code to use the package with ECMAScript Modules:
import Gemini from '@onepunya/ez-gemini';
const gemini = new Gemini();
(async () => {
try {
const textResponse = await gemini.pro('Hello');
console.log('Text Response:', textResponse);
const imageResponse = await gemini.vision('https://example.com/image.jpg', 'Describe this image');
console.log('Response text:', imageResponse);
} catch (error) {
console.error('Error:', error);
}
})();
//use personal apikey
new Gemini(apiKey)
//or leave it blank
new Gemini() //by default
##example
const Gemini = require('@onepunya/ez-gemini');
const gemini = new Gemini();
(async () => {
try {
const textResponse = await gemini.pro('Hello, world!');
console.log('Text Response:', textResponse);
const imageResponse = await gemini.vision('https://example.com/image.jpg', 'What is in this image?');
console.log('Image Response:', imageResponse);
} catch (error) {
console.error('Error:', error);
}
})();
follow me • github • insta • comunity
licence ISC