JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 3
  • Score
    100M100P100Q54741F
  • License ISC

Package Exports

  • @onepunya/ez-gemini

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