New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@izumiapi/gemini-api

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@izumiapi/gemini-api

A module to connect to gemini api.

latest
npmnpm
Version
1.0.2
Version published
Maintainers
1
Created
Source

@izumiapi/gemini-api

🚧 This package is currently in testing/maintenance phase 🚧

A simple and lightweight wrapper for Google's Gemini AI API that provides session-based chat functionality with automatic conversation history management.

Features

  • 💬 Session-based chat conversations
  • 📝 Automatic conversation history tracking
  • 🔒 Secure API key handling
  • 🚀 Easy to use and integrate
  • 📦 Lightweight with minimal dependencies

Installation

npm install @izumiapi/gemini-api

Quick Start

import { ConnectToGemini } from '@izumiapi/gemini-api';

// Initialize with your Google AI API key
const gemini = new ConnectToGemini({
    apiKey: 'your-google-ai-api-key'
});

// Start chatting with session management
const response = await gemini.chatSession({
    idSesi: 'user123',
    chat: 'Hello, how are you?'
});

console.log(response.result);

API Reference

Constructor

new ConnectToGemini({ apiKey })

Parameters:

  • apiKey (string, required): Your Google AI API key

Methods

chatSession({ idSesi, chat })

Send a message and get a response while maintaining conversation history.

Parameters:

  • idSesi (string, required): Unique session identifier for conversation tracking
  • chat (string, required): The message to send to Gemini

Returns:

{
    success: true,
    result: "AI response text",
    sessions: [...] // Complete conversation history
}

Usage Examples

Basic Chat

const gemini = new ConnectToGemini({
    apiKey: process.env.GOOGLE_AI_API_KEY
});

try {
    const response = await gemini.chatSession({
        idSesi: 'session-001',
        chat: 'Explain quantum computing in simple terms'
    });
    
    console.log('AI Response:', response.result);
    console.log('Conversation History:', response.sessions);
} catch (error) {
    console.error('Error:', error.message);
}

Multiple Sessions

// Different users with separate conversation histories
const user1Response = await gemini.chatSession({
    idSesi: 'user-1',
    chat: 'What is JavaScript?'
});

const user2Response = await gemini.chatSession({
    idSesi: 'user-2', 
    chat: 'How to cook pasta?'
});

// Continue user-1's conversation
const user1Followup = await gemini.chatSession({
    idSesi: 'user-1',
    chat: 'Can you give me an example?'
});

Environment Variables

Create a .env file:

GOOGLE_AI_API_KEY=your_actual_api_key_here
import dotenv from 'dotenv';
dotenv.config();

const gemini = new ConnectToGemini({
    apiKey: process.env.GOOGLE_AI_API_KEY
});

Getting Your API Key

  • Visit Google AI Studio
  • Sign in with your Google account
  • Create a new API key
  • Copy the key and use it in your application

⚠️ Security Note: Never expose your API key in client-side code or commit it to version control. Always use environment variables.

Error Handling

The package includes built-in error handling for common scenarios:

try {
    const response = await gemini.chatSession({
        idSesi: 'test-session',
        chat: 'Hello world!'
    });
    console.log(response.result);
} catch (error) {
    if (error.message.includes('session ID')) {
        console.error('Session ID is required');
    } else if (error.message.includes('message')) {
        console.error('Chat message is required');
    } else {
        console.error('Unexpected error:', error.message);
    }
}

Model Information

This package uses the gemini-2.0-flash-001 model, which provides:

  • Fast response times
  • High-quality text generation
  • Multi-turn conversation support

Limitations

  • Currently in testing/maintenance phase
  • Requires valid Google AI API key
  • Internet connection required
  • Subject to Google AI API rate limits and quotas

Development Status

🚧 Testing/Maintenance Phase

This package is actively being tested and maintained. Features may change, and we recommend:

  • Testing thoroughly in development environments
  • Checking for updates regularly
  • Reporting issues on our repository

Support

For questions, issues, or feature requests, please open an issue on our GitHub repository.

Note: This package is not officially affiliated with Google. Google AI and Gemini are trademarks of Google LLC.

FAQs

Package last updated on 15 Sep 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts