Home
Softono
chatgpt.js

chatgpt.js

Open source JavaScript
2K
Stars
171
Forks
36
Issues
14
Watchers
1 week
Last Commit

About chatgpt.js

🤖 A powerful, open source JavaScript library + interactive CLI for ChatGPT

Platforms

Web Self-hosted

Languages

JavaScript

Links




⚡ 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:

After setting an API key, control from your terminal:

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

chatgpt --ascii-art "cat"  # or cjs -a cat
# e.g. =>
#
#       |\      _,,,---,,_
# ZZZzz /,`.-'`'    -.  ;-;;,_
#      |,4-  ) )-,_. ,\ (  `'-'
#     '---''(_/--'  `-'\_)

chatgpt --commit-msg  # or cjs -g (in a git repo)
# e.g. => feat: add `--ascii-art` cli cmd

Create local config file (customize provider, etc.):

chatgpt init

View all CLI options:

chatgpt --help

For more options & examples, see the extended user guide:

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



🚀 Made with chatgpt.js

AmazonGPT  

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

Greasemonkey / README / Discuss

Autoclear ChatGPT History  

Auto-clear your ChatGPT query history for maximum privacy.

Greasemonkey / README / Discuss

BraveGPT  

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

Greasemonkey / README / Discuss

ChatGPT Auto-Continue  

Automatically continue generating answers when ChatGPT responses get cut off.

Chrome / Firefox / Edge / README / Discuss


Have a library idea or request?

Create a new Issue: https://github.com/KudoAI/chatgpt.js/issues/new


ChatGPT Auto Refresh ↻  

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

Greasemonkey / README / Discuss

ChatGPT Auto-Talk 📣  

Auto-play ChatGPT responses.

Greasemonkey / README / Discuss

ChatGPT Infinity  

Generate endless answers powered by ChatGPT (on any topic!)

Chrome / Firefox / Edge / Greasemonkey / README / Discuss

ChatGPT Widescreen  

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

Chrome / Firefox / Edge / Greasemonkey / README / Discuss

DuckDuckGPT  

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

Greasemonkey / README / Discuss

GoogleGPT  

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

Greasemonkey / README / Discuss

ThunderAI  [Rated 5-stars]

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


🧠 Contributors



All contributions are 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.

**[Latest releases](https://github.com/KudoAI/chatgpt.js/releases)** / [Userguide](https://github.com/KudoAI/chatgpt.js/blob/v4.13.0/docs/USERGUIDE.md) / [Get support](https://github.com/KudoAI/chatgpt.js/issues) / [Discuss](https://github.com/KudoAI/chatgpt.js/discussions) / [Back to top ↑](#top)