Chatgpt.js
🤖 A powerful, open source client-side JavaScript library for ChatGPT
Install / Use
/learn @KudoAI/Chatgpt.jsREADME
<a id="top"></a>
<div align="center"> <h6> <a href="https://github.com/KudoAI/chatgpt.js/tree/main/docs"> <picture> <source type="image/svg+xml" media="(prefers-color-scheme: dark)" srcset="https://assets.chatgptjs.org/images/icons/earth/white/icon32.svg?v=e638eac"> <img height=14 src="https://assets.chatgptjs.org/images/icons/earth/black/icon32.svg?v=e638eac"> </picture> </a> English | <a href="https://github.com/KudoAI/chatgpt.js/tree/main/docs/zh-cn#readme">简体中文</a> | <a href="https://github.com/KudoAI/chatgpt.js/tree/main/docs/zh-tw#readme">繁體中文</a> | <a href="https://github.com/KudoAI/chatgpt.js/tree/main/docs/ja#readme">日本</a> | <a href="https://github.com/KudoAI/chatgpt.js/tree/main/docs/ko#readme">한국인</a> | <a href="https://github.com/KudoAI/chatgpt.js/tree/main/docs/hi#readme">हिंदी</a> | <a href="https://github.com/KudoAI/chatgpt.js/tree/main/docs/ne#readme">नेपाली</a> | <a href="https://github.com/KudoAI/chatgpt.js/tree/main/docs/de#readme">Deutsch</a> | <a href="https://github.com/KudoAI/chatgpt.js/tree/main/docs/es#readme">Español</a> | <a href="https://github.com/KudoAI/chatgpt.js/tree/main/docs/fr#readme">Français</a> | <a href="https://github.com/KudoAI/chatgpt.js/tree/main/docs/it#readme">Italiano</a> | <a href="https://github.com/KudoAI/chatgpt.js/tree/main/docs/nl#readme">Nederlands</a> | <a href="https://github.com/KudoAI/chatgpt.js/tree/main/docs/pt#readme">Português</a> | <a href="https://github.com/KudoAI/chatgpt.js/tree/main/docs/ru#readme">Английский</a> | <a href="https://github.com/KudoAI/chatgpt.js/tree/main/docs/vi#readme">Việt</a> </h6> </div> <br> <a href="https://chatgpt.js.org/?utm_source=chatgpt.js-github&utm_medium=referral&utm_content=cover-logo"> <picture> <source type="image/png" media="(prefers-color-scheme: dark)" srcset="https://assets.chatgptjs.org/images/logos/chatgpt.js/with-reflection/darkmode/logo-6014x1334.png?v=8169c77"> <img width=800 src="https://assets.chatgptjs.org/images/logos/chatgpt.js/with-reflection/lightmode/logo-6014x1334.png?v=8169c77"> </picture> </a>🤖 A powerful client-side JavaScript library for ChatGPT
</div> <br> <div id="shields" align="center"> <a href="https://github.com/KudoAI/chatgpt.js/blob/main/LICENSE.md" target="_blank" rel="noopener"> <img src="https://img.shields.io/badge/License-MIT-orange.svg?logo=internetarchive&logoColor=white&labelColor=464646&style=for-the-badge"></a> <a href="https://www.npmjs.com/package/@kudoai/chatgpt.js/v/latest" target="_blank" rel="noopener"> <img src="https://img.shields.io/npm/v/%40kudoai%2Fchatgpt.js?logo=npm&logoColor=white&labelColor=464646&color=blue&style=for-the-badge&label=Latest+Release"></a> <a href="https://github.com/KudoAI/chatgpt.js/tree/v3.9.0/dist/chatgpt.min.js" target="_blank" rel="noopener"> <img src="https://img.shields.io/github/size/KudoAI/chatgpt.js/dist/chatgpt.min.js?branch=v3.9.0&label=Minified%20Size&logo=databricks&logoColor=white&labelColor=464646&color=ff69b4&style=for-the-badge"></a> <a href="https://www.codefactor.io/repository/github/kudoai/chatgpt.js" target="_blank" rel="noopener"> <img src="https://img.shields.io/codefactor/grade/github/kudoai/chatgpt.js?label=Code+Quality&logo=codefactor&logoColor=white&labelColor=464646&color=1acc6c&style=for-the-badge"></a> <a href="https://sonarcloud.io/component_measures?metric=vulnerabilities&id=kudoai_chatgpt.js" target="_blank" rel="noopener"> <img src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fsonarcloud.io%2Fapi%2Fmeasures%2Fcomponent%3Fcomponent%3Dkudoai_chatgpt.js%26metricKeys%3Dvulnerabilities&query=%24.component.measures.0.value&style=for-the-badge&logo=sonar&logoColor=white&labelColor=464646&label=Vulnerabilities&color=gold"></a> <a href="https://github.com/sindresorhus/awesome-chatgpt#javascript" target="_blank" rel="noopener"> <img src="https://img.shields.io/badge/Mentioned_in-Awesome-af68ff?logo=awesomelists&logoColor=white&labelColor=464646&style=for-the-badge"></a> <a href="#"> <img src="https://img.shields.io/badge/jsDelivr_Requests-2,000,000+-2bbbd8.svg?logo=jsdelivr&logoColor=white&labelColor=464646&style=for-the-badge"></a> </div><br><br>
<img height=8px width="100%" src="https://assets.chatgptjs.org/images/separators/gradient-aqua.png?v=e638eac"> <div id="intro">💡 About
</div><span style="color: white"><b>chatgpt.js</b></span> is a <span style="color: white">powerful</span> JavaScript library that allows for <span style="color: white">super easy</span> interaction w/ the ChatGPT DOM.
- Feature-rich
- Object-oriented
- Easy-to-use
- Lightweight (yet optimally performant)
⚡ Importing the library
</div>[!NOTE] To always import the latest version (not recommended in production!) replace the versioned jsDelivr URL with:
https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js/chatgpt.min.js
ES11 (2020):
(async () => {
await import('https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.9.0/dist/chatgpt.min.js');
// Your code here...
})();
ES5 (2009):
var xhr = new XMLHttpRequest();
xhr.open('GET', 'https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.9.0/dist/chatgpt.min.js');
xhr.onload = function () {
if (xhr.status === 200) {
var chatgptJS = document.createElement('script');
chatgptJS.textContent = xhr.responseText;
document.head.append(chatgptJS);
yourCode(); // runs your code
}
};
xhr.send();
function yourCode() {
// Your code here...
}
<img style="margin: 0 2px -0.065rem 0" height=17 src="https://assets.chatgptjs.org/images/icons/platforms/tampermonkey/icon28.png?v=e638eac"><img style="margin: 0 2px -0.035rem 1px" height=17.5 src="https://assets.chatgptjs.org/images/icons/platforms/violentmonkey/icon25.png?v=e638eac"> Greasemonkey:
[!NOTE] To use a starter template: kudoai/chatgpt.js-greasemonkey-starter
...
// @require https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.9.0/dist/chatgpt.min.js
// ==/UserScript==
// Your code here...
<img style="margin: 0 2px -1px 0" height=16 src="https://assets.chatgptjs.org/images/icons/platforms/chrome/icon16.png?v=e638eac"> Chrome:
[!NOTE] To use a starter template: kudoai/chatgpt.js-chrome-starter
Since Google does not allow remote code, importing chatgpt.js locally is required:
-
Save https://raw.githubusercontent.com/KudoAI/chatgpt.js/main/chatgpt.js to a subdirectory (
libin this example) -
In project's (V3)
manifest.json, addlib/chatgpt.jsas a web accessible resource
"web_accessible_resources": [{
"matches": ["<all_urls>"],
"resources": ["lib/chatgpt.js"]
}],
- In scripts that need
chatgpt.js(foreground/background alike), import it like so:
(async () => {
await import(chrome.runtime.getURL('lib/chatgpt.js'));
// Your code here...
})();
<img height=8px width="100%" src="https://assets.chatgptjs.org/images/separators/gradient-aqua.png?v=e638eac">
<div id="npm">
💾 Downloading via npm:
</div>To download chatgpt.js for local customization, run the following command in your project's root:
npm install @kudoai/chatgpt.js
After installation, navigate to node_modules/@kudoai/chatgpt.js to find the library source.
💻 Usage
</div>chatgpt.js was written w/ ultra flexibility in mind.
For example:
chatgpt.getLastResponse();
chatgpt.getLastReply();
chatgpt.response.getLast();
chatgpt.get('reply', 'last');
Each call equally fetches the last response. If you think it works, it probably will... so just type it!
If it didn't, check out the extended userguide, or simply submit an issue or PR and it will be integrated, ezpz!
<img height=8px width="100%" src="https://assets.chatgptjs.org/images/separators/gradient-aqua.png?v=e638eac"> <div id="showcase">🤖 Made with chatgpt.js
</div>https://github.com/KudoAI/chatgpt.js/assets/10906554/f53c740f-d5e0-49b6-ae02-3b3140b0f8a4
<picture><source type="image/png" media="(prefers-color-scheme: dark)" srcset="https://amazongpt.kudoai.com/assets/images/icons/app/white/icon48.png"><img width=20 src="https://amazongpt.kudoai.com/assets/images/icons/app/black-gold-teal/icon48.png"></picture> AmazonGPT <a href="https://amazongpt.kudoai.com/assets/wolfram-award/letter.pdf
Related Skills
openhue
348.2kControl Philips Hue lights and scenes via the OpenHue CLI.
sag
348.2kElevenLabs text-to-speech with mac-style say UX.
weather
348.2kGet current weather and forecasts via wttr.in or Open-Meteo
tweakcc
1.6kCustomize Claude Code's system prompts, create custom toolsets, input pattern highlighters, themes/thinking verbs/spinners, customize input box & user message styling, support AGENTS.md, unlock private/unreleased features, and much more. Supports both native/npm installs on all platforms.
