Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@onepunya/ez-gemini

onepunya25ISC1.3.0-saitekina

A wrapper for Google Gemini (Gemini Ai) API supporting both CommonJS (CJS) and ECMAScript Modules (ESM).

ai, gpt, gemini, gemini vision, Whatsapp bot, bot, discord bot, REST api, Api, Free, Onesytex-Api, mr.one, gpt

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 • githubinstacomunity

licence ISC