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.
- 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.
- Node.js (v22+)
- Cloudflare account with Wrangler CLI
- Google Gemini cookies (for authentication)
- Cloudflare D1 database (for token revocation)
A. Install from NPM
npm i gawa.jsB. Clone from github
git clone https://github.com/RahadyanRizqy/GAWA.JS.git gawajs
cd gawajsimport { 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 ...
})();// 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);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);const response = await client.generateContent({
prompt: "What's your language model version?",
model: 'gemini-2.5-flash'
});
console.log(response.text);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);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.
- 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)