TypeScript icon, indicating that this package has built-in type declarations

0.0.28 • Public • Published

Gradio Chatbot

A tool that can automatically convert Huggingface Spaces, Modelscope Studios and Gradio ChatBot into free APIs. It basically supports any space with a chatbot, and currently perfectly supports many model spaces such as GPT4Free, ChatGPT, Llama 2, Vicuna, MPT-30B, Falcon, ChatGLM, Qwen and so on.

English | 中文

NPM Apache 2.0 License

Online Demo:

Due to the current high demand on the ChatGPT space on Huggingface, there is a noticeable delay in response time. If you have your own ChatGPT account, it is recommended to use gpt-web.

Quick Start


  • Experience a free ChatGPT.
npx gradio-chatbot
# or
npm install -g gradio-chatbot
# call the default model
  • Experience Llama2.
chatbot 2
# or

More usage just type chatbot help


docker build . -t gradio-server
docker run --rm -it -p 8000:8000 gradio-server



You can use npm or yarn to install gradio-chatbot. Node version 18 or higher is required.

npm install gradio-chatbot
# or
yarn add gradio-chatbot


Currently supports three modes.

CLI mode

Refer to Quickstart.

API Service

To make it easy to use, two forms of interfaces are provided.

Streaming output, simply visit http://localhost:8000/api/conversation?model=0&text=hello. Non-streaming output, the calling method is the same as ChatGPT API. The following is an example of a call.

API Function

import { GradioChatBot } from 'gradio-chatbot'

const bot = new GradioChatBot();

async function start() {
  const message = await'hello', {
    onMessage(partialMsg) {
      console.log('stream output:', partialMsg);
  console.log('message', message);


You can also input the spatial address you want to convert, such as

import { GradioChatBot } from 'gradio-chatbot'

const bot = new GradioChatBot({
  url: '',
  fnIndex: 35,
}); // 调用自定义 ChatBot 模型

async function start() {

In addition, the NPM package has built-in support for 10 popular spaces from Hugging Face Spaces and Modelscope Studios. You can directly use the model index to access them. Please refer to the Model List for more details.

import { GradioChatBot } from 'gradio-chatbot';

const bot = new GradioChatBot('1');
async function start() {
  console.log(await'Tell me about ravens.'));


For more examples, please visit the directory: Examples .

Note: Some models on Hugging Face may collect the information you input. If you have data security concerns, it is recommended not to use them, and using self-hosted models is a better choice.

Using OpenAI


import openai
openai.api_key = "dummy"
openai.api_base = ""

# create a chat completion
chat_completion = openai.ChatCompletion.create(model="10", messages=[{"role": "user", "content": "Hello"}])

# print the completion

For more usage instructions, please refer to


import OpenAI from 'openai';

const openai = new OpenAI({
  baseURL: ''

async function main() {
  const stream = await{
    model: '10',
    messages: [{ role: 'user', content: 'Hello' }],
    stream: true,
  for await (const part of stream) {
    process.stdout.write(part.choices[0]?.delta?.content || '');


For more usage instructions, please refer to

API Document

See API Document

Model List

Index Type Description Model
0 Huggingface Spaces ChatGPT
1 Huggingface Spaces GPT Free
2 Huggingface Spaces Llama2 Spaces
3 Huggingface Spaces MosaicML MPT-30B-Chat
4 Huggingface Spaces Falcon Chat
5 Huggingface Spaces Star Chat
6 Huggingface Spaces ChatGLM2
7 Huggingface Spaces ChatGLM
8 Huggingface Spaces Vicuna
9 Huggingface Spaces Qwen 7B Chat
10 ModelScope Qwen 7B Chat
11 ModelScope ChatGLM2
12 ModelScope Jiang Ziya V1.1
13 ModelScope Character Dialogue Chatbot developed by Alibaba DAMO Academy

More useful models are welcome to contribute in the issue section.

Change Log



  • This package supports node >= 18.



Apache 2.0 © LICENSE.

Package Sidebar


npm i gradio-chatbot

Weekly Downloads






Unpacked Size

605 kB

Total Files


Last publish


  • lwdgit