Backend Development 13 min read

Step-by-Step Guide: Integrating DeepSeek API with a WeChat Public Account on a Cloud Server

This tutorial walks beginners through obtaining a DeepSeek API key, configuring a WeChat public account, setting up an Alibaba Cloud ECS instance, installing required dependencies, editing configuration files, and running the chatgpt‑on‑wechat project to enable AI‑powered replies via the WeChat platform.

Top Architecture Tech Stack
Top Architecture Tech Stack
Top Architecture Tech Stack
Step-by-Step Guide: Integrating DeepSeek API with a WeChat Public Account on a Cloud Server

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

Disclaimer: the tutorial is for learning purposes only; the author is not responsible for any loss and recommends testing with an unimportant public account first.

1. Basic Principles & Potential Risks

The tutorial uses a GitHub open‑source project to combine the DeepSeek API and the WeChat public platform API. A server receives messages from the public account, forwards them to the DeepSeek model, and returns the response to the user.

Risks include possible misconfiguration of the WeChat public account (admin risk), potential cloud server fees after the free tier expires, and possible DeepSeek API usage fees after the free quota is exhausted.

2. Obtaining a DeepSeek API Key

Log in to the DeepSeek developer platform (https://platform.deepseek.com/), create an API key on the "API keys" page, and save the key for later use.

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

3. Getting WeChat Public Platform Information

Log in to the WeChat public platform, enable developer mode, and copy the AppID, AppSecret, and generate a random AESKey. Save all values.

4. Creating a Cloud Server

Register on Alibaba Cloud (https://www.aliyun.com/), apply for the free ECS trial, select Hong Kong region, a 2‑core 2 GiB Ubuntu 22.04 instance, and no pre‑installed applications. Open port 80 in the security group.

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 config.json with the collected values (channel_type, model, open_ai_api_key, open_ai_api_base, wechatmp_app_id, wechatmp_app_secret, wechatmp_aes_key, wechatmp_token, wechatmp_port, etc.). Use vi config.json , press I to edit, paste the JSON, then Esc :wq to save.

{
  "channel_type": "wechatmp",
  "model": "deepseek-chat",
  "open_ai_api_key": "YOUR_DEEPSEEK_API_KEY",
  "open_ai_api_base": "https://api.deepseek.com/v1",
  "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.",
  "temperature": 0.8,
  "subscribe_msg": "Thank you for following! The public account is now connected to DeepSeek‑V3.",
  "use_linkai": false
}

5.4 Run the Project

sudo python3 app.py

For unattended operation, use:

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

6. Configuring the WeChat Public Platform

In the WeChat console, go to Settings & Development → Interface Configuration and set:

URL: http://YOUR_SERVER_IP/wx

Token: same as wechatmp_token in config.json

AESKey: same as wechatmp_aes_key

Encryption Mode: Compatibility

Submit and enable the configuration; the public account should now be linked to DeepSeek.

7. Post‑Setup and Maintenance

To keep the service running after closing the terminal, restart the server and execute the unattended command above. Periodically restart the ECS instance and re‑run the command. You can customize the configuration (model, prompts, etc.) as needed. Monitor Alibaba Cloud trial usage and DeepSeek API quota to avoid unexpected charges.

BackendPythonDeepSeekTutorialWeChatCloud serverAPI Integration
Top Architecture Tech Stack
Written by

Top Architecture Tech Stack

Sharing Java and Python tech insights, with occasional practical development tool tips.

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.