Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Sep 19, 2025. It is now read-only.

RahadyanRizqy/GAWA.JS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

48 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Gemini AI Wrapper API (JavaScript Version)

Gemini Banner

Gemini Icon Gemini-API

A JavaScript implementation of the Gemini AI Wrapper API, providing Node.js modules. This project is a remake and direct translation of the original Python version available at HanaokaYuzu/Gemini-API which is currently mimic the v1.15.2 (latest) version of the gemini_webapi.

πŸš€ Features

  • Persistent Cookies - Automatically refreshes cookies in background. Optimized for always-on services (currently tested).
  • Image Generation - Natively supports generating and modifying images with natural language. (60% success)
  • System Prompt - Supports customizing model's system prompt with Gemini Gems.
  • Extension Support - (unimplemented yet)
  • Classified Outputs - Categorizes texts, thoughts, web images and AI generated images in the response.
  • Official Flavor - Provides a simple and elegant interface inspired by Google Generative AI's official API.

πŸ“‹ Prerequisites

  • Node.js (v22+)
  • Cloudflare account with Wrangler CLI
  • Google Gemini cookies (for authentication)
  • Cloudflare D1 database (for token revocation)

πŸ› οΈ Installation

A. Install from NPM

npm i gawa.js

B. Clone from github

git clone https://github.com/RahadyanRizqy/GAWA.JS.git gawajs
cd gawajs

✨ Usage

Basic Setup

import { GeminiClient, setLogLevel } from 'gawa.js';

/*
By default setLogLevel is set to debug mode
you may change my

import { setLogLevel } from 'gawa.js';

setLogLevel('debug');
*/

const client = new GeminiClient({
    cookieHeader: 'your-cookie-header-here'
});

(async() => {
    await client.init();

    // execute here ...
})();

Generate Content

// Simple text generation
const response = await client.generateContent({ prompt: 'Hello' });
console.log(response.text);

// With files
const response = await client.generateContent({
    prompt: 'Explain this image',
    files: [path.resolve('./image.jpg')]
});
console.log(response.text);

Chat Conversations

const chat = client.startChat();
const response1 = await chat.sendMessage('What is the capital of Russia?');
console.log(response1.text);

const response2 = await chat.sendMessage('And what is the population?');
console.log(response2.text);

Using Different Models

const response = await client.generateContent({
    prompt: "What's your language model version?",
    model: 'gemini-2.5-flash'
});
console.log(response.text);

Creating Custom Gems

const newGem = await client.createGem(
    'Python Tutor',
    'You are a helpful Python programming tutor.',
    'A specialized gem for Python programming'
);

const response = await client.generateContent({
    prompt: 'Explain how list comprehensions work in Python',
    gem: newGem
});
console.log(response.text);

Handling Images

const response = await client.generateContent({
    prompt: 'Generate some pictures of cats'
});

for (const image of response.images) {
    await image.save({ path: 'temp/', filename: `cat.png` });
}

For more advanced usage, see test.js.

πŸ”— References

❗ Notes (Known Failures)

  • The autorefresh logging might shows error but it works perfectly
  • Express.js API (currently tested) integration works for more than 2 days
  • Discord.js (currently tested) integration fails to send/receive message after couple of hours, this might be due to cookie refreshment mechanism that isn't suitable for discord event-driven message (need external API like Express.js/Fastify)

About

πŸ’« Reverse-engineered JavaScript API for Google Gemini web app (from HanaokaYuzu/Gemini-API)

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published