$npx -y skills add TencentCloudBase/cloudbase-skills --skill ai-model-webUse this skill when a browser/Web app (React, Vue, Angular, Next, Nuxt, static sites, SPAs, dashboards, AI chat UI) needs AI models via @cloudbase/js-sdk. Default routing for page/页面/Web/前端/frontend/网页/H5 AI — call directly from browser, do NOT propose a Node.js proxy. Covers gen
| 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-web/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 browser/Web applications** via `@cloudbase/js-sdk`. |
| 13 | |
| 14 | > 🧭 **Runtime-plane default for Web.** Any time the user's request is framed around a page, a Web app, the frontend, React/Vue/Next/Nuxt, a dashboard UI, or "add AI to my H5", this skill is the default routing target. **Do NOT first propose a Node.js / cloud-function / CloudRun proxy**; `@cloudbase/js-sdk` can call the model from the browser directly. Only switch to `ai-model-nodejs` if the user explicitly asks for a backend/server call, image generation, or a scenario that truly needs server-side keys or long-running work. This decision is independent of which concrete model the user picks — model names (`deepseek-*`, `glm-*`, `hunyuan-*`, `kimi-*`, …) only affect the `model` field, not the routing plane. |
| 15 | |
| 16 | **Use it when you need to:** |
| 17 | |
| 18 | - Integrate AI text generation into a frontend Web app |
| 19 | - Stream AI responses for a better UX |
| 20 | - Call Hunyuan / DeepSeek / GLM / Kimi / MiniMax models from the browser |
| 21 | |
| 22 | **Do NOT use for:** |
| 23 | |
| 24 | - Node.js backend or cloud functions → use the `ai-model-nodejs` skill |
| 25 | - WeChat Mini Program → use the `ai-model-wechat` skill |
| 26 | - Image generation → use the `ai-model-nodejs` skill (Node SDK only) |
| 27 | - Runtimes without a CloudBase SDK (native apps, Python, Go, etc.) → use the `http-api` skill (it now includes the `ai_model` OpenAPI spec for direct HTTP calls; do NOT build a custom HTTP proxy) |
| 28 | |
| 29 | --- |
| 30 | |
| 31 | ## ⛔ STOP — `ai.createModel(...)` argument is **not** a vendor / model name |
| 32 | |
| 33 | Read this before writing any `createModel(...)` line. The single most common mistake when agents generate code for this SDK is hallucinating the argument. There are **exactly three** legal shapes. Anything else is a bug. |
| 34 | |
| 35 | | ✅ Legal `ai.createModel(...)` argument | When to use it | |
| 36 | |----------------------------------------|----------------| |
| 37 | | `"cloudbase"` | **The main managed group for new projects** (TokenHub-backed, multi-vendor pool). Vendor + concrete model go into the **`model` field** of `generateText` / `streamText`, e.g. `{ model: "deepseek-v4-flash" }`. **No model is enabled by default — always check `DescribeAIModels` first and, if the target model is missing, enable it with `UpdateAIModel` before calling the SDK.** | |
| 38 | | `"hunyuan-exp"` | Only if `DescribeAIModels` explicitly returns this legacy builtin group for the current env (mainly the Mini Program Growth Plan — see `ai-model-wechat`). | |
| 39 | | `"custom-<your-name>"` | A user-defined GroupName you onboarded via `CreateAIModel`. **Must** start with `custom-` (e.g. `custom-kimi`, `custom-openai-compat`). | |
| 40 | |
| 41 | ### ❌ Do NOT write any of these — they are all wrong |
| 42 | |
| 43 | ```js |
| 44 | ai.createModel("deepseek") // wrong — that's a vendor, not a GroupName |
| 45 | ai.createModel("deepseek-v4-flash") // wrong — that's a model name, goes in the `model` field |
| 46 | ai.createModel("hunyuan") // wrong — vendor family, not a GroupName |
| 47 | ai.createModel("hunyuan-2.0-instruct-20251111") // wrong — model name |
| 48 | ai.createModel("glm") / ai.createModel("kimi") / ai.createModel("minimax") // wrong — vendor names |
| 49 | ai.createModel("openai") / ai.createModel("moonshot") // wrong — vendor names |
| 50 | ai.createModel("custom") // wrong — placeholder; use your real custom-<name> |
| 51 | ai.createModel(modelName) // wrong — do not reuse the va |