General Introduction
DDG-Chat is an open source project that aims to provide a one-click deployment to multiple platforms of the ChatGPT API backend. The project supports multiple models, including GPT-4o mini, Claude 3 Haiku, Llama 3.1 70B, and Mixtral 8x7B, all anonymously provided by DuckDuckGo. All models are provided anonymously by DuckDuckGo. Users can easily deploy and use the API backend through Vercel, Cloudflare Workers, Docker and other platforms.
Since the DDG API limits the number of concurrency to a single IP, it is recommended that you use Vercel for deployment, or if you use a local deployment such as Docker, make sure the project is running in a proxy pool.
Function List
- Supports multiple ChatGPT models
- One-click deployment to Vercel, Cloudflare Workers, Docker, etc.
- Provide API interface for third-party applications
- Supports multiple deployment methods, including cloud and local deployment
- Provide detailed deployment and usage documentation
Using Help
Installation and Deployment
Vercel deployment
- Cloud Fork repository deployment: (Vercel One-Click Deployment)
- Fork this repository to your GitHub account.
- Go to the Vercel New Project page and import the repository you just Forked.
- Click Deploy to complete the deployment.
- Local Clone repository deployment:
- Make sure you have a Node.js environment.
- Execute the following command:
npm i -g vercel vercel login git clone https://github.com/leafmoes/DDG-Chat.git ddg-chat cd ddg-chat npm run publish
Cloudflare Workers Deployment
- Go to the Cloudflare Workers and Pages console and create a worker.
- In the Workers settings, set the runtime to nodejs_compat.
- Paste the code from the repositoryGo to your Workers and click Deploy.
Docker Deployment
- Command line build:
docker run -it -d --name ddg-chat -p 8787:8787 ghcr.io/leafmoes/ddg-chat:latest
- Build using the docker-compose.yml file:
- Download and save the docker-compose.yml file.
- Start the service by running the following command in the directory where the file is located:
docker-compose up -d
environment variable
# API 调用的前缀地址 API_PREFIX = '/' # 作为调用 API 验证的 API Key API_KEY = 'dummy_key' # 向 DDG 发送请求失败的重试次数 MAX_RETRY_COUNT = 3 # 向 DDG 发送请求失败的重试延迟,单位 ms RETRY_DELAY = 5000
Using the API
invoke an interface
Use a third-party ChatGPT application to invoke the interface, such as ChatNextWeb. the following is a sample dialog request:
curl --request POST 'https://你的域名/v1/chat/completions' \
--header 'Content-Type: application/json' \
--data '{
"messages": [
{
"role": "user",
"content": "你好!"
}
],
"model": "gpt-4o-mini",
"stream": true
}'
Model Query
interviews https://你的域名/v1/models
Allows you to view the currently supported models.
common problems
- Vercel deployment limitations: The free version takes 60 seconds for a single API request and 100,000 API calls per month.
- Error 429 ERR_SERVICE_UNAVAILABLE: Non-Vercel are prone to this issue, as the DDG API limits single IP concurrency, it is recommended to reduce concurrency and also use a proxy pool for requests.
Alternative go version deployment: free server serv00 deployment of resident services
- Go to the serv00 panel and click on DNS zones and click on Add new zone to add your own customized domain name.
- Go to cf to add A-record parsing
- Click on Additional services and click on Run your own applications.
Enabled
- Open a port. I'm opening 5005.
- Click WWW Websites Click Add website Domain to fill in your own domain name.
- Click to download file Granting executable permissions to files
chmod +x ddgchatgo-freebsd-amd64
- exist
public_html
Create a startup script understart_ddgchatgo.sh
#!/bin/bash # 定义进程名称和启动命令 PROCESS_NAME="ddgchatgo" START_COMMAND="PORT=5005 /home/你的Serv00用户名/domains/example.com/public_html/ddgchatgo-freebsd-amd64 > /home/你的Serv00用户/domains/example.com/public_html/ddgchatgo.log 2>&1 &" # 检查进程是否在运行 if ! pgrep -f "$PROCESS_NAME" > /dev/null then echo "进程 $PROCESS_NAME 未运行,正在启动..." # 启动进程 eval "$START_COMMAND" if [ $? -eq 0 ]; then echo "进程 $PROCESS_NAME 启动成功。" else echo "进程 $PROCESS_NAME 启动失败。" fi else echo "进程 $PROCESS_NAME 已经在运行。" fi
- Granting script execution privileges
chmod +x start_api.sh
- The first time you run cron, just run the following command
nohup /home/你的Serv00用户名/domains/example.com/public_html/start_ddgchatgo.sh > /home/你的Serv00用户名/domains/example.com/public_html/start_ddgchatgo.log 2>&1 &
Change your Serv00 username to your own.
example.com to your own domain name
PORT If the open port is not 5005, you can change it.
One-Click Installation Scripts
#!/bin/bash
# Step 1: 进入工作目录
cd ~/domains/example.com/public_html/
# Step 2: 下载可执行程序
wget https://github.com/Shadownc/DDG-Chat-go/releases/download/v0.0.2/ddgchatgo-freebsd-amd64
# Step 3: 赋予解压后freechatgpt文件可执行权限
chmod +x ddgchatgo-freebsd-amd64
# Step 4: 创建start_ddgchatgo.sh脚本
cat <<EOL > start_ddgchatgo.sh
#!/bin/bash
# 定义进程名称和启动命令
PROCESS_NAME="ddgchatgo"
START_COMMAND="PORT=5005 /home/你的Serv00用户名/domains/example.com/public_html/ddgchatgo-freebsd-amd64 > /home/你的Serv00用户名/domains/example.com/public_html/ddgchatgo.log 2>&1 &"
# 检查进程是否在运行
if ! pgrep -f "$PROCESS_NAME" > /dev/null
then
echo "进程 $PROCESS_NAME 未运行,正在启动..."
# 启动进程
eval "$START_COMMAND"
if [ $? -eq 0 ]; then
echo "进程 $PROCESS_NAME 启动成功。"
else
echo "进程 $PROCESS_NAME 启动失败。"
fi
else
echo "进程 $PROCESS_NAME 已经在运行。"
fi
EOL
# Step 5: 赋予start_ddgchatgo.sh可执行权限
chmod +x start_ddgchatgo.sh
# Step 6: 运行start_ddgchatgo.sh脚本并将日志输出到start_ddgchatgo.log
nohup /home/你的Serv00用户名/domains/example.com/public_html/start_ddgchatgo.sh > /home/你的Serv00用户名/domains/example.com/public_html/start_ddgchatgo.log 2>&1 &
In one-click scriptshttps://github.com/Shadownc/DDG-Chat-go/releases/download/v0.0.2/ddgchatgo-freebsd-amd64
Replace withhttps://github.com/Shadownc/DDG-Chat-go/releases/download/v0.0.4/ddgchatgo-freebsd-amd64
API KEY can be set.
Change your Serv00 username to your own.
example.com to your own domain name
PORT If the open port is not 5005, you can change it.
After deployment is complete, accessing the domain returns the following to indicate success:
{ "message": "Welcome to the API" }
Access to newapi after building
new api/one api select custom channel
http://chat.xxl.serv00.net/v1/chat/completions