- name
SKILL.md
스킬 파일은 게시자의 저장소에 그대로 있습니다.
복사한 명령을 터미널에 붙여넣습니다. 이 SKILL.md가 해당 에이전트에 설치됩니다.
npx skills add TencentCloudBase/CloudBase-AI-Toolkit --skill ai-model-wechat -a cursor -y복사한 명령을 터미널에 붙여넣습니다. 이 SKILL.md가 해당 에이전트에 설치됩니다.
npx skills add TencentCloudBase/CloudBase-AI-Toolkit --skill ai-model-wechat -a claude-code -y복사한 명령을 터미널에 붙여넣습니다. 이 SKILL.md가 해당 에이전트에 설치됩니다.
npx skills add TencentCloudBase/CloudBase-AI-Toolkit --skill ai-model-wechat -a codex -y복사한 명령을 터미널에 붙여넣습니다. 이 SKILL.md가 해당 에이전트에 설치됩니다.
npx skills add TencentCloudBase/CloudBase-AI-Toolkit --skill ai-model-wechat -a grok -y복사한 메시지를 Grok Bot 채팅에 보냅니다. Bot이 GitHub에서 이 SKILL.md를 가져와 모든 Bot이 공유하는 스킬에 추가합니다.
Install this skill: https://github.com/TencentCloudBase/CloudBase-AI-Toolkit/tree/HEAD/config/.claude/skills/ai-model-wechat게시자 제공
Sibling CloudBase skills ship beside this skill. Use local relative paths such as ../auth-tool-cloudbase/SKILL.md.
If a referenced sibling skill file is missing from this environment, ask the user to install the full CloudBase plugin (or the missing skill). Do not HTTP-fetch remote skill or protocol markdown into the agent context.
Use this skill for calling AI models in WeChat Mini Program using wx.cloud.extend.AI.
Use it when you need to:
Do NOT use for:
ai-model-web skillai-model-nodejs skillai-model-nodejs skill (not available in Mini Program)http-api-cloudbase skill (it now includes the ai_model OpenAPI spec for direct HTTP calls)wx.cloud.extend.AI.createModel(provider) argument is not a vendor / model nameRead this before writing any createModel(...) line. Agents frequently hallucinate this argument. There are exactly four legal shapes. Anything else is a bug.
wx.cloud.extend.AI.createModel("deepseek") // wrong — vendor, not GroupName
wx.cloud.extend.AI.createModel("deepseek-v4.1-flash") // wrong — model id goes in `model`
wx.cloud.extend.AI.createModel("hunyuan") // wrong — vendor family
wx.cloud.extend.AI.createModel("hunyuan-2.0-instruct-20251111") // wrong — model name
wx.cloud.extend.AI.createModel("glm") / "kimi" / "minimax" // wrong — vendor names
wx.cloud.extend.AI.createModel("custom") // wrong — placeholder
wx.cloud.extend.AI.createModel(modelName) // wrong — do not reuse the model-id variable
// Growth Plan branch (enable the model in the console first)
const model = wx.cloud.extend.AI.createModel("cloudbase"); // ← provider / GroupName
await model.streamText({
data: { model: "deepseek-v4.1-flash", messages: [...] } // ← concrete model id
});
// Token Credits branch — same provider, any managed model you enabled
await model.streamText({
data: { model: "glm-5.3", messages: [...] }
});
"cloudbase" in almost every case, including Growth Plan environments (cloudbase + a plan model). "hunyuan-v3" only appears in existing code that already used it; "hunyuan-exp" only if DescribeAIModels still returns that older group.model field: { model: "deepseek-v4.1-flash" }, { model: "hy3" }, { model: "kimi-k2.6" }, … (inside data when you call streamText).DescribeAIModels({ GroupName: "cloudbase" }).Models[]. If not, enable it via UpdateAIModel.If you are about to type
wx.cloud.extend.AI.createModel(and the thing inside the parentheses is a vendor name or a model id — stop. It is almost certainly one of the four legal values above.
You MUST NOT jump straight into wx.cloud.extend.AI.createModel(...). Before writing any business code, confirm billing eligibility and group readiness in this fixed order: ① eligibility → ② group readiness. Do not swap the two.
The Mini Program side has two billing paths: 小程序成长计划 (checked first) and Token Credits 资源包 (generic fallback). Both settle through the cloudbase main managed group — on the plan, the model is one of hy4-preview / hy3 / deepseek-v4.1-flash, and the plan quota is drawn first; hunyuan-v3 is the legacy plan group that only draws plan quota and is being retired.
Fetch envId via the MCP tool queryEnv action=info.
Pick the branch by user intent:
callCloudApi({
service: "tcb",
action: "DescribeActivityInfo",
params: {
ActivityNames: ["ai_miniprogram_inspire_plan"], // PascalCase preferred; switch to camelCase if InvalidParameter is returned
},
})
Hit criterion: the response's attendRecords contains at least one entry where activityName === "ai_miniprogram_inspire_plan" and envId matches the current environment. On hit, use createModel("cloudbase") + one of hy4-preview / hy3 / deepseek-v4.1-flash (enable it in the group first); the call draws the plan's free quota. Pick deepseek-v4.1-flash unless the user needs a text-only model. Legacy code on createModel("hunyuan-v3") + hy3 still works but that group is being retired — migrate it to cloudbase.
⚠️ The gifted Token is source-scoped. It applies to Mini Program client calls and administrator-identity calls (console playground, calls made inside a cloud function) only. A call from any other origin does not draw on it and settles against the environment's resource-point pool instead — which is what a user sees as "the Token pack did not apply, resource points were charged". When a report sounds like that, check the call origin before touching the code or the model config. Same rule for the Token Credits pack path below.
On miss: do NOT silently fall back. Tell the user "the current environment is not enrolled in 小程序成长计划", surface the enrollment entry https://docs.cloudbase.net/ai/ai-inspire-plan, and ask whether to enroll and retry, or to switch to the Token Credits resource pack path with a non-hunyuan model.
"cloudbase" main managed group):callCloudApi({
service: "tcb",
action: "DescribeEnvPostpayPackage",
params: {
EnvId: "<current envId>",
},
})
Hit criterion: envPostpayPackageInfoList contains an entry whose postpayPackageId starts with pkg_tcb_tokencredits_, has status ∉ [3, 4] (not expired, not disabled), and versionSwitchStatus is not in a blocking state.
On miss: surface the purchase link (replace {region} with the environment's Region from queryEnv, e.g. ap-shanghai, and {envId} with the real ID — never leave the placeholders):
https://buy.cloud.tencent.com/CloudBase?buyType=resPack®ion={region}&envId={envId}
Passing eligibility does not mean the target model is callable. No model is enabled by default in the "cloudbase" main managed group — you must first call DescribeAIModels to see what is enabled, then (if missing) DescribeManagedAIModelList for the authoritative supported-model catalog and UpdateAIModel with Status: 1 to enable it. Growth Plan enrollment does not skip this check: the chosen plan model must still be present and enabled in the cloudbase group. Legacy "hunyuan-v3" exposes only hy3 and is being retired — treat it as read-only compatibility, not the default.
tcb Action DescribeAIModels, Version 2018-06-08):callCloudApi({
service: "tcb",
action: "DescribeAIModels",
params: { EnvId: "<envId>" },
})
Returns AIModelGroups: AIModelGroup[]. Each AIModelGroup has GroupName (e.g. cloudbase / hunyuan-exp / your custom group), Type (builtin / custom), Models: [{ Model, EnableMCP, Tags }], and Status (1=on / 2=off). Group readiness = all three of: the GroupName exists + Status === 1 + the target Model is present in Models[].
DescribeAIModels response, query the platform catalog + pricing via DescribeManagedAIModelList — it returns ManagedAIModelGroup[] including ModelSpec (context length, etc.) and ModelChargingInfo (Uniform / Tiered pricing). Pick the target model, then enable it via UpdateAIModel:callCloudApi({
service: "tcb",
action: "UpdateAIModel",
params: {
EnvId: "<envId>",
GroupName: "cloudbase",
Status: 1, // 1=on, 2=off
Models: [
{ Model: "deepseek-v4.1-flash", EnableMCP: false },
{ Model: "hy3", EnableMCP: false }, // append the new model to enable
],
// ⚠️ `Models` is a FULL REPLACEMENT, not incremental; merge the old list + new entries before passing.
},
})
wx.cloud.extend.AI.createModel("<GroupName>") in the Mini Program code, and pass a model value that exists in that group's Models[].Order is fixed. Without eligibility, no enabled model will bill; without group readiness, even with eligibility you will receive
ModelNotEnabled-class errors. Both must be done before business code.API casing tip:
tcbpublic-service Actions officially use PascalCase (EnvId,GroupName,ActivityNames); some docs show camelCase. On the first call, if you hitInvalidParameter, switch casing and retry, then freeze the working form in your project's wrapper.
The provider argument of wx.cloud.extend.AI.createModel(provider) equals the GroupName returned by DescribeAIModels. Only the four kinds of values below are legal. Run the decision tree before choosing.
cloudbase, model is one of the three plan modelsThe "cloudbase" GroupName is backed by Tencent Cloud TokenHub, a unified managed pool that covers multiple first-party and third-party vendors — including the Hunyuan family (HY 2.0 Instruct, HY 2.0 Think, Hunyuan-role, Hy3 preview, …), DeepSeek family (DeepSeek-V4-Pro, DeepSeek-V4-Flash, Deepseek-v3.2, Deepseek-v3.1, Deepseek-r1-0528, Deepseek-v3-0324, …), Zhipu GLM (GLM-5, GLM-5-Turbo, GLM-5.1, GLM-5V-Turbo), Kimi (K2.5, K2.6), MiniMax (M2.5, M2.7) and more. The roster evolves over time, so do not hard-code the list in application code — always discover it at runtime.
⚠️ Common Mini Program mistake: writing
createModel("deepseek")/createModel("hunyuan")/createModel("glm")/createModel("kimi")/createModel("minimax")/createModel("custom"). All wrong — those are vendor / model names, not provider / GroupName. The provider must be one of theGroupNamevalues returned byDescribeAIModels. New projects always use the unified"cloudbase"managed group and select the concrete vendor model via themodelfield.
Models involving third-party / self-hosted / OpenAI-compatible endpoints (anything not appearing in A/B) do NOT go through the billing paths above. You must register a Type=custom GroupName via "Custom onboarding" first. See ./references/custom-onboarding.md.
SKILL.md keeps the guardrails and the mandatory preflight. Detailed examples live under ./references/.
Read the matching file before writing code:
Complete the two-step preflight before using any example. Keep the four legal createModel(provider) values and the model field rule from the STOP section above.
DescribeActivityInfo / DescribeEnvPostpayPackage for billing eligibility → ② DescribeAIModels for group readiness (if needed, DescribeManagedAIModelList for catalog + pricing, then UpdateAIModel to enable the target model). Only after both pass should you write wx.cloud.extend.AI.createModel(...).createModel(provider) accepts only four kinds of values — "cloudbase" (main managed group, default for new projects and for 成长计划), "hunyuan-v3" (legacy plan group, only hy3, being retired), "hunyuan-exp" (older legacy builtin), or the custom-onboarding GroupName (MUST start with custom-, e.g. custom-kimi, custom-openai-compat, to avoid colliding with built-in / vendor names). Never write createModel("deepseek") (unless DescribeAIModels truly returns a legacy builtin group named deepseek), createModel("hunyuan"), createModel("kimi"), or createModel("custom") — these are model/vendor names or placeholders, not GroupNames.model field must come from DescribeAIModels. Pass a value that actually exists in the Models[].Model list of the chosen group. No model is enabled by default — if the model you want is missing, call UpdateAIModel first.cloudbase + one of hy4-preview / hy3 / deepseek-v4.1-flash; hunyuan-v3 (only hy3) still draws it too but is being retired. When not enrolled, guide the user to https://docs.cloudbase.net/ai/ai-inspire-plan, or use "cloudbase" + a managed model under the resource pack.DescribeManagedAIModelList returns ModelChargingInfo (Uniform flat price / Tiered tiered pricing) + ModelSpec.ContextLength. Confirm before calling UpdateAIModel. Models is a full replacement — merge the old list + the new entry before passing.Use this skill for WeChat Mini Program AI via wx.cloud.extend.AI (小程序, wx.cloud apps). Covers generateText and streamText with callbacks (onText, onEvent, onFinish); streamText needs a data wrapper, g
---name: ai-model-wechatdescription: Use this skill for WeChat Mini Program AI via wx.cloud.extend.AI (小程序, wx.cloud apps). Covers generateText and…---# config/.claude/skills/ai-model-wechat/SKILL.md개요
Use this skill for WeChat Mini Program AI via wx.cloud.extend.AI (小程序, wx.cloud apps). Covers generateText and streamText with callbacks (onText, onEvent, onFinish); streamText needs a data wrapper, generateText returns the raw response. Also covers multimodal image input (image_url content blocks, OCR and form extraction) — vision-capable models only. Models via wx.cloud.extend.AI.createModel with groups cloudbase (main managed, also 小程序成长计划 with `hy4-preview` / `hy3` / `deepseek-v4.1-flash`), the legacy hunyuan-v3 / hunyuan-exp, or custom-*; model id goes in the `model` field. MUST run two-step preflight before code — see body. NOT for browser/Web (use ai-model-web), Node.js backend (use ai-model-nodejs), or image generation (use ai-model-nodejs).
FAQ
게시자에게서 config/.claude/skills/ai-model-wechat/SKILL.md를 다운로드하거나 경로를 복사해 저장소를 엽니다. PlugMCP는 스킬을 목록에 올릴 뿐 파일을 호스팅하지 않습니다.
게시자가 https://github.com/TencentCloudBase/CloudBase-AI-Toolkit에서 관리합니다.
Claude, Cursor, Codex, Grok Build는 게시자의 저장소에서 추가한 SKILL.md를 읽을 수 있습니다. Grok Bot은 채팅에서 스킬의 GitHub 폴더 링크를 보내면 설치합니다.
wx.cloud.extend.AI is undefined — do not debug it as a model issue.onText is well-suited for progressively refreshing chat bubbles; manually concatenating from eventStream tends to drop separators.[DONE]. When iterating eventStream, stop only when event.data === "[DONE]", otherwise the stream waits forever for the next frame.data wrapper. streamText parameters MUST be wrapped in data: { ... } — unlike JS/Node SDK. Forgetting it yields a parameter error.UpdateAIModel flows; the latter is about debugging prompts, parameters, or the network. The error messages and next actions are completely different.CreateAIModel (Secret.ApiKey) so the key is stored on the CloudBase side; keep only the GroupName in the Mini Program.any to silence type errors. If the wx.cloud.extend.AI surface is missing types, declare a precise interface for the slice you actually use, or augment via a local .d.ts. Never : any, as any, @ts-ignore, @ts-nocheck.streamText / generateText flow end-to-end, and confirm: (a) the text chunks arrive via onText, (b) [DONE] terminates the stream, (c) no new console errors. "It should work" without an actual run is not acceptable evidence.