创建多角色服务
更新时间:2026-10-21
接口描述
创建多角色服务(服务组),即由 prefill 和 decode 两个角色组成的 PD 分离推理服务,并由 LLM 调度器对外提供统一访问入口。
仅支持 serverless(全托管)资源池。 prefill 和 decode 使用的队列必须在同一个资源池里。 创建是异步的:接口返回只表示请求已受理,部署是否成功要通过「查询详情」或控制台查看各角色状态。
请求结构
Plain Text
1POST /?action=CreateGroupService
2HTTP/1.1
3Host: aihc.bj.baidubce.com
4Authorization:authorization string
5version: v2
6{
7 "groupName": "string",
8 "aiGateway": { ... },
9 "roles": [ { ... }, { ... } ],
10 "llmScheduler": { ... }
11}
请求头域
除公共头域外,无其它特殊头域。
请求参数
| 参数名称 | 参数类型 | 是否必须 | 参数位置 | 参数说明 |
|---|---|---|---|---|
| clientToken | String | 否 | query | 保证请求幂等性。相同 clientToken 的重复请求不会重复创建,直接返回已创建的 serviceGroupId |
| groupName | String | 是 | body | 服务组名称。只能由小写字母、数字和 - 组成,以小写字母开头,以小写字母或数字结尾,长度不超过 32 个字符;同一账号、同一地域下不能重名 |
| aiGateway | AiGatewayConf | 是 | body | AI 网关配置 |
| roles | Array of ServiceConf | 是 | body | 角色列表。必须是 prefill 和 decode 两个角色 |
| llmScheduler | LlmSchedulerConf | 是 | body | LLM 调度器配置。 |
返回头域
除公共头域,无其它特殊头域。
返回参数
| 参数名称 | 类型 | 说明 |
|---|---|---|
| requestId | String | 唯一标识请求,用于日志排查 |
| serviceGroupId | String | 服务组 ID,后续查询、删除、鉴权开关都用它 |
请求示例
下面的示例中,只有每个角色的 resourcePool.queueName 需要填资源信息。
Plain Text
1POST /?action=CreateGroupService&clientToken=3f2b6c1e-0d6a-4d7a-9a52-1c1a6a0f6e21 HTTP/1.1
2Host:aihc.bj.baidubce.com
3Authorization:authorization string
4version: v2
5
6{
7 "groupName": "qwen3-32b-pd",
8 "aiGateway": {
9 "aigwId": "aigw-xxxxxxxx",
10 "enableAuth": true,
11 "strategy": "round-robin",
12 "protocol": "http"
13 },
14 "roles": [
15 {
16 "roleName": "prefill",
17 "instanceCount": 1,
18 "acceleratorType": "baidu.com/a800_80g_cgpu",
19 "resourcePool": { "queueName": "aihcq-xxxxxxxxxxxx" },
20 "storage": {
21 "shmSize": 32,
22 "volumns": [
23 { "volumeType": "bos", "volumnName": "vn-model", "bos": { "sourcePath": "<bucket>/<模型路径>" } }
24 ]
25 },
26 "containers": [
27 {
28 "name": "custom-container",
29 "cpus": 16,
30 "memory": 128,
31 "acceleratorCount": 1,
32 "command": ["/bin/sh", "-c", "<prefill 的启动命令>"],
33 "ports": [{ "name": "HTTP", "port": 8000 }],
34 "image": { "imageType": 1, "imageUrl": "<镜像地址>" },
35 "volumeMounts": [{ "volumnName": "vn-model", "mountPath": "/mnt/model" }],
36 "readinessProbe": {
37 "initialDelaySeconds": 15, "timeoutSeconds": 15, "periodSeconds": 15,
38 "successThreshold": 1, "failureThreshold": 3,
39 "handler": { "httpGet": { "path": "/health", "port": 8000 } }
40 }
41 }
42 ],
43 "misc": { "enableRDMA": true }
44 },
45 {
46 "roleName": "decode",
47 "instanceCount": 1,
48 "acceleratorType": "baidu.com/a800_80g_cgpu",
49 "resourcePool": { "queueName": "aihcq-xxxxxxxxxxxx" },
50 "...": "decode 角色的其余配置与 prefill 类似,端口必须与 prefill 一致"
51 }
52 ],
53 "llmScheduler": {
54 "enable": true,
55 "resourceSpec": { "cpus": 2, "memory": 8 },
56 "replicas": 1,
57 "inferEngine": "sglang",
58 "policy": "pd_split",
59 "pdPolicy": { "prefillPolicy": "prefix_aware", "decodePolicy": "random" }
60 }
61}
返回示例
Plain Text
1HTTP/1.1 200 OK
2
3{
4 "requestId": "0ca81095-4446-423f-976e-ca38d99e682c",
5 "serviceGroupId": "g-xxxxxxxxxxxx"
6}
评价此篇文章
