API请求
URLs
PUT zstack/v1/ai/model-services/{uuid}Headers
Authorization: OAuth the-session-uuidBody
{
"updateModelService": {
"name": "example",
"description": "This is an example description.",
"yaml": "example-yaml-configuration",
"requestCpu": 4,
"requestMemory": 8192,
"gpuComputeCapability": "7.5",
"startCommand": "python start.py",
"pythonVersion": "3.8",
"type": "Endpoint",
"framework": "HuggingFace",
"architectureImages": [
{
"cpuArchitecture": "X86_64",
"vmImageUuid": "1e463a11a89a38429f53f6bc34dbe4b3",
"dockerImage": "registry.example.com/x86_64/myimage:latest"
},
{
"cpuArchitecture": "AARCH64",
"vmImageUuid": "9458c977c7f838afbc6144aed913c947",
"dockerImage": "registry.example.com/aarch64/myimage:latest"
}
]
},
"systemTags": [],
"userTags": []
}说明: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"updateModelService":{"name":"example","description":"This is an example description.","yaml":"example-yaml-configuration","requestCpu":4,"requestMemory":8192,"gpuComputeCapability":"7.5","startCommand":"python start.py","pythonVersion":"3.8","type":"Endpoint","framework":"HuggingFace","architectureImages":[{"cpuArchitecture":"X86_64","vmImageUuid":"1e463a11a89a38429f53f6bc34dbe4b3","dockerImage":"registry.example.com/x86_64/myimage:latest"},{"cpuArchitecture":"AARCH64","vmImageUuid":"9458c977c7f838afbc6144aed913c947","dockerImage":"registry.example.com/aarch64/myimage:latest"}]}}' \
http://localhost:8080/zstack/v1/ai/model-services/a0a4dfd377a13862bb92614482ea2d42参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| uuid | String | url | 资源的UUID,唯一标示该资源 | 5.1.8 | |
| name (可选) | String | body(包含在updateModelService结构中) | 资源名称 | 5.1.8 | |
| description (可选) | String | body(包含在updateModelService结构中) | 资源的详细描述 | 5.1.8 | |
| yaml (可选) | String | body(包含在updateModelService结构中) | 模型服务的yaml配置 | 5.1.8 | |
| requestCpu (可选) | Integer | body(包含在updateModelService结构中) | 需要的CPU数量 | 5.1.8 | |
| requestMemory (可选) | Long | body(包含在updateModelService结构中) | 需要的内存大小 | 5.1.8 | |
| systemTags (可选) | List | body | 系统标签 | 5.1.8 | |
| userTags (可选) | List | body | 用户标签 | 5.1.8 | |
| gpuComputeCapability (可选) | String | body(包含在updateModelService结构中) | 5.1.8 | ||
| startCommand (可选) | String | body(包含在updateModelService结构中) | 5.1.8 | ||
| pythonVersion (可选) | String | body(包含在updateModelService结构中) | 5.1.8 | ||
| type (可选) | String | body(包含在updateModelService结构中) |
|
5.1.8 | |
| framework (可选) | String | body(包含在updateModelService结构中) | 5.1.8 | ||
| source (可选) | String | body(包含在updateModelService结构中) |
|
5.3.28 | |
| architectureImages (可选) | List | body(包含在updateModelService结构中) | 5.3.28 | ||
| supportDistributed (可选) | Boolean | body(包含在updateModelService结构中) | 5.3.52 | ||
| environmentParameters (可选) | HashMap | body(包含在updateModelService结构中) | 5.3.52 | ||
| startupParameters (可选) | HashMap | body(包含在updateModelService结构中) | 5.3.52 | ||
| inferenceParams (可选) | HashMap | body(包含在updateModelService结构中) | 5.3.52 | ||
| serviceName (可选) | String | body(包含在updateModelService结构中) | 5.3.52 | ||
| servicePorts (可选) | List | body(包含在updateModelService结构中) | 5.3.52 | ||
| serviceLivez (可选) | String | body(包含在updateModelService结构中) | 5.3.52 | ||
| serviceReadyz (可选) | String | body(包含在updateModelService结构中) | 5.3.52 | ||
| serviceBootupTime (可选) | Integer | body(包含在updateModelService结构中) | 5.3.52 | ||
| serviceInstallPath (可选) | String | body(包含在updateModelService结构中) | 5.3.52 | ||
| serviceStartCommand (可选) | String | body(包含在updateModelService结构中) | 5.3.52 | ||
| containerCommand (可选) | String | body(包含在updateModelService结构中) | 容器启动命令。 | 5.5.22 | |
| containerArgs (可选) | String | body(包含在updateModelService结构中) | 容器启动参数。 | 5.5.22 | |
| vendorToSpecUuidsMap (可选) | Map | body(包含在updateModelService结构中) | GPU厂商到GPU规格UUID列表的映射。 | 5.5.22 |
API返回
返回示例
{
"inventory": {
"uuid": "6c1a5f6167944aa1886294842075279f",
"name": "example",
"description": "Example description for modelService",
"yaml": "services:\n - ports:\n - 3000\n name: qwen1.5-7b-chat:2b34xhrmqwhomjkd\n livez: /livez\n readyz: /readyz\n serviceBootupTime: 30\nenv:\n - key:value\n - key:value\ndistro:\n packages: vim,nfs-utils\npython:\n requirements_txt: ./requirements.txt\n index_url: https://pypi.tuna.tsinghua.edu.cn/simple\n trusted_host: pypi.tuna.tsinghua.edu.cn\n",
"requestCpu": 1,
"requestMemory": 1024,
"modelCenterUuid": "52c542f0c3384b6890e08570e611d52a",
"type": "Endpoint",
"system": true,
"gpuComputeCapability": "3.7",
"installPath": "/example/install/path",
"pythonVersion": "3.8.10",
"condaVersion": "23.7.4",
"startCommand": "python3 app.py",
"supportDistributed": true,
"modelServiceImages": [
{
"uuid": "d163eac54dba403abe12e77a0fec3dd5",
"modelServiceUuid": "6c1a5f6167944aa1886294842075279f",
"cpuArchitecture": "x86_64",
"vmImageUuid": "aa45d85a91d94342838797626fd4bbfc",
"dockerImage": "registry.example.com/x86_64/myimage:latest",
"createDate": "Nov 25, 2025 11:51:50 AM",
"lastOpDate": "Nov 25, 2025 11:51:50 AM"
},
{
"uuid": "e41c7c9d14934ca0aaea2847c2ed8a5e",
"modelServiceUuid": "6c1a5f6167944aa1886294842075279f",
"cpuArchitecture": "aarch64",
"vmImageUuid": "3ab8e36ed4be4fe6bd91ad1e4f22cffd",
"dockerImage": "registry.example.com/aarch64/myimage:latest",
"createDate": "Nov 25, 2025 11:51:50 AM",
"lastOpDate": "Nov 25, 2025 11:51:50 AM"
}
],
"createDate": "Nov 25, 2025 11:51:50 AM",
"lastOpDate": "Nov 25, 2025 11:51:50 AM"
}
}#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 5.2.1 |
| description | String | 错误的概要描述 | 5.2.1 |
| details | String | 错误的详细信息 | 5.2.1 |
| elaboration | String | 保留字段,默认为null | 5.2.1 |
| opaque | LinkedHashMap | 保留字段,默认为null | 5.2.1 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 5.2.1 |
#inventory
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标识该资源 | 5.1.8 |
| name | String | 资源名称 | 5.1.8 |
| description | String | 资源的详细描述 | 5.1.8 |
| readme | String | README内容 | 5.1.8 |
| yaml | String | 服务YAML配置 | 5.1.8 |
| requestCpu | Integer | 请求CPU数量 | 5.1.8 |
| requestMemory | Long | 请求内存大小 | 5.1.8 |
| modelCenterUuid | String | 模型中心UUID | 5.1.8 |
| type | String | 模型服务类型 | 5.1.8 |
| framework | String | 模型服务框架 | 5.1.8 |
| source | String | 模型服务来源 | 5.1.8 |
| size | Long | 模型服务大小 | 5.1.8 |
| system | Boolean | 是否为系统模型服务 | 5.1.8 |
| hasNewVersion | Boolean | 是否存在新版本 | 5.1.8 |
| gpuComputeCapability | String | GPU算力要求 | 5.1.8 |
| installPath | String | 模型服务安装路径 | 5.1.8 |
| pythonVersion | String | Python版本 | 5.1.8 |
| condaVersion | String | Conda版本 | 5.1.8 |
| version | String | 模型服务版本 | 5.1.8 |
| startCommand | String | 启动命令 | 5.1.8 |
| containerCommand | String | 容器启动命令 | 5.1.8 |
| containerArgs | String | 容器启动参数 | 5.1.8 |
| supportDistributed | Boolean | 是否支持分布式部署 | 5.1.8 |
| cpuArchitectures | List | 支持的CPU架构 | 5.1.8 |
| vendorToSpecUuidsMap | Map | GPU厂商与规格UUID映射 | 5.1.8 |
| modelServiceRefs | List | 模型与模型服务的绑定关系 | 5.1.8 |
| modelServiceImages | List | 模型服务镜像列表 | 5.1.8 |
| createDate | Timestamp | 创建时间 | 5.1.8 |
| lastOpDate | Timestamp | 最后一次修改时间 | 5.1.8 |
SDK示例
Java
SDK
UpdateModelServiceAction action = new UpdateModelServiceAction();
action.uuid = "a0a4dfd377a13862bb92614482ea2d42";
action.name = "example";
action.description = "This is an example description.";
action.yaml = "example-yaml-configuration";
action.requestCpu = 4;
action.requestMemory = 8192;
action.gpuComputeCapability = "7.5";
action.startCommand = "python start.py";
action.pythonVersion = "3.8";
action.type = "Endpoint";
action.framework = "HuggingFace";
action.architectureImages = asList([cpuArchitecture:X86_64, vmImageUuid:1e463a11a89a38429f53f6bc34dbe4b3, dockerImage:registry.example.com/x86_64/myimage:latest],[cpuArchitecture:AARCH64, vmImageUuid:9458c977c7f838afbc6144aed913c947, dockerImage:registry.example.com/aarch64/myimage:latest]);
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
UpdateModelServiceAction.Result res = action.call();Python SDK
UpdateModelServiceAction action = UpdateModelServiceAction()
action.uuid = "a0a4dfd377a13862bb92614482ea2d42"
action.name = "example"
action.description = "This is an example description."
action.yaml = "example-yaml-configuration"
action.requestCpu = 4
action.requestMemory = 8192
action.gpuComputeCapability = "7.5"
action.startCommand = "python start.py"
action.pythonVersion = "3.8"
action.type = "Endpoint"
action.framework = "HuggingFace"
action.architectureImages = [[cpuArchitecture:X86_64, vmImageUuid:1e463a11a89a38429f53f6bc34dbe4b3, dockerImage:registry.example.com/x86_64/myimage:latest], [cpuArchitecture:AARCH64, vmImageUuid:9458c977c7f838afbc6144aed913c947, dockerImage:registry.example.com/aarch64/myimage:latest]]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
UpdateModelServiceAction.Result res = action.call()