新建我的模型版本
更新时间:2025-06-24
功能介绍
用于新建我的模型版本。
使用说明
本文API支持通过Python SDK、Go SDK、Java SDK 和 Node.js SDK调用,调用流程请参考SDK安装及使用流程。
权限说明
调用本文API,需符合以下权限要求,权限介绍及分配,请查看角色与权限控制列表、账号创建与权限分配。需具有以下任一权限:
- 完全控制千帆大模型平台的权限:QianfanFullControlAccessPolicy
- 完全控制千帆大模型平台模型调优的权限:QianfanModelTuningFullControlAccessPolicy
SDK调用
调用示例
训练侧发布模型
1import os
2from qianfan import resources
3
4# 通过环境变量初始化认证信息
5# 使用安全认证AK/SK调用,替换下列示例中参数,安全认证Access Key替换your_iam_ak,Secret Key替换your_iam_sk,如何获取请查看https://cloud.baidu.com/doc/Reference/s/9jwvz2egb
6os.environ["QIANFAN_ACCESS_KEY"] = "your_access_key"
7os.environ["QIANFAN_SECRET_KEY"] = "your_secret_key"
8
9resp = resources.console.utils.call_action(
10 # 调用本文API,该参数值为固定值,无需修改;对应API调用文档-请求结构-请求地址的后缀
11 "/v2/model",
12 # 调用本文API,该参数值为固定值,无需修改;对应API调用文档-请求参数-Query参数的Action
13 "CreateCustomModel",
14 # 请查看本文请求参数说明,根据实际使用选择参数;对应API调用文档-请求参数-Body参数
15 {
16 "modelSetId": "am-ash****",
17 "sourceType": "Train",
18 "trainMeta": {
19 "taskId": "task-sdvsdfbhjsdfb",
20 "step": 50
21 }
22 }
23)
24print(resp.body)
1package main
2
3import (
4 "context"
5 "fmt"
6 "os"
7
8 "github.com/baidubce/bce-qianfan-sdk/go/qianfan"
9)
10
11func main() {
12 // 使用安全认证AK/SK鉴权,通过环境变量初始化;替换下列示例中参数,安全认证Access Key替换your_iam_ak,Secret Key替换your_iam_sk
13 os.Setenv("QIANFAN_ACCESS_KEY", "your_iam_ak")
14 os.Setenv("QIANFAN_SECRET_KEY", "your_iam_sk")
15
16 ca := qianfan.NewConsoleAction()
17
18 res, err := ca.Call(context.TODO(),
19 // 调用本文API,该参数值为固定值,无需修改;对应API调用文档-请求结构-请求地址的后缀
20 "/v2/model",
21 // 调用本文API,该参数值为固定值,无需修改;对应API调用文档-请求参数-Query参数的Action
22 "CreateCustomModel",
23 // 请查看本文请求参数说明,根据实际使用选择参数;对应API调用文档-请求参数-Body参数
24 map[string]interface{}{
25 "modelSetId": "am-ashdagwfy234",
26 "sourceType": "Train",
27 "trainMeta": map[string]any{
28 "taskId": "task-sdvsdfbhjsdfb",
29 "step": 50,
30 },
31 })
32
33 if err != nil {
34 panic(err)
35 }
36
37 fmt.Println(string(res.Body))
38
39}
1import com.baidubce.qianfan.Qianfan;
2import com.baidubce.qianfan.model.console.ConsoleResponse;
3import com.baidubce.qianfan.util.CollUtils;
4import com.baidubce.qianfan.util.Json;
5import java.util.Map;
6
7public class Dome {
8 public static void main(String args[]){
9 // 使用安全认证AK/SK鉴权,替换下列示例中参数,安全认证Access Key替换your_iam_ak,Secret Key替换your_iam_sk
10 Qianfan qianfan = new Qianfan("your_iam_ak", "your_iam_sk");
11
12 ConsoleResponse<Map<String, Object>> response = qianfan.console()
13 // 调用本文API,该参数值为固定值,无需修改;对应API调用文档-请求结构-请求地址的后缀
14 .route("/v2/model")
15 // 调用本文API,该参数值为固定值,无需修改;对应API调用文档-请求参数-Query参数的Action
16 .action("DescribeServices")
17 // 需要传入参数的场景,可以自行封装请求类,或者使用Map.of()来构建请求Body
18 // Java 8可以使用SDK提供的CollUtils.mapOf()来替代Map.of()
19 // 请查看本文请求参数说明,根据实际使用选择参数;对应API调用文档-请求参数-Body参数
20 .body(CollUtils.mapOf(
21 "modelSetId", "am-ashd****",
22 "sourceType", "Train",
23 "trainMeta", CollUtils.mapOf(
24 "taskId", "task-sdvsdfbhjsdfb",
25 "step", 50
26 )
27 ))
28 .execute();
29
30 System.out.println(Json.serialize(response));
31 }
32}
1import {consoleAction, setEnvVariable} from "@baiducloud/qianfan";
2
3// 使用安全认证AK/SK鉴权,通过环境变量初始化;替换下列示例中参数,安全认证Access Key替换your_iam_ak,Secret Key替换your_iam_sk
4setEnvVariable('QIANFAN_ACCESS_KEY','your_iam_ak');
5setEnvVariable('QIANFAN_SECRET_KEY','your_iam_sk');
6
7async function main() {
8 //base_api_route:调用本文API,该参数值为固定值,无需修改;对应API调用文档-请求结构-请求地址的后缀
9 //action:调用本文API,该参数值为固定值,无需修改;对应API调用文档-请求参数-Query参数的Action
10 //data:请查看本文请求参数说明,根据实际使用选择参数;对应API调用文档-请求参数-Body参数
11 const res = await consoleAction({base_api_route: '/v2/model', action: 'CreateCustomModel', body: {
12 "modelSetId": "am-ash****",
13 "sourceType": "Train",
14 "trainMeta": {
15 "taskId": "task-sdvsdfbhjsdfb",
16 "step": 50
17 }
18 }
19 });
20
21 console.log(res);
22}
23
24main();
导入自定义HF模型
- transformer引擎
1import os
2from qianfan import resources
3
4# 通过环境变量初始化认证信息
5# 使用安全认证AK/SK调用,替换下列示例中参数,安全认证Access Key替换your_iam_ak,Secret Key替换your_iam_sk,如何获取请查看https://cloud.baidu.com/doc/Reference/s/9jwvz2egb
6os.environ["QIANFAN_ACCESS_KEY"] = "your_iam_ak"
7os.environ["QIANFAN_SECRET_KEY"] = "your_iam_sk"
8
9resp = resources.console.utils.call_action(
10 # 调用本文API,该参数值为固定值,无需修改;对应API调用文档-请求结构-请求地址的后缀
11 "/v2/model",
12 # 调用本文API,该参数值为固定值,无需修改;对应API调用文档-请求参数-Query参数的Action
13 "CreateCustomModel",
14 # 请查看本文请求参数说明,根据实际使用选择参数;对应API调用文档-请求参数-Body参数
15 {
16 "modelSetId":"am-ih8****",
17 "sourceType":"Import",
18 "importMeta":{
19 "bucket":"test",
20 "objectPath":"demoModel",
21 "modelFormat":"HuggingFace.Transformers",
22 "modelApplicationType":"chat",
23 "transformerVersion":"4.36.2",
24 "chatConf": {
25 "historyQATemplate": "\\n\\nUser: {question} \\nAssistant: {answer}\\n",
26 "latestQuestionTemplate": "\\n\\nUser: {question} \\nAssistant:",
27 "promptTemplate": "你是一个对话机器人,根据下文输入完成回答\n### 输入:\n{input}\n### 回答: "
28 }
29 }
30 }
31)
32print(resp.body)
1package main
2
3import (
4 "context"
5 "fmt"
6 "os"
7
8 "github.com/baidubce/bce-qianfan-sdk/go/qianfan"
9)
10
11func main() {
12 // 使用安全认证AK/SK鉴权,通过环境变量初始化;替换下列示例中参数,安全认证Access Key替换your_iam_ak,Secret Key替换your_iam_sk
13 os.Setenv("QIANFAN_ACCESS_KEY", "your_iam_ak")
14 os.Setenv("QIANFAN_SECRET_KEY", "your_iam_sk")
15
16 ca := qianfan.NewConsoleAction()
17
18 res, err := ca.Call(context.TODO(),
19 // 调用本文API,该参数值为固定值,无需修改;对应API调用文档-请求结构-请求地址的后缀
20 "/v2/model",
21 // 调用本文API,该参数值为固定值,无需修改;对应API调用文档-请求参数-Query参数的Action
22 "CreateCustomModel",
23 // 请查看本文请求参数说明,根据实际使用选择参数;对应API调用文档-请求参数-Body参数
24 map[string]interface{}{
25 "modelSetId":"am-ih8***",
26 "sourceType":"Import",
27 "importMeta":map[string]any{
28 "bucket":"test",
29 "objectPath":"demoModel",
30 "modelFormat":"HuggingFace.Transformers",
31 "modelApplicationType":"chat",
32 "transformerVersion":"4.36.2",
33 "chatConf": map[string]any{
34 "historyQATemplate": "\\n\\nUser: {question} \\nAssistant: {answer}\\n",
35 "latestQuestionTemplate": "\\n\\nUser: {question} \\nAssistant:",
36 "promptTemplate": "你是一个对话机器人,根据下文输入完成回答\n### 输入:\n{input}\n### 回答: ",
37 },
38 },
39 })
40
41 if err != nil {
42 panic(err)
43 }
44 fmt.Println(string(res.Body))
45
46}
1import com.baidubce.qianfan.Qianfan;
2import com.baidubce.qianfan.model.console.ConsoleResponse;
3import com.baidubce.qianfan.util.CollUtils;
4import com.baidubce.qianfan.util.Json;
5import java.util.Map;
6
7public class Dome {
8 public static void main(String args[]){
9 // 使用安全认证AK/SK鉴权,替换下列示例中参数,安全认证Access Key替换your_iam_ak,Secret Key替换your_iam_sk
10 Qianfan qianfan = new Qianfan("your_iam_ak", "your_iam_sk");
11
12 ConsoleResponse<Map<String, Object>> response = qianfan.console()
13 // 调用本文API,该参数值为固定值,无需修改;对应API调用文档-请求结构-请求地址的后缀
14 .route("/v2/model")
15 // 调用本文API,该参数值为固定值,无需修改;对应API调用文档-请求参数-Query参数的Action
16 .action("CreateCustomModel")
17 // 需要传入参数的场景,可以自行封装请求类,或者使用Map.of()来构建请求Body
18 // Java 8可以使用SDK提供的CollUtils.mapOf()来替代Map.of()
19 // 请查看本文请求参数说明,根据实际使用选择参数;对应API调用文档-请求参数-Body参数
20 .body(CollUtils.mapOf(
21 "modelSetId","am-ih8***",
22 "sourceType","Import",
23 "importMeta",CollUtils.mapOf(
24 "bucket","test",
25 "objectPath","demoModel",
26 "modelFormat","HuggingFace.Transformers",
27 "modelApplicationType","chat",
28 "transformerVersion","4.36.2",
29 "chatConf", CollUtils.mapOf(
30 "historyQATemplate", "\\n\\nUser: {question} \\nAssistant: {answer}\\n",
31 "latestQuestionTemplate", "\\n\\nUser: {question} \\nAssistant:",
32 "promptTemplate", "你是一个对话机器人,根据下文输入完成回答\n### 输入:\n{input}\n### 回答: "
33 )
34 )
35 ))
36 .execute();
37
38 System.out.println(Json.serialize(response));
39 }
40}
1import {consoleAction, setEnvVariable} from "@baiducloud/qianfan";
2
3// 使用安全认证AK/SK鉴权,通过环境变量初始化;替换下列示例中参数,安全认证Access Key替换your_iam_ak,Secret Key替换your_iam_sk
4setEnvVariable('QIANFAN_ACCESS_KEY','your_iam_ak');
5setEnvVariable('QIANFAN_SECRET_KEY','your_iam_sk');
6
7async function main() {
8 //base_api_route:调用本文API,该参数值为固定值,无需修改;对应API调用文档-请求结构-请求地址的后缀
9 //action:调用本文API,该参数值为固定值,无需修改;对应API调用文档-请求参数-Query参数的Action
10 //data:请查看本文请求参数说明,根据实际使用选择参数;对应API调用文档-请求参数-Body参数
11 const res = await consoleAction({base_api_route: '/v2/model', action: 'CreateCustomModel', data: {
12 "modelSetId":"am-ih8****",
13 "sourceType":"Import",
14 "importMeta":{
15 "bucket":"test",
16 "objectPath":"demoModel",
17 "modelFormat":"HuggingFace.Transformers",
18 "modelApplicationType":"chat",
19 "transformerVersion":"4.36.2",
20 "chatConf": {
21 "historyQATemplate": "\\n\\nUser: {question} \\nAssistant: {answer}\\n",
22 "latestQuestionTemplate": "\\n\\nUser: {question} \\nAssistant:",
23 "promptTemplate": "你是一个对话机器人,根据下文输入完成回答\n### 输入:\n{input}\n### 回答: "
24 }
25 }
26 }
27 });
28
29 console.log(res);
30}
31
32main();
- 开启prompt自动拼接
1import os
2from qianfan import resources
3
4# 通过环境变量初始化认证信息
5# 使用安全认证AK/SK调用,替换下列示例中参数,安全认证Access Key替换your_iam_ak,Secret Key替换your_iam_sk,如何获取请查看https://cloud.baidu.com/doc/Reference/s/9jwvz2egb
6os.environ["QIANFAN_ACCESS_KEY"] = "your_iam_ak"
7os.environ["QIANFAN_SECRET_KEY"] = "your_iam_sk"
8
9resp = resources.console.utils.call_action(
10 # 调用本文API,该参数值为固定值,无需修改;对应API调用文档-请求结构-请求地址的后缀
11 "/v2/model",
12 # 调用本文API,该参数值为固定值,无需修改;对应API调用文档-请求参数-Query参数的Action
13 "CreateCustomModel",
14 # 请查看本文请求参数说明,根据实际使用选择参数;对应API调用文档-请求参数-Body参数
15 {
16 "modelSetId":"am-ih8***",
17 "sourceType":"Import",
18 "importMeta":{
19 "bucket":"test",
20 "objectPath":"demoModel",
21 "modelFormat":"HuggingFace.vLLM",
22 "modelApplicationType":"chat",
23 "enablePromptAutoConcat": true,
24 "vLLMVersion":"0.6.3",
25 "advancedSettings": {
26 "samplingStrategy": "multinomialSampling",
27 "numSampling": 1
28 }
29 },
30 "resourceConfig": {
31 "resourceId": "prl-yqec88en7r08"
32 }
33 }
34)
35print(resp.body)
1package main
2
3import (
4 "context"
5 "fmt"
6 "os"
7
8 "github.com/baidubce/bce-qianfan-sdk/go/qianfan"
9)
10
11func main() {
12 // 使用安全认证AK/SK鉴权,通过环境变量初始化;替换下列示例中参数,安全认证Access Key替换your_iam_ak,Secret Key替换your_iam_sk
13 os.Setenv("QIANFAN_ACCESS_KEY", "your_iam_ak")
14 os.Setenv("QIANFAN_SECRET_KEY", "your_iam_sk")
15
16 ca := qianfan.NewConsoleAction()
17
18 res, err := ca.Call(context.TODO(),
19 // 调用本文API,该参数值为固定值,无需修改;对应API调用文档-请求结构-请求地址的后缀
20 "/v2/model",
21 // 调用本文API,该参数值为固定值,无需修改;对应API调用文档-请求参数-Query参数的Action
22 "CreateCustomModel",
23 // 请查看本文请求参数说明,根据实际使用选择参数;对应API调用文档-请求参数-Body参数
24 map[string]interface{}{
25 "modelSetId":"am-ih8***",
26 "sourceType":"Import",
27 "importMeta":map[string]any{
28 "bucket":"test",
29 "objectPath":"demoModel",
30 "modelFormat":"HuggingFace.vLLM",
31 "modelApplicationType":"chat",
32 "enablePromptAutoConcat": true,
33 "vLLMVersion":"0.6.3",
34 "advancedSettings": map[string]any{
35 "samplingStrategy": "multinomialSampling",
36 "numSampling": 1,
37 },
38 },
39 "resourceConfig": map[string]any{
40 "resourceId": "prl-yqec88en7r08",
41 },
42 })
43
44 if err != nil {
45 panic(err)
46 }
47 fmt.Println(string(res.Body))
48
49}
1import com.baidubce.qianfan.Qianfan;
2import com.baidubce.qianfan.model.console.ConsoleResponse;
3import com.baidubce.qianfan.util.CollUtils;
4import com.baidubce.qianfan.util.Json;
5import java.util.Map;
6
7public class Dome {
8 public static void main(String args[]){
9 // 使用安全认证AK/SK鉴权,替换下列示例中参数,安全认证Access Key替换your_iam_ak,Secret Key替换your_iam_sk
10 Qianfan qianfan = new Qianfan("your_iam_ak", "your_iam_sk");
11
12 ConsoleResponse<Map<String, Object>> response = qianfan.console()
13 // 调用本文API,该参数值为固定值,无需修改;对应API调用文档-请求结构-请求地址的后缀
14 .route("/v2/model")
15 // 调用本文API,该参数值为固定值,无需修改;对应API调用文档-请求参数-Query参数的Action
16 .action("CreateCustomModel")
17 // 需要传入参数的场景,可以自行封装请求类,或者使用Map.of()来构建请求Body
18 // Java 8可以使用SDK提供的CollUtils.mapOf()来替代Map.of()
19 // 请查看本文请求参数说明,根据实际使用选择参数;对应API调用文档-请求参数-Body参数
20 .body(CollUtils.mapOf(
21 "modelSetId","am-ih8***",
22 "sourceType","Import",
23 "importMeta",CollUtils.mapOf(
24 "bucket","test",
25 "objectPath","demoModel",
26 "modelFormat","HuggingFace.vLLM",
27 "modelApplicationType","chat",
28 "enablePromptAutoConcat", true,
29 "vLLMVersion","0.6.3",
30 "advancedSettings", CollUtils.mapOf(
31 "samplingStrategy", "multinomialSampling",
32 "numSampling", 1
33 )
34 ),
35 "resourceConfig", CollUtils.mapOf(
36 "resourceId", "prl-yqec88en7r08"
37 )
38 ))
39 .execute();
40
41 System.out.println(Json.serialize(response));
42 }
43}
1import {consoleAction, setEnvVariable} from "@baiducloud/qianfan";
2
3// 使用安全认证AK/SK鉴权,通过环境变量初始化;替换下列示例中参数,安全认证Access Key替换your_iam_ak,Secret Key替换your_iam_sk
4setEnvVariable('QIANFAN_ACCESS_KEY','your_iam_ak');
5setEnvVariable('QIANFAN_SECRET_KEY','your_iam_sk');
6
7async function main() {
8 //base_api_route:调用本文API,该参数值为固定值,无需修改;对应API调用文档-请求结构-请求地址的后缀
9 //action:调用本文API,该参数值为固定值,无需修改;对应API调用文档-请求参数-Query参数的Action
10 //data:请查看本文请求参数说明,根据实际使用选择参数;对应API调用文档-请求参数-Body参数
11 const res = await consoleAction({base_api_route: '/v2/model', action: 'CreateCustomModel', data: {
12 "modelSetId":"am-ih8***",
13 "sourceType":"Import",
14 "importMeta":{
15 "bucket":"test",
16 "objectPath":"demoModel",
17 "modelFormat":"HuggingFace.vLLM",
18 "modelApplicationType":"chat",
19 "enablePromptAutoConcat": true,
20 "vLLMVersion":"0.6.3",
21 "advancedSettings": {
22 "samplingStrategy": "multinomialSampling",
23 "numSampling": 1
24 }
25 },
26 "resourceConfig": {
27 "resourceId": "prl-yqec88en7r08"
28 }
29 }
30 });
31
32 console.log(res);
33}
34
35main();
导入属于深度推理模型的模型版本
1import os
2from qianfan import resources
3
4# 通过环境变量初始化认证信息
5# 使用安全认证AK/SK调用,替换下列示例中参数,安全认证Access Key替换your_iam_ak,Secret Key替换your_iam_sk,如何获取请查看https://cloud.baidu.com/doc/Reference/s/9jwvz2egb
6os.environ["QIANFAN_ACCESS_KEY"] = "your_access_key"
7os.environ["QIANFAN_SECRET_KEY"] = "your_secret_key"
8
9resp = resources.console.utils.call_action(
10 # 调用本文API,该参数值为固定值,无需修改;对应API调用文档-请求结构-请求地址的后缀
11 "/v2/model",
12 # 调用本文API,该参数值为固定值,无需修改;对应API调用文档-请求参数-Query参数的Action
13 "CreateCustomModel",
14 # 请查看本文请求参数说明,根据实际使用选择参数;对应API调用文档-请求参数-Body参数
15 {
16 "modelSetId": "am-ash****",
17 "sourceType": "Import",
18 "importMeta": {
19 "bucket":"test",
20 "objectPath":"xxxx",
21 "modelFormat": "HuggingFace.vLLM",
22 "basicModelName":"DeepSeek-R1-Distill-Qwen-32B",
23 "modelApplicationType":"chat",
24 "vLLMVersion":"0.6.3"
25 }
26 }
27)
28print(resp.body)
1package main
2
3import (
4 "context"
5 "fmt"
6 "os"
7
8 "github.com/baidubce/bce-qianfan-sdk/go/qianfan"
9)
10
11func main() {
12 // 使用安全认证AK/SK鉴权,通过环境变量初始化;替换下列示例中参数,安全认证Access Key替换your_iam_ak,Secret Key替换your_iam_sk
13 os.Setenv("QIANFAN_ACCESS_KEY", "your_iam_ak")
14 os.Setenv("QIANFAN_SECRET_KEY", "your_iam_sk")
15
16 ca := qianfan.NewConsoleAction()
17
18 res, err := ca.Call(context.TODO(),
19 // 调用本文API,该参数值为固定值,无需修改;对应API调用文档-请求结构-请求地址的后缀
20 "/v2/model",
21 // 调用本文API,该参数值为固定值,无需修改;对应API调用文档-请求参数-Query参数的Action
22 "CreateCustomModel",
23 // 请查看本文请求参数说明,根据实际使用选择参数;对应API调用文档-请求参数-Body参数
24 map[string]interface{}{
25 "modelSetId": "am-ashdagwfy234",
26 "sourceType": "Import",
27 "importMeta": map[string]any{
28 "bucket":"test",
29 "objectPath":"xxxx",
30 "modelFormat": "HuggingFace.vLLM",
31 "basicModelName":"DeepSeek-R1-Distill-Qwen-32B",
32 "modelApplicationType":"chat",
33 "vLLMVersion":"0.6.3",
34 },
35 })
36
37 if err != nil {
38 panic(err)
39 }
40
41 fmt.Println(string(res.Body))
42
43}
1import com.baidubce.qianfan.Qianfan;
2import com.baidubce.qianfan.model.console.ConsoleResponse;
3import com.baidubce.qianfan.util.CollUtils;
4import com.baidubce.qianfan.util.Json;
5import java.util.Map;
6
7public class Dome {
8 public static void main(String args[]){
9 // 使用安全认证AK/SK鉴权,替换下列示例中参数,安全认证Access Key替换your_iam_ak,Secret Key替换your_iam_sk
10 Qianfan qianfan = new Qianfan("your_iam_ak", "your_iam_sk");
11
12 ConsoleResponse<Map<String, Object>> response = qianfan.console()
13 // 调用本文API,该参数值为固定值,无需修改;对应API调用文档-请求结构-请求地址的后缀
14 .route("/v2/model")
15 // 调用本文API,该参数值为固定值,无需修改;对应API调用文档-请求参数-Query参数的Action
16 .action("DescribeServices")
17 // 需要传入参数的场景,可以自行封装请求类,或者使用Map.of()来构建请求Body
18 // Java 8可以使用SDK提供的CollUtils.mapOf()来替代Map.of()
19 // 请查看本文请求参数说明,根据实际使用选择参数;对应API调用文档-请求参数-Body参数
20 .body(CollUtils.mapOf(
21 "modelSetId", "am-ashd****",
22 "sourceType", "Import",
23 "importMeta", CollUtils.mapOf(
24 "bucket","test",
25 "objectPath","xxxx",
26 "modelFormat", "HuggingFace.vLLM",
27 "basicModelName","DeepSeek-R1-Distill-Qwen-32B",
28 "modelApplicationType","chat",
29 "vLLMVersion","0.6.3"
30 )
31 ))
32 .execute();
33
34 System.out.println(Json.serialize(response));
35 }
36}
1import {consoleAction, setEnvVariable} from "@baiducloud/qianfan";
2
3// 使用安全认证AK/SK鉴权,通过环境变量初始化;替换下列示例中参数,安全认证Access Key替换your_iam_ak,Secret Key替换your_iam_sk
4setEnvVariable('QIANFAN_ACCESS_KEY','your_iam_ak');
5setEnvVariable('QIANFAN_SECRET_KEY','your_iam_sk');
6
7async function main() {
8 //base_api_route:调用本文API,该参数值为固定值,无需修改;对应API调用文档-请求结构-请求地址的后缀
9 //action:调用本文API,该参数值为固定值,无需修改;对应API调用文档-请求参数-Query参数的Action
10 //data:请查看本文请求参数说明,根据实际使用选择参数;对应API调用文档-请求参数-Body参数
11 const res = await consoleAction({base_api_route: '/v2/model', action: 'CreateCustomModel', body: {
12 "modelSetId": "am-ash****",
13 "sourceType": "Import",
14 "importMeta": {
15 "bucket":"test",
16 "objectPath":"xxxx",
17 "modelFormat": "HuggingFace.vLLM",
18 "basicModelName":"DeepSeek-R1-Distill-Qwen-32B",
19 "modelApplicationType":"chat",
20 "vLLMVersion":"0.6.3"
21 }
22 }
23 });
24
25 console.log(res);
26}
27
28main();
返回示例
1{
2 "requestId": "6ba7b810-9dad-11d1-80b4-00c04fd430c8",
3 "result": {
4 "modelSetId": "am-5sxpz4xn25uw",
5 "modelId": "amv-21qxxr97z8fp"
6 }
7}
1{
2 "requestId": "6ba7b810-9dad-11d1-80b4-00c04fd430c8",
3 "result": {
4 "modelSetId": "am-5sxpz4xn25uw",
5 "modelId": "amv-21qxxr97z8fp"
6 }
7}
1{
2 "requestId": "6ba7b810-9dad-11d1-80b4-00c04fd430c8",
3 "result": {
4 "modelSetId": "am-5sxpz4xn25uw",
5 "modelId": "amv-21qxxr97z8fp"
6 }
7}
1{
2 requestId: '6ba7b810-9dad-11d1-80b4-00c04fd430c8',
3 result: {
4 modelSetId: 'am-5sxpz4xn25uw',
5 modelId: 'amv-21qxxr97z8fp'
6 }
7}
请求参数
名称 | 类型 | 必填 | 描述 |
---|---|---|---|
modelSetId | string | 是 | 模型版本归属的模型ID,示例:am-gh0azfeb9adu,说明:通过以下任一方式获取该字段值: · 方式一:调用新建获取我的模型列表接口,返回的modelSetId字段获取 · 方式二:在控制台-我的模型查看,如下图所示 ![]() |
description | string | 否 | 模型版本描述,长度为 [0, 300] |
sourceType | string | 是 | 版本来源,可选值如下: · Train:训练模型发布 · Import:外部导入模型发布 |
trainMeta | object | 否 | 当sourceType=Train时,此字段必填 |
importMeta | object | 否 | 当sourceType=Import时,此字段必填 |
trainMeta说明
名称 | 类型 | 必填 | 描述 |
---|---|---|---|
taskId | string | 是 | 训练任务ID |
checkpointStep | int | 否 | 选择step发布时填写此字段 |
importMeta说明
名称 | 类型 | 必填 | 描述 |
---|---|---|---|
bucket | string | 是 | bucket名称 |
objectPath | string | 是 | object路径 |
modelFormat | string | 是 | 模型格式,可选值如下: · HuggingFace.Transformers:HF导入模型 · Safetensors:文生图模型 |
modelApplicationType | string | 是 | 输入输出模式,可选值如下: · chat:对话模式 · completion:续写模式 · Text-to-Image:文生图模式 |
chatConf | object | 否 | 对话模型平台预置对话模板,说明: (1)该字段仅导入HF模型有效 (2)该字段与customSpec字段不能同时使用,只能选择其中一个 |
customSpec | object | 否 | 对话模型自定义对话模板,说明: (1)该字段仅导入HF模型有效 (2)该字段与chatConf字段不能同时使用,只能选择其中一个 |
advanceConf | string | 否 | 说明: (1)该字段仅导入HF模型有效 (2)该字段值通过调用获取导入模型平台预置高级配置接口,返回的result获取 |
transformerVersion | string | 是 | 说明: (1)该字段仅导入HF模型有效 (2)transformer版本,目前支持4.34.0、4.36.2、4.39.3和4.40.2 |
vLLMVersion | string | 否 | 说明: (1)该字段仅导入HF模型可填 (2)vLLM版本,目前支持0.3.2、0.4.0 |
enablePromptAutoConcat | bool | 否 | 是否开启Prompt自动拼接,说明:该字段仅导入HF模型有效 |
basicModelName | string | 否 | 基础模型版本名称,说明:若名称为其他,该参数值写为HuggingFace |
advancedSettings | object | 是 | 量化压缩配置 |
chatConf说明
名称 | 类型 | 必填 | 描述 |
---|---|---|---|
historyQATemplate | string | 是 | 历史对话模板, 长度限制[1,200] |
latestQuestionTemplate | string | 是 | 最新对话模板, 长度限制[1,200] |
promptTemplate | string | 是 | prompt模板,长度限制[0,300] |
customSpec说明
名称 | 类型 | 必填 | 描述 |
---|---|---|---|
displayName | string | 是 | 自定义配置文件展示名称,长度限制[1,200] |
fileName | string | 是 | 自定义配置平台存储文件名称,该字段值通过调用上传自定义对话模板文件接口,返回result字段获取 |
advancedSettings说明
名称 | 类型 | 必填 | 描述 |
---|---|---|---|
samplingStrategy | string | 是 | 压缩时的采样策略, (1)当导入HF模型,且推理引擎为vLLM时,该字段有效 (2)可选值: · 多项式采样:multinomialSampling · 束搜索:beamSearch · 贪心搜索 greedySearch |
numSampling | int | 否 | 返回序列数量,当导入HF模型可填,采样策略选择multinomialSampling且推理引擎为vLLM时可填,范围为1~15 |
numBeams | int | 是 | 束数量,当导入HF模型,该字段有效,取值范围2-15 |
返回参数
名称 | 类型 | 描述 |
---|---|---|
requestId | string | 请求ID |
result | object | 请求结果 |
result说明
名称 | 类型 | 描述 |
---|---|---|
modelSetId | string | 模型ID |
modelId | string | 模型版本ID |