$npx -y skills add TencentCloudBase/cloudbase-skills --skill ai-model-wechatUse this skill for WeChat Mini Program AI via wx.cloud.extend.AI (小程序, 企业微信小程序, wx.cloud apps). Features generateText and streamText with callbacks (onText, onEvent, onFinish). Models via wx.cloud.extend.AI.createModel with groups hunyuan-exp (小程序成长计划), cloudbase (main managed),
| 1 | ## Standalone Install Note |
| 2 | |
| 3 | If this environment only installed the current skill, start from the CloudBase main entry and use the published `cloudbase/references/...` paths for sibling skills. |
| 4 | |
| 5 | - CloudBase main entry: `https://cnb.cool/tencent/cloud/cloudbase/cloudbase-skills/-/git/raw/main/skills/cloudbase/SKILL.md` |
| 6 | - Current skill raw source: `https://cnb.cool/tencent/cloud/cloudbase/cloudbase-skills/-/git/raw/main/skills/cloudbase/references/ai-model-wechat/SKILL.md` |
| 7 | |
| 8 | Keep local `references/...` paths for files that ship with the current skill directory. When this file points to a sibling skill such as `auth-tool` or `web-development`, use the standalone fallback URL shown next to that reference. |
| 9 | |
| 10 | ## When to use this skill |
| 11 | |
| 12 | Use this skill for **calling AI models in WeChat Mini Program** using `wx.cloud.extend.AI`. |
| 13 | |
| 14 | **Use it when you need to:** |
| 15 | |
| 16 | - Integrate AI text generation in a Mini Program |
| 17 | - Stream AI responses with callback support |
| 18 | - Call Hunyuan models from the WeChat environment |
| 19 | |
| 20 | **Do NOT use for:** |
| 21 | |
| 22 | - Browser/Web apps → use `ai-model-web` skill |
| 23 | - Node.js backend or cloud functions → use `ai-model-nodejs` skill |
| 24 | - Image generation → use `ai-model-nodejs` skill (not available in Mini Program) |
| 25 | - Runtimes without a CloudBase SDK (native apps, Python, etc.) → use `http-api` skill (it now includes the `ai_model` OpenAPI spec for direct HTTP calls) |
| 26 | |
| 27 | --- |
| 28 | |
| 29 | ## ⛔ STOP — `wx.cloud.extend.AI.createModel(provider)` argument is **not** a vendor / model name |
| 30 | |
| 31 | Read this before writing any `createModel(...)` line. Agents frequently hallucinate this argument. There are **exactly three** legal shapes. Anything else is a bug. |
| 32 | |
| 33 | | ✅ Legal `createModel(provider)` argument | When to use it | |
| 34 | |-----------------------------------------|----------------| |
| 35 | | `"hunyuan-exp"` | The Mini Program **成长计划** (`ai_miniprogram_inspire_plan`) is enrolled for the current env. Default model: `hunyuan-2.0-instruct-20251111`. | |
| 36 | | `"cloudbase"` | Default fallback. Main managed group (TokenHub-backed, multi-vendor pool). Vendor + concrete model go into the **`model` field**, e.g. `{ model: "deepseek-v4-flash" }`. | |
| 37 | | `"custom-<your-name>"` | A user-defined GroupName you onboarded via `CreateAIModel`. **Must** start with `custom-` (e.g. `custom-kimi`, `custom-openai-compat`). | |
| 38 | |
| 39 | ### ❌ Do NOT write any of these — they are all wrong |
| 40 | |
| 41 | ```js |
| 42 | wx.cloud.extend.AI.createModel("deepseek") // wrong — vendor, not GroupName |
| 43 | wx.cloud.extend.AI.createModel("deepseek-v4-flash") // wrong — model id goes in `model` |
| 44 | wx.cloud.extend.AI.createModel("hunyuan") // wrong — vendor family |
| 45 | wx.cloud.extend.AI.createModel("hunyuan-2.0-instruct-20251111") // wrong — model name |
| 46 | wx.cloud.extend.AI.createModel("glm") / "kimi" / "minimax" // wrong — vendor names |
| 47 | wx.cloud.extend.AI.createModel("custom") // wrong — placeholder |
| 48 | wx.cloud.extend.AI.createModel(modelName) // wrong — do not reuse the model-id variable |
| 49 | ``` |
| 50 | |
| 51 | ### ✅ Correct pattern — provider vs model are two different fields |
| 52 | |
| 53 | ```js |
| 54 | // Growth Plan branch |
| 55 | const model = wx.cloud.extend.AI.createModel("hunyuan-exp"); // ← provider / GroupName |
| 56 | await model.streamText({ |
| 57 | data: { model: "hunyuan-2.0-instruct-20251111", messages: [...] } // ← concrete model id |
| 58 | }); |
| 59 | |
| 60 | // Token Credits branch |
| 61 | const model = wx.cloud.extend.AI.createModel("cloudbase"); |
| 62 | await model.streamText({ |
| 63 | data: { model: "deepseek-v4-flash", messages: [...] } |
| 64 | }); |
| 65 | ``` |
| 66 | |
| 67 | ### Decision procedure (when the user names a specific model) |
| 68 | |
| 69 | 1. The user says "use DeepSeek v3.2" / "use hunyuan thinking" / "use Kimi k2.6" / … |
| 70 | 2. First run the eligibility decision tree below — the correct `provider` may be `"hunyuan-exp"` (if the env is on Growth Plan and the user asked for a `hunyuan-*` model) or `"cloudbase"` (anything else in the managed catalog). |
| 71 | 3. Put the model id into the **`model` field** inside `data`: `{ model: "deepseek-v3.2" }`, `{ model: "hunyuan-2.0-instruct-20251111" }`, `{ model: "kimi-k2.6" }`, … |
| 72 | 4. Before usin |