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
Prefix address for # API calls API_PREFIX = '/' API Key that # uses as authentication for API calls API_KEY = 'dummy_key' # Number of retries for failed requests to the DDG MAX_RETRY_COUNT = 3 # retry delay for failed requests to the DDG in 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": "Hello!"
}
],
"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 # Define the process name and startup command PROCESS_NAME="ddgchatgo" START_COMMAND="PORT=5005 /home/yourServ00username/domains/example.com/public_html/ddgchatgo-freebsd-amd64 > /home/yourServ00user/domains/example .com/public_html/ddgchatgo.log 2>&1 &" # Check if the process is running if ! pgrep -f "$PROCESS_NAME" > /dev/null then echo "Process $PROCESS_NAME is not running, starting..." # Starting process eval "$START_COMMAND" if [ $? -eq 0 ]; then echo "Process $PROCESS_NAME started successfully." then echo "Process $PROCESS_NAME started successfully." else echo "Process $PROCESS_NAME failed." else echo "Process $PROCESS_NAME failed to start. echo "Process $PROCESS_NAME failed to start." fi echo "Process $PROCESS_NAME is already running." fi
- Granting script execution privileges
chmod +x start_api.sh
- The first time you run cron, just run the following command
nohup /home/your Serv00 username/domains/example.com/public_html/start_ddgchatgo.sh > /home/your Serv00 username/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: Enter the working directory
cd ~/domains/example.com/public_html/
# Step 2: Download the executable program
wget https://github.com/Shadownc/DDG-Chat-go/releases/download/v0.0.2/ddgchatgo-freebsd-amd64
# Step 3: Give executable permission to the extracted freechatgpt file
chmod +x ddgchatgo-freebsd-amd64
# Step 4: Create the start_ddgchatgo.sh script
cat < start_ddgchatgo.sh
#!/bin/bash
# Define the process name and start command
PROCESS_NAME="ddgchatgo"
START_COMMAND="PORT=5005 /home/your Serv00 username/domains/example.com/public_html/ddgchatgo-freebsd-amd64 > /home/your Serv00 username/domains/ example.com/public_html/ ddgchatgo-freebsd-amd64 > /home/your Serv00 username/domains/ example.com/public_html/ddgchatgo-freebsd-amd64 example.com/public_html/ddgchatgo.log 2>&1 &"
# Check if the process is running
if ! pgrep -f "$PROCESS_NAME" > /dev/null
then
echo "Process $PROCESS_NAME is not running, starting..."
# Starting process
eval "$START_COMMAND"
if [ $? -eq 0 ]; then
echo "Process $PROCESS_NAME started successfully."
then echo "Process $PROCESS_NAME started successfully." else
echo "Process $PROCESS_NAME failed to start."
echo "Process $PROCESS_NAME failed to start.
echo "Process $PROCESS_NAME failed to start." else
echo "Process $PROCESS_NAME is already running."
fi
EOL
# Step 5: Give start_ddgchatgo.sh executable privilege
chmod +x start_ddgchatgo.sh
# Step 6: Run start_ddgchatgo.sh script and output logs to start_ddgchatgo.log
nohup /home/your Serv00 username/domains/example.com/public_html/start_ddgchatgo.sh > /home/your Serv00 username/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