Skip to content

KudoAI/chatgpt.js

Repository files navigation




⚡ Installation

Library

Node.js:

From your project root:

npm install @kudoai/chatgpt.js

Web:

<script src="https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@4/dist/chatgpt.min.js"></script>

Greasemonkey:

Note To use a starter template: KudoAI/chatgpt.js-greasemonkey-starter

// @require https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@4/dist/chatgpt.min.js
// ==/UserScript==

Chrome:

Note To use a starter template: KudoAI/chatgpt.js-chrome-starter

  1. Save https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@4/dist/chatgpt.min.js to lib

  2. In project's (V3) manifest.json, add lib/chatgpt.min.js as a web accessible resource

    "web_accessible_resources": [{
        "matches": ["<all_urls>"],
        "resources": ["lib/chatgpt.min.js"]
    }],

CLI app

Node.js:

npm install -g @kudoai/chatgpt.js

API keys

Supported providers:

OpenRouter — 300+ models, dozens free

1. Create API key: https://openrouter.ai/settings/keys

2. Add key to environment:

Windows:
setx OPENROUTER_API_KEY "sk-or-v1-8a69..."
Mac/Linux:
export OPENROUTER_API_KEY="sk-or-v1-8a69..."
Google AI — Gemini + Gemma models

1. Create API key: https://aistudio.google.com/api-keys

2. Add key to environment:

Windows:
setx GOOGLE_API_KEY "AIzaSyB..."
Mac/Linux:
export GOOGLE_API_KEY="AIzaSyB..."

💻 Usage

ES Modules (ESM):

import chatgpt from '@kudoai/chatgpt.js'

console.log(await chatgpt.send('sup'))
// e.g. => Hey! Not much—just here and ready to help. What's up with you?

CommonJS (CJS):

(async () => {
    const chatgpt = require('@kudoai/chatgpt.js')

    console.log(await chatgpt.send('sup'))
    // e.g. => Hey! What's up?
})()

Chrome:

(async () => {
    await import(chrome.runtime.getURL('lib/chatgpt.min.js'))

    await chatgpt.isLoaded()
    console.log('ChatGPT is ready!') 
})()

Terminal:

chatgpt --query "sup"  # or cjs -q sup
# e.g. => Hey there! What's up?

For more options & examples, see the extended userguide:

https://github.com/KudoAI/chatgpt.js/blob/v4.0.2/docs/USERGUIDE.md



🚀 Made with chatgpt.js

Add AI chat & product/category summaries to Amazon shopping, powered by the latest LLMs!

Greasemonkey / Readme / Discuss

Auto-clear your ChatGPT query history for maximum privacy.

Greasemonkey / Readme / Discuss

Add AI chat & search summaries to Brave Search, powered by the latest LLMs!

Greasemonkey / Readme / Discuss

Automatically continue generating answers when ChatGPT responses get cut-off.

Chrome / Firefox / Edge / Readme / Discuss


Have a library idea or request?

Create a new discussion: https://github.com/KudoAI/chatgpt.js/discussions/new?category=ideas


Keeps ChatGPT sessions fresh, eliminating chat time limits + network errors + Cloudflare checks.

Greasemonkey / Readme / Discuss

Auto-play ChatGPT responses.

Greasemonkey / Readme / Discuss

Generate endless answers from all-knowing ChatGPT (on any topic!)

Chrome / Firefox / Edge / Greasemonkey / Readme / Discuss

Enhances ChatGPT with wide/full/tall-screen + spamblock modes. Also works on poe.com!

Chrome / Firefox / Edge / Greasemonkey / Readme / Discuss

Add AI chat & search summaries to DuckDuckGo, powered by the latest LLMs!

Greasemonkey / Readme / Discuss

Add AI chat & search summaries to Google Search, powered by the latest LLMs!

Greasemonkey / Readme / Discuss

Use ChatGPT in Thunderbird to enhance you emails, even with a free account!
Install / Readme / Support


🧠 Contributors



All contributions are very welcome!


🏛️ License

MIT License

Copyright © 2023–2026 KudoAI & contributors.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.