Add Full‑Featured DeepSeek AI to a WeChat Mini‑Program with Just 3 Lines of Code
This guide shows how developers can quickly integrate DeepSeek's powerful language model into WeChat mini‑programs using Tencent Cloud, covering three integration approaches, a three‑step voice‑interaction setup, and a concise list of related cloud products and resources.
Integration methods for DeepSeek in WeChat mini‑programs
Three official ways are provided by Tencent Cloud to embed the full‑capacity DeepSeek large language model (LLM) into a mini‑program.
SDK direct connection – Call the DeepSeek model through the public API. The typical request uses three lines of JavaScript in the mini‑program environment:
import { request } from 'wx-server-sdk';
await request({
url: 'https://api.deepseek.com/v1/chat/completions',
method: 'POST',
data: { model: 'deepseek-chat', messages: [{ role: 'user', content: 'Hello' }] }
});This method is ideal for text generation, completion, translation, or any scenario that only needs a stateless response.
Agent (smart‑agent) integration – Build a conversational expert that maintains context, accesses a knowledge base, and can invoke external services such as databases. The agent is defined by a JSON configuration that includes a welcome prompt, retrieval instructions, and optional function calls. The platform automatically stores conversation history and supports feedback loops for continual improvement.
AI dialogue UI component – Drag‑and‑drop a pre‑built front‑end component into the mini‑program page. The component handles UI rendering, session management, and API invocation without additional code. It is suited for rapid prototyping, MVPs, or when UI consistency is a priority.
Voice interaction – three‑step setup
Enable voice capability – Log in to the Real‑Time Audio‑Video (TRTC) console, locate the “AI real‑time dialogue” entry and click “Start”. No server or code changes are required.
Configure STT, LLM, and TTS – Follow the wizard to select a speech‑to‑text engine (e.g., Tencent Cloud ASR), the DeepSeek LLM for inference, and a text‑to‑speech engine of choice. The wizard records the selected model IDs and generates a configuration JSON that the mini‑program consumes.
Start the conversation – Launch the dialogue UI. The system streams microphone audio, performs STT, sends the transcribed text to DeepSeek, receives the response, and streams TTS audio back to the user. Parameters such as noise reduction level, interruption timeout, and speech speed can be adjusted at runtime, and latency metrics for each LLM‑TTS pair are displayed in the console.
Supported Tencent Cloud products
High‑Performance Application Service (HAI) – Private deployment of DeepSeek models (R1‑1.5B/7B/8B/14B/32B). One‑click launch, pay‑as‑you‑go pricing.
CloudStudio – Zero‑code environment for quick model trials. Provides free compute minutes.
Cloud Native Build (cnb.cool) – Remote development with branch‑as‑environment. Supports all DeepSeek sizes up to 70B and offers 1 600 core‑hours free per month.
TI Platform – High‑concurrency, distributed inference, enterprise monitoring. Supports DeepSeek V3‑671B and other sizes.
Public Cloud API – Direct HTTP calls to DeepSeek models without additional services.
Real‑Time Audio‑Video (TRTC) – No‑code AI voice chat using configurable ASR, LLM, and TTS modules.
Cloud Development (CloudBase) – API‑driven smart mini‑programs; integrates DeepSeek with three lines of code.
Technical documentation and example code are available at:
https://docs.cloudbase.net/ai/miniprogram-using
GitHub repository with sample projects:
https://github.com/TencentCloudBase/cloudbase-ai-example
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Tencent Technical Engineering
Official account of Tencent Technology. A platform for publishing and analyzing Tencent's technological innovations and cutting-edge developments.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
