$npx -y skills add TencentCloudBase/cloudbase-skills --skill ai-model-nodejsUse this skill for Node.js backend AI via @cloudbase/node-sdk (>=3.16.0) — cloud functions, CloudRun, Express, Koa, NestJS, serverless APIs, scheduled jobs, LLM proxies. Only SDK supporting image generation (ai.createImageModel + generateImage). Text models via ai.createModel wit
| 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-nodejs/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 from Node.js backends, cloud functions, or CloudRun services** via `@cloudbase/node-sdk`. |
| 13 | |
| 14 | > 🧭 **Runtime-plane fit.** This is the right skill when the AI call truly belongs on the server: image generation (the only SDK that supports it), long-running agent jobs, orchestration across multiple tools, scheduled tasks, or flows that must keep secrets server-side. **If the user is building a Web page / frontend AI chat UI, do NOT wrap this SDK behind a backend proxy** — route to `ai-model-web` and call the model directly from the browser. For WeChat Mini Programs use `ai-model-wechat`. Routing is decided by runtime plane first; the concrete model (`deepseek-*`, `glm-*`, `hunyuan-*`, `kimi-*`, …) only affects the `model` field. |
| 15 | |
| 16 | **Use it when you need to:** |
| 17 | |
| 18 | - Integrate AI text generation into a backend service |
| 19 | - Generate images with the Hunyuan Image model |
| 20 | - Call AI models from CloudBase cloud functions or CloudRun |
| 21 | - Do server-side AI processing (agent orchestration, batch jobs, scheduled tasks) |
| 22 | |
| 23 | **Do NOT use for:** |
| 24 | |
| 25 | - Browser/Web apps → use the `ai-model-web` skill |
| 26 | - WeChat Mini Program → use the `ai-model-wechat` skill |
| 27 | - Runtimes without a CloudBase SDK (Python, Go, PHP, curl, etc.) → use the `http-api` skill (it now includes the `ai_model` OpenAPI spec for direct HTTP calls to the AI model endpoint; do NOT wrap this SDK behind an 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. Agents frequently hallucinate this 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 server-side 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. | |
| 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 | > Image generation is a separate entry point: `ai.createImageModel("hunyuan-image")`. Do not mix it with `createModel(...)`. |
| 42 | |
| 43 | ### ❌ Do NOT write any of these — they are all wrong |
| 44 | |
| 45 | ```js |
| 46 | ai.createModel("deepseek") // wrong — that's a vendor, not a GroupName |
| 47 | ai.createModel("deepseek-v4-flash") // wrong — model id goes in the `model` field |
| 48 | ai.createModel("hunyuan") / "hunyuan-2.0-instruct-20251111" // wrong — vendor / model name |
| 49 | ai.createModel("glm") / "kimi" / "minimax" // wrong — vendor names |
| 50 | ai.createModel("openai") / "moonshot" // wrong — vendor names |
| 51 | ai.createModel("custom") // wrong — placeholder; use your real custom-<name> |
| 52 | ai.createModel(modelName) // wrong — do not reuse the variable that holds the model id |
| 53 | ``` |
| 54 | |
| 55 | ### ✅ Correct pattern — GroupName vs Model are two different fields |
| 56 | |
| 57 | ```js |
| 58 | const model = ai.createModel("cloudbase"); |