ai-model-nodejs

Verify Token Credits and enable AI models before Node.js calls on Tencent CloudBase.

Updated May 14, 2026
One-click install
npx skills add https://github.com/williamwang25/ams-admin --skill ai-model-nodejs-williamwang25
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: ai-model-nodejs
Source: https://github.com/williamwang25/ams-admin/tree/main/.windsurf/skills/cloudbase/references/ai-model-nodejs
Command: npx skills add https://github.com/williamwang25/ams-admin --skill ai-model-nodejs-williamwang25

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill prevents runtime failures by guiding you to verify Token Credits eligibility and enable the exact AI model before calling @cloudbase/node-sdk from your Node.js server-side code.

Core Features & Use Cases

  • Server-side AI text generation: Use generateText and streamText in CloudBase cloud functions, CloudRun, or any Node.js backend that must keep keys and orchestration on the server.
  • Server-side AI image generation: Use ai.createImageModel("hunyuan-image") + generateImage, which is supported only by the Node SDK for Hunyuan image.
  • Guardrailed model readiness: Runs a mandatory two-step preflight (Token Credits resource pack eligibility + group readiness via DescribeAIModelsDescribeManagedAIModelListUpdateAIModel) so you never assume models are already enabled.

Quick Start

Instruct the agent to generate a server-side handler that calls a chosen managed model by first running the Token Credits and model enablement preflight steps, then using generateText or streamText to return the result.

Frequently Asked Questions about ai-model-nodejs

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I call AI models from Node.js without runtime failures?

Calling AI models from Node.js requires verifying Token Credits eligibility and enabling the target model before invocation. Run preflight checks using `DescribeAIModels` and `UpdateAIModel` to prevent runtime failures in your backend.

How do I generate streaming text in a Tencent CloudBase cloud function?

Generating streaming text in a Tencent CloudBase cloud function uses the `streamText` method from `@cloudbase/node-sdk`. You must first verify Token Credits and enable the model group via `createModel(GroupName)`.

Can I use generateImage with Hunyuan models in my Node.js backend?

Yes, generating images with Hunyuan models in your Node.js backend uses `ai.createImageModel("hunyuan-image")` followed by `generateImage`. This server-side AI image generation is supported exclusively by the Node SDK.

Why does my Node.js AI model invocation fail on Tencent CloudBase?

Your Node.js AI model invocation fails if you assume models are already enabled. You must execute a mandatory preflight checking Token Credits via `DescribeEnvPostpayPackage` and model readiness via `DescribeManagedAIModelList` before calling `generateText`.

Do I need Token Credits to use generateText in a CloudRun service?

Yes, using `generateText` in a CloudRun service requires Token Credits. The process involves calling `DescribeEnvPostpayPackage` to verify your resource pack eligibility before you can safely enable and invoke the managed AI model.