Artificial Intelligence 13 min read

Step-by-Step Guide to Integrate DeepSeek AI with a WeChat Public Account Using a Cloud Server

This tutorial walks beginners through obtaining a DeepSeek API key, setting up an Alibaba Cloud ECS instance, configuring the WeChat public‑account interface, cloning and configuring the open‑source COW project, and finally deploying a Python service that connects the WeChat bot to the DeepSeek large‑language model.

Java Architect Essentials
Java Architect Essentials
Java Architect Essentials
Step-by-Step Guide to Integrate DeepSeek AI with a WeChat Public Account Using a Cloud Server

Recently DeepSeek released a low‑cost API that is almost fully compatible with the OpenAI SDK, simplifying deployment. This tutorial explains, in plain language, how a complete beginner can integrate DeepSeek into a personal WeChat public account.

1. Basic Principles, Potential Risks, and Process Overview

The tutorial uses a GitHub open‑source project (COW) to bridge the DeepSeek API and the WeChat public‑account API. A server receives messages from the public account, forwards them to the AI model, and returns the response. Risks include accidental misuse of the WeChat admin interface, possible cloud‑server charges after free quotas expire, and API‑call fees after the DeepSeek free quota is exhausted.

2. Obtaining a DeepSeek API Key

Log in to the DeepSeek developer platform ( https://platform.deepseek.com/ ), navigate to API keys → Create API key , copy the key and keep it safe for later configuration.

3. Collecting WeChat Public‑Account Information

Log in to the WeChat public‑account platform, become a developer, and copy the AppID , AppSecret , and generate a 43‑character AESKey . Record these values carefully.

4. Creating a Cloud Server

Register on Alibaba Cloud, apply for the free ECS trial (choose Hong Kong region, 2 CPU + 2 GiB, Ubuntu 22.04 64‑bit, no pre‑installed packages). After the instance is created, open port 80 in the security‑group rules to allow HTTP access.

5. Project Code Configuration

5.1 Clone the Project

git clone https://github.com/zhayujie/chatgpt-on-wechat.git

5.2 Install Dependencies

pip3 install -r ./chatgpt-on-wechat/requirements.txt
pip3 install -r ./chatgpt-on-wechat/requirements-optional.txt

5.3 Edit Configuration File

Create a config.json file (using vi config.json ) and paste the following JSON, replacing placeholder values with the keys obtained earlier:

{
  "channel_type": "wechatmp",
  "model": "deepseek-chat",
  "open_ai_api_key": "YOUR_DEEPSEEK_API_KEY",
  "open_ai_api_base": "https://api.deepseek.com/v1",
  "single_chat_prefix": [""],
  "single_chat_reply_prefix": "",
  "wechatmp_app_id": "YOUR_APPID",
  "wechatmp_app_secret": "YOUR_APPSECRET",
  "wechatmp_aes_key": "YOUR_AESKEY",
  "wechatmp_token": "YOUR_TOKEN",
  "wechatmp_port": 80,
  "conversation_max_tokens": 3000,
  "expires_in_seconds": 3600,
  "character_desc": "You are an AI assistant based on a large language model, capable of answering any question in multiple languages.",
  "temperature": 0.8,
  "subscribe_msg": "Thank you for following! The public account is now connected to DeepSeek‑V3. Longer replies will first send a "正在思考中" message; reply any text to receive the full output.",
  "use_linkai": false
}

5.4 Verify Configuration

Run cat config.json to ensure the file contains the correct JSON.

5.5 Run the Service

sudo python3 app.py

If the terminal shows no errors, the service is running and ready to receive WeChat messages.

6. WeChat Public‑Account Server Configuration

In the WeChat admin console, go to Settings → Development → Interface Management → Modify Server Configuration and fill in:

URL: http://YOUR_SERVER_PUBLIC_IP/wx

Token: same as wechatmp_token in config.json

AESKey: same as wechatmp_aes_key in config.json

Encryption Mode: Compatibility Mode

Submit and enable the configuration; a “submission successful” message indicates the integration is complete.

7. Post‑Deployment Tips

For long‑running operation, use a nohup command to keep the service alive after the terminal closes:

(cd chatgpt-on-wechat && nohup python3 app.py &) ; tail -f ./chatgpt-on-wechat/nohup.out

Periodically restart the ECS instance and re‑run the command. You can also customize the configuration (model version, trigger format, reply style) once you understand each field.

Monitor Alibaba Cloud trial quota (≈300 CNY) and DeepSeek API free credit (≈10 CNY) to avoid unexpected charges.

DeepSeeklarge language modelWeChatCloud serverPython tutorial
Java Architect Essentials
Written by

Java Architect Essentials

Committed to sharing quality articles and tutorials to help Java programmers progress from junior to mid-level to senior architect. We curate high-quality learning resources, interview questions, videos, and projects from across the internet to help you systematically improve your Java architecture skills. Follow and reply '1024' to get Java programming resources. Learn together, grow together.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.