Skip to main content

AI Model Management

version tip

Added since v5.2.0. Accessed via app.aiModel, this module provides configuration, query, update and deletion capabilities for AI model groups in a CloudBase environment, and supports OpenAI-compatible gateways (e.g. DeepSeek, Hunyuan, Moonshot).

AiModelService is organized around the AI Model Group (AIModelGroup). Each group contains:

  • GroupName: group name. Custom group names MUST NOT start with cloudbase (reserved prefix).
  • BaseUrl: model service URL (must be an OpenAI-compatible gateway).
  • Models: list of models under this group. Replaced as a whole on update.
  • Secret: credentials used to access the model service. Either SecretId / SecretKey or ApiKey.
  • Status: group status. 1 = enabled, 2 = disabled.
  • Type: group type. builtin (provided by CloudBase) / custom (user-defined).

Initialization

import CloudBase from '@cloudbase/manager-node'

const app = CloudBase.init({
secretId: 'Your SecretId',
secretKey: 'Your SecretKey',
envId: 'Your envId'
})

const aiModel = app.aiModel

createAIModel

1. API Description

API feature: Creates a custom AI model configuration group.

API declaration: app.aiModel.createAIModel(options): Promise<CreateAIModelResp>

Note

groupName MUST NOT start with cloudbase, which is a reserved prefix. The server validates baseUrl + secret connectivity, so make sure the model service is reachable and the credentials are valid.

2. Input Parameters

FieldRequiredTypeDescription
groupNameRequiredStringGroup name. Must not start with cloudbase.
baseUrlNoStringModel service URL (OpenAI-compatible gateway), e.g. https://api.deepseek.com/v1.
modelsNoAIModel[]Model list. See AIModel below.
remarkNoStringGroup remark.
statusNo1 | 2Model status. 1 = enabled, 2 = disabled.
secretNoAIModelSecretModel credentials. See AIModelSecret below.
envIdNoStringEnvironment ID. Falls back to the current environment if omitted.

AIModel

FieldRequiredTypeDescription
ModelNoStringModel name, e.g. deepseek-chat.
EnableMCPNoBooleanWhether MCP is enabled. Default false.
TagsNoString[]Tags.

AIModelSecret

FieldRequiredTypeDescription
SecretSourceNoStringSource of the credential. Fixed value: custom.
SecretIdNoStringSecret ID, paired with SecretKey.
SecretKeyNoStringSecret Key, paired with SecretId.
ApiKeyNoStringAPI Key. Mutually exclusive with SecretId/SecretKey.

3. Return Value

FieldTypeDescription
CountNumberNumber of groups created.
RequestIdStringRequest identifier.

4. Example

const res = await app.aiModel.createAIModel({
groupName: 'custom-deepseek',
baseUrl: 'https://api.deepseek.com/v1',
models: [
{ Model: 'deepseek-chat', EnableMCP: false }
],
remark: 'DeepSeek custom group',
status: 1,
secret: {
SecretSource: 'custom',
ApiKey: 'sk-xxxxxxxxxxxxxxxx'
}
})

console.log(res.Count, res.RequestId)

updateAIModel

1. API Description

API feature: Updates an existing AI model configuration group.

API declaration: app.aiModel.updateAIModel(options): Promise<UpdateAIModelResp>

Note

The models field uses full-replacement semantics. Pass in all the models you want to keep, including the unchanged ones.

2. Input Parameters

FieldRequiredTypeDescription
groupNameRequiredStringName of the group to update.
baseUrlNoStringModel service URL.
modelsNoAIModel[]Model list, fully replaced.
remarkNoStringRemark.
statusNo1 | 2Model status. 1 = enabled, 2 = disabled.
secretNoAIModelSecretModel credentials.
envIdNoStringEnvironment ID. Falls back to the current environment if omitted.

AIModel / AIModelSecret are the same as in createAIModel.

3. Return Value

FieldTypeDescription
CountNumberNumber of groups updated.
RequestIdStringRequest identifier.

4. Example

