chatgpt.js
chatgpt.js is an open source JavaScript library and CLI for sending prompts to large language models from Node.js, the browser, Greasemonkey scripts, and Chrome extensions used in design and UI tooling. Install it with npm as @kudoai/chatgpt.js or load it from jsDelivr, then call chatgpt.send() to get a response. The project lives on GitHub under KudoAI with more than 2,000 stars.
Where most ChatGPT wrappers target only the official API, chatgpt.js also ships a terminal CLI with commands for quick queries, ASCII art generation, and git commit messages. It supports OpenRouter (300+ models) and Google AI (Gemini and Gemma) through environment variables, so you are not locked to one provider. Starter templates exist for Greasemonkey and Chrome Manifest V3 extensions.
Developers building browser userscripts, Node automations, or terminal workflows use it to add LLM calls without writing HTTP boilerplate. The MIT license lets you bundle it in commercial projects, and the ecosystem page lists extensions like BraveGPT, DuckDuckGPT, and ChatGPT Widescreen built on top of it.
npm package @kudoai/chatgpt.js installs for Node.js and global CLI use
jsDelivr CDN script tag loads version 4 for browser and Greasemonkey projects
CLI supports --query, --ascii-art, and --commit-msg commands from any git repo
OpenRouter and Google AI API keys configurable via environment variables
MIT licensed with 2,000+ GitHub stars and starter templates for Chrome extensions
Works in ESM, CommonJS, terminal, Greasemonkey, and Chrome Manifest V3
MIT license with no usage restrictions on commercial projects
Single library runs in Node.js, browser, CLI, and extension contexts
OpenRouter support gives access to 300+ models through one API key
Active ecosystem of browser extensions built on the library
Lightweight CDN build loads without a bundler step
Requires your own API key and provider billing for actual LLM calls
chatgpt.js.org redirects to GitHub rather than hosting its own docs site
No built-in UI components; you wire responses into your own interface
Provider setup and environment variables needed before first query works
Is chatgpt.js free?
Yes. chatgpt.js is open source under the MIT license and free to use in personal and commercial projects. You bring your own API key from OpenRouter or Google AI; the library itself has no subscription fee.
How do you install chatgpt.js?
For Node.js, run npm install @kudoai/chatgpt.js in your project root. For browsers, add the jsDelivr script tag pointing at @kudoai/chatgpt.js@4/dist/chatgpt.min.js. For a global CLI, run npm install -g @kudoai/chatgpt.js.
Which API providers does chatgpt.js support?
chatgpt.js supports OpenRouter, which offers 300+ models including free tiers, and Google AI for Gemini and Gemma models. Set OPENROUTER_API_KEY or GOOGLE_API_KEY in your environment before running queries.
Can chatgpt.js run in browser extensions?
Yes. chatgpt.js includes a Chrome extension starter template and documents how to add chatgpt.min.js as a web accessible resource in a Manifest V3 project. Greasemonkey userscripts can load the same CDN build with an @require directive.
What CLI commands does chatgpt.js include?
The chatgpt.js CLI accepts --query for quick prompts, --ascii-art for text art generation, and --commit-msg to draft git commit messages from staged changes. Run chatgpt --help for the full option list or chatgpt init to create a config file.
Where is the chatgpt.js source code?
The source code is hosted at github.com/KudoAI/chatgpt.js. Issues, discussions, and releases are managed there. The chatgpt.js.org domain redirects to the GitHub repository.

