Docker Website (18) ChatGPT-Web: Your Own OpenAI Mirror Website

0, Preface

ChatGPT has been released for several months, and the popularity is still unabated. However, due to network reasons, I did not find a suitable server to access at the beginning, and later I got stuck on the SMS verification code. SMS Activate provides mobile phones in India, Malaysia, Indonesia, etc. I couldn't get the code at all, so I had to ask the almighty group of friends to play with the mirror station they built.

Later, because their quota was exhausted, the mirror sites were closed or not open to the public. At this time @IURT told me that he wanted to set up a server dedicated to GPT, which happened to be me, so we hit it off and set up two mirror sites ChatGPT-Web and ChatGPT-Next-Web Used to access GPT.

1 Introduction

There are two most popular Docker images: ChatGPT-Web and ChatGPT-Next-Web.

You can go to GitHub to see the introduction.

2. Installation

By default, the API Key is used to call, if you need to use the Access Token, turn to the 3.2 configuration section of this article.

2.1、Web

implement:

Bash
1
2
3
4
5
6
7
docker run -d \
     --name chatgpt-web \
     -p 3002:3002 \
     --env OPENAI_API_KEY=sk-xxxxxx\
     --env OPENAI_API_BASE_URL=https://api.openai.com \
     --env AUTH_SECRET_KEY=ChatGPTWebPassword\
chenzhaoyu94/chatgpt-web

OPENAI_API_KEY: Mandatory, replace it with your own key, GPT 3.5 calls are charged but have a $5 limit.
OPENAI_API_BASE_URL: Optional, replace it with a self-built or community anti-generation official API interface, suitable for servers that cannot access the official API.
AUTH_SECRET_KEY: Optional, if you don’t want your mirror site to be discovered and abused, you’d better set it up and change it to the password you want, you can have more than one: password 1, password 2, password 3.

Reverse proxy 127.0.0.1:3002 after startup.

2.2, NextWeb

implement:

Bash
1
2
3
4
5
6
docker run -d \
     --name chatgpt-next-web\
     -p 3000:3000 \
     -e OPENAI_API_KEY="sk-xxxxxx" \
     -e CODE="ChatGPTWebPassword" \
yidadaa/chatgpt-next-web

Replace OPENAI_API_KEY with your own key, and CODE with the password you want to set.

Reverse proxy 127.0.0.1:3000 after startup.

3. Configuration

3.1, shield crawlers

It stands to reason that you can Enjoy it! , but in order to prevent being discovered and then brush the volume, let’s configure the rules.

Add to the Nginx configuration file:

Comment first then view it after your comment is approved. Join QQ Group to display all hidden texts.

If you use a domain name to access, and use DNSPod, etc. to support regional resolution, you can add the default host as 0.0.0.0, and the domestic host as the actual IP, directly preventing overseas access.

Using the pagoda firewall, etc. can be set to prohibit foreign countries, prohibit crawlers, etc.

3.2, using unofficial API

ChatGPT-Web supports unofficial anti-generation API + Access Token access, which will be smarter than the official API, theoretically no different from logging in to chat directly with a browser.

Compared:

Compare ItemsOfficial APIAccess Token (not Plus)
Basic RequirementsOpenAI account
bind with foreign virtual credit card
Only OpenAI account
ChargesUsage chargesFree
Basic PromptSupportedNot Supported
Hyperparameter supportTemprature
Top_p
Not supported
Number of requests per unit timeHigher, suitable for multiple peopleLower, suitable for personal use
ResponsivenessFaster (gpt-3.5-turbo)Slower (gpt-3.5)
Token lengthlongershorter
Bypassing Cloudflare's Reverse ProxyNot requiredRequired
StabilityHighLow (community proxy)
High (self-built proxy)

3.2.1, using community proxy

Bash
1
2
3
4
5
6
7
docker run -d \
     --name chatgpt-web \
     -p 3002:3002 \
     --env OPENAI_ACCESS_TOKEN=eyJxxxx \
     --env API_REVERSE_PROXY=https://ai.fakeopen.com/api/conversation \
     --env AUTH_SECRET_KEY=ChatGPTWebPassword \
chenzhaoyu94/chatgpt-web

OPENAI_ACCESS_TOKEN: Mandatory, the browser logs in to chat.openai.com to access

https://chat.openai.com/api/auth/session

You can get it, but it will expire after a while. It is recommended to use it with this project:

https://github.com/acheong08/OpenAIAuth

API_REVERSE_PROXY: optional, if you don’t know it, you can delete it or keep it as default.

3.2.2, using self-built proxy

First use the server to execute

Bash
1
curl -v https://chat.openai.com

Check to see if it is blocked. If it is blocked, you can use the following method to connect to Warp+ to unlock.

If the access is normal, create a new docker-compose.yml:

Comment first then view it after your comment is approved. Join QQ Group to display all hidden texts.

If it is blocked, change to the following configuration file:
Comment first then view it after your comment is approved. Join QQ Group to display all hidden texts.

network_mode: host: If this parameter is enabled, you can use 127.0.0.1:8080 when setting the reverse generation address of ChatGPT-Web later, otherwise you should use Docker network host IP: mapped port, for example, by default is 172.17.0.1:8080. But the port used after enabling is 8080 and cannot be customized.

After filling in the configuration file, execute in this directory:

Bash
1
docker-compose up -d

The container can be started.

After that, start ChatGPT-Web:

Bash
1
2
3
4
5
6
7
8
docker run -d \
     --name chatgpt-web \
     -p 3002:3002 \
     --env OPENAI_ACCESS_TOKEN=eyJxxxx \
     --env API_REVERSE_PROXY=http://127.0.0.1:8080/api/conversation \
     --env AUTH_SECRET_KEY=ChatGPTWebPassword\
     #--network=host \
chenzhaoyu94/chatgpt-web

network=host: If network_mode: host is not enabled in the configuration file of the anti-generation API, using network=host here can also set the anti-generation address to 127.0.0.1, otherwise it is the Docker host host IP. But the port mapped out in this way is 3002 and cannot be customized, pay attention to changing the Nginx reverse proxy configuration file.

At this point, the construction and connection of the self-built API has been completed.

Docker Website (18) ChatGPT-Web: Your Own OpenAI Mirror Website

https://blog.tsinbei.com/en/archives/742/

Author
Hsukqi Lee
Posted on

2023-06-22

Edited on

2023-06-22

Licensed under

CC BY-NC-ND 4.0

Comments

Name
Mail
Site
None yet