const res = await app.aiModel.updateAIModel({
groupName: 'custom-deepseek',
models: [
{ Model: 'deepseek-chat', EnableMCP: true },
{ Model: 'deepseek-reasoner', EnableMCP: true }
],
status: 1
})

console.log(res.Count)

deleteAIModel

1. API Description

API feature: Deletes AI model configuration groups in batch.

API declaration: app.aiModel.deleteAIModel(options): Promise<DeleteAIModelResp>

2. Input Parameters

FieldRequiredTypeDescription
groupNamesRequiredString[]List of group names. At least one non-empty item.
envIdNoStringEnvironment ID. Falls back to the current environment if omitted.

3. Return Value

FieldTypeDescription
CountNumberNumber of groups successfully deleted.
RequestIdStringRequest identifier.

4. Example

const res = await app.aiModel.deleteAIModel({
groupNames: ['custom-deepseek', 'custom-hunyuan']
})

console.log(res.Count)

describeAIModels

1. API Description

API feature: Lists AI model groups configured under the current environment, including both builtin and custom groups.

API declaration: app.aiModel.describeAIModels(options?): Promise<DescribeAIModelsResp>

2. Input Parameters

FieldRequiredTypeDescription
envIdNoStringEnvironment ID. Falls back to the current environment if omitted.

3. Return Value

FieldTypeDescription
AIModelsAIModelGroup[] | nullModel group list. May be null.
RequestIdStringRequest identifier.

AIModelGroup

FieldTypeDescription
GroupNameStringGroup name, e.g. hunyuan-exp / deepseek / cloudbase / custom-xxx.
ModelsAIModel[] | nullModel list.
Type'builtin' | 'custom'Group type.
OriginType'builtin' | 'custom'Original group type.
RemarkStringRemark.
BaseUrlStringModel service URL.
Status1 | 2Model status. 1 = enabled, 2 = disabled.
SecretAIModelSecret | nullModel credentials (may be masked or null in response).
CreateTimeStringCreation time, ISO 8601.
UpdateTimeStringLast update time, ISO 8601.

4. Example

const res = await app.aiModel.describeAIModels()

for (const group of res.AIModels || []) {
console.log(group.GroupName, group.Type, group.Status, group.Models?.length)
}

describeManagedAIModelList

1. API Description

API feature: Lists managed AI models supported by the CloudBase platform (billed by CloudBase, no user-provided credentials required).

API declaration: app.aiModel.describeManagedAIModelList(options?): Promise<DescribeManagedAIModelListResp>

2. Input Parameters

FieldRequiredTypeDescription
envIdNoStringEnvironment ID. Falls back to the current environment if omitted.

3. Return Value

FieldTypeDescription
ManagedAIModelListManagedAIModelGroup[] | nullManaged model group list.
RequestIdStringRequest identifier.

ManagedAIModelGroup

FieldTypeDescription
GroupNameStringGroup name, e.g. cloudbase.
ModelsManagedAIModel[] | nullModel list.
RemarkStringRemark.

ManagedAIModel

FieldTypeDescription
ModelStringModel name, e.g. hy3-preview.
EnableMCPBooleanWhether MCP is enabled.
ModelSpecManagedAIModelSpecModel specification (context window, token limits).
ModelChargingInfoManagedAIModelChargingInfo[]Billing info (uniform / tiered).

ManagedAIModelSpec

FieldTypeDescription
MaxInputTokenStringMax input tokens, e.g. 192k.
MaxOutputTokenStringMax output tokens, e.g. 32k.
ContextLengthStringContext window length, e.g. 128k.

ManagedAIModelChargingInfo

FieldTypeDescription
Type'Uniform' | 'Tiered'Charging type: uniform / tiered.
NameStringTier name, e.g. 0-16k.
InputPriceStringInput token price.
OutputPriceStringOutput token price.
CachePriceStringCache-hit price.
InputOutputUnitStringBilling unit, e.g. 1k tokens.

4. Example

const res = await app.aiModel.describeManagedAIModelList()

for (const group of res.ManagedAIModelList || []) {
console.log(group.GroupName, group.Remark)
for (const model of group.Models || []) {
console.log(' -', model.Model, model.ModelSpec?.ContextLength)
}
}