ai-model-nodejs
Provides AI model connectivity for Node.js backends and CloudBase services, supporting text and image generation.
Install
mkdir -p .claude/skills/ai-model-nodejs && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/6930" && unzip -o skill.zip -d .claude/skills/ai-model-nodejs && rm skill.zipInstalls to .claude/skills/ai-model-nodejs
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
Use 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 with groups cloudbase, hunyuan-exp, or custom-*. Model IDs (deepseek-v4-flash, deepseek-v3.2, hunyuan-2.0-instruct-20251111, glm-5, kimi-k2.6) go in the model field of generateText/streamText. MUST run two-step preflight before code — see body. Keywords: backend, 云函数, 云托管, serverless, LLM proxy, agent orchestration, generateText, streamText, generateImage, createModel, hunyuan-image, Token Credits, TokenHub, Hunyuan, DeepSeek, GLM, Kimi, MiniMax. NOT for browser/Web (use ai-model-web) or Mini Program (use ai-model-wechat).Key capabilities
- →Initializes AI model clients for Node.js backends
- →Streams text generation from models like Hunyuan or DeepSeek
- →Generates images using dedicated SDK methods
- →Handles server-side LLM proxy requests
- →Configures token credit usage for backend tasks
How it works
It wraps the CloudBase Node SDK functions to authorize and route API calls to specific AI backends from a server environment.
Inputs & outputs
When to use ai-model-nodejs
- →Building LLM-powered backend APIs
- →Generating images in cloud functions
- →Implementing AI agents in serverless environments
About this skill
Sibling skills (local only)
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.
When to use this skill
Use this skill for calling AI models from Node.js backends, cloud functions, or CloudRun services via @cloudbase/node-sdk.
🧭 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-weband call the model directly from the browser. For WeChat Mini Programs useai-model-wechat. Routing is decided by runtime plane first; the concrete model (deepseek-*,glm-*,hunyuan-*,kimi-*, …) only affects themodelfield.
Use it when you need to:
- Integrate AI text generation into a backend service
- Generate images with the Hunyuan Image model
- Call AI models from CloudBase cloud functions or CloudRun
- Do server-side AI processing (agent orchestration, batch jobs, scheduled tasks)
Do NOT use for:
- Browser/Web apps → use the
ai-model-webskill - WeChat Mini Program → use the
ai-model-wechatskill - Runtimes without a CloudBase SDK (Python, Go, PHP, curl, etc.) → use the
http-api-cloudbaseskill (it now includes theai_modelOpenAPI spec for direct HTTP calls to the AI model endpoint; do NOT wrap this SDK behind an HTTP proxy)
⛔ STOP — ai.createModel(...) argument is not a vendor / model name
Read this before writing any createModel(...) line. Agents frequently hallucinate this argument. There are exactly three legal shapes. Anything else is a bug.
✅ Legal ai.createModel(...) argument | When to use it |
|---|---|
"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. |
"hunyuan-exp" | Only if DescribeAIModels explicitly returns this legacy builtin group for the current env. |
"custom-<your-name>" | A user-defined GroupName you onboarded via CreateAIModel. Must start with custom- (e.g. custom-kimi, custom-openai-compat). |
Image generation is a separate entry point:
ai.createImageModel("hunyuan-image"). Do not mix it withcreateModel(...).
❌ Do NOT write any of these — they are all wrong
ai.createModel("deepseek") // wrong — that's a vendor, not a GroupName
ai.createModel("deepseek-v4-flash") // wrong — model id goes in the `model` field
ai.createModel("hunyuan") / "hunyuan-2.0-instruct-20251111" // wrong — vendor / model name
ai.createModel("glm") / "kimi" / "minimax" // wrong — vendor names
ai.createModel("openai") / "moonshot" // wrong — vendor names
ai.createModel("custom") // wrong — placeholder; use your real custom-<name>
ai.createModel(modelName) // wrong — do not reuse the variable that holds the model id
✅ Correct pattern — GroupName vs Model are two different fields
const model = ai.createModel("cloudbase"); // ← GroupName
await model.generateText({
model: "deepseek-v4-flash", // ← concrete model id
messages: [...]
});
Decision procedure (when the user names a specific model)
- The user says "use DeepSeek v3.2" / "use hunyuan instruct" / "use Kimi k2.6" / "use GLM-5" / …
createModel("cloudbase")stays the same.- Put the model id into the
modelfield:{ model: "deepseek-v3.2" },{ model: "hunyuan-2.0-instruct-20251111" },{ model: "kimi-k2.6" },{ model: "glm-5" }, … - Never assume the model is already enabled. Before calling the SDK, verify it is present in
DescribeAIModels({ GroupName: "cloudbase" }).Models[]. If missing, callDescribeManagedAIModelListto confirm the exactModelname the platform supports (case-sensitive — do not guess the spelling) and then enable it viaUpdateAIModelwithStatus: 1(rememberModelsis a full replacement).
If you are about to type
ai.createModel(and the thing inside the parentheses is a vendor name, a model name, or a guess — stop. It is almost certainly one of the three legal values above.
Mandatory Two-Step Preflight (before any SDK code)
Before calling any AI API on the server, run the two-step preflight: ① eligibility, ② group readiness. Text generation and image generation draw from the same Token Credits resource pack, and both must complete the preflight before code is emitted.
Step 0: obtain the environment ID
Call the MCP tool envQuery with action=info and read EnvId from the response.
Preflight ① — Eligibility (Token Credits resource pack)
Call the MCP tool:
callCloudApi(service="tcb", action="DescribeEnvPostpayPackage", params={ EnvId })
Pass conditions (all required):
-
envPostpayPackageInfoListcontains at least one entry -
That entry's
postpayPackageIdstarts withpkg_tcb_tokencredits_ -
That entry's
statusis NOT in[3, 4](3 / 4 typically mean expired / disabled; trust the live response) -
❌ Not satisfied → stop writing code and surface this to the user (replacing
{envId}with the real id):The current environment has no active Token Credits resource pack. Please purchase one before calling any AI API: https://buy.cloud.tencent.com/lowcode?buyType=resPack&envId={envId}&resourceType=token
Let me know once it's done and I'll re-check the resource pack status.
-
✅ Satisfied → proceed to preflight ②.
Parameter casing is PascalCase by contract. If the call returns
InvalidParameter, fall back to camelCase (envId) and trust the live response.
Preflight ② — Group readiness (DescribeAIModels → UpdateAIModel if needed)
Eligibility alone is not enough. Do not write createModel("cloudbase") yet. First confirm that the target GroupName exists in the env with Status=1, and that the target Model is present in its Models[].
-
List groups configured in the current env:
callCloudApi(service="tcb", action="DescribeAIModels", params={ EnvId })Returns
AIModelGroups: AIModelGroup[]withGroupName,Type(builtin/custom),Models: [{ Model, EnableMCP, Tags }],Status(1 / 2),BaseUrl,Secret,Remark. The main managedGroupNameiscloudbase. -
Never assume a model is already enabled. Inspect
AIModelGroups[?].Models[].Modelfor the target group. If the text model you plan to use (e.g.deepseek-v4-flash, or whatever the user asked for) is missing from thecloudbasegroup'sModels[], jump to step 4 and enable it — do not callcreateModel("cloudbase")yet. Image generation usescreateImageModel("hunyuan-image")+model: "hunyuan-image"; verify it is likewise enabled before the call. -
User asked for a model from the managed catalog (e.g.
deepseek-v3.2,hunyuan-2.0-instruct-20251111): check whether thatModelis already in thecloudbasegroup'sModels[]. If not, jump to step 4. Do not guess the exact model id — confirm the canonical spelling inDescribeManagedAIModelListfirst. -
Enable / add a managed model (always inspect the authoritative catalog + pricing first):
callCloudApi(service="tcb", action="DescribeManagedAIModelList", params={ EnvId })Returns
ManagedAIModelGroup[]withGroupName,Remark, andModels: [{ Model, EnableMCP, ModelSpec, ModelChargingInfo }]. This is the single source of truth for supported model names and pricing — do not infer them from memory. Use the exactModelstring from here when callingUpdateAIModel.ModelChargingInfoincludes input / output prices and billing unit. Surface the prices to the user before enabling.Then enable (note:
Modelsis a full replacement — always resend the already-enabled models together with the new one):callCloudApi(service="tcb", action="UpdateAIModel", params={ EnvId, GroupName: "cloudbase", Models: [ // resend every model that DescribeAIModels already showed as enabled { Model: "<already-enabled model>" }, // append the newly-requested one, using the exact spelling from DescribeManagedAIModelList { Model: "<target model>" } ], Status: 1 }) -
The requested model is not in the managed catalog (not found by
DescribeManagedAIModelList) → jump to the next section, Custom onboarding (models outside the managed catalog).
All Actions use
service=tcb,Version=2018-06-08. Parameters are PascalCase; fall back to camelCase only onInvalidParameter.
Available Providers and Models
ai.createModel(<GroupName>) accepts exactly three kinds of legal values; ai.createImageModel("hunyuan-image") is the dedicated image-generation entry point.
1. "cloudbase" — the main managed group (recommended)
GroupName: "cloudbase",Type: "builtin",Remark: "腾讯云开发"(Tencent CloudBase)- Backed by Tencent Cloud TokenHub, a unified managed pool covering multiple vendors — Hunyuan (HY 2.0 Instruct, HY 2.0 Think, Hunyuan-role, Hy3 preview, …), DeepSeek (DeepSeek-V4-Pro, DeepSeek-V4-Flash, Deepseek-v3.2, Deepseek-v3.1, Deepseek-r1-0528, Deepseek-v3-0324
Content truncated.
When not to use it
- →Building frontend browser applications
- →Client-side WeChat Mini Program development
Prerequisites
Limitations
- →Requires active server-side runtime environment
- →Strict model group compatibility requirements
How it compares
It provides server-side access to image generation and long-lived agent tasks that are otherwise restricted or impossible in client-side environments.
Compared to similar skills
ai-model-nodejs side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| ai-model-nodejs (this skill) | 5 | 2mo | Review | Intermediate |
| Video Generation | 0 | 3mo | Review | Intermediate |
| add-ai-endpoint | 0 | 4mo | Review | Intermediate |
| telegram-bot-builder | 106 | 6mo | Review | Intermediate |
Try saying
Example prompts that trigger this skill in your AI assistant.
More by TencentCloudBase
View all by TencentCloudBase →You might also like
Video Generation
e2662020
Implement AI-powered video generation capabilities using the z-ai-web-dev-sdk. Use this skill when the user needs to generate videos from text prompts or images, create video content programmatically, or build applications that produce video outputs. Supports asynchronous task management with status
add-ai-endpoint
malhajri07
Scaffold a Claude API powered endpoint with system prompt, structured output, token tracking, and rate limiting. Use when adding AI features like chatbot, matching, or text generation.
telegram-bot-builder
davila7
Expert in building Telegram bots that solve real problems - from simple automation to complex AI-powered bots. Covers bot architecture, the Telegram Bot API, user experience, monetization strategies, and scaling bots to thousands of users. Use when: telegram bot, bot api, telegram automation, chat bot telegram, tg bot.
telegram-mini-app
davila7
Expert in building Telegram Mini Apps (TWA) - web apps that run inside Telegram with native-like experience. Covers the TON ecosystem, Telegram Web App API, payments, user authentication, and building viral mini apps that monetize. Use when: telegram mini app, TWA, telegram web app, TON app, mini app.
stripe-integration
wshobson
Implement Stripe payment processing for robust, PCI-compliant payment flows including checkout, subscriptions, and webhooks. Use when integrating Stripe payments, building subscription systems, or implementing secure checkout flows.
langchain-architecture
wshobson
Design LLM applications using the LangChain framework with agents, memory, and tool integration patterns. Use when building LangChain applications, implementing AI agents, or creating complex LLM workflows.