创建一个新的模型导入任务。
前提条件
公共请求头
所有接口均需在 HTTP Header 中携带以下字段:
|
Header |
说明 |
|
Authorization |
|
|
Content-Type |
|
创建导入任务
提交一个模型导入任务。系统将对模型文件进行结构和安全校验,确保文件能够正常部署。
地址
POST https://dashscope.aliyuncs.com/api/v1/custom_models/import
请求示例
curl -X POST "https://dashscope.aliyuncs.com/api/v1/custom_models/import" \
--header "Authorization: Bearer $DASHSCOPE_API_KEY" \
--header "Content-Type: application/json" \
--data '{
"model_name": "qwen3-32b",
"display_name": "我的 LoRA 调优模型",
"source": "oss",
"weight_type": "lora",
"storage_info": {
"bucket_name": "my-model-bucket",
"object_key": "models/qwen3-32b-lora/"
}
}'
请求参数
|
参数 |
类型 |
传参方式 |
必选 |
说明 |
|
model_name |
String |
body |
是 |
基础模型的名称。对应控制台基础模型字段。当前支持的模型请参见支持导入的基础模型。示例: |
|
display_name |
String |
body |
否 |
导入模型的显示名称,对应控制台模型名称字段。最多50个字符。不传时默认使用基础模型名称。 |
|
source |
String |
body |
是 |
导入来源。对应控制台导入来源字段。当前仅支持 |
|
weight_type |
String |
body |
是 |
调优类型。 |
|
storage_info |
Object |
body |
是 |
导入来源的存储信息。 |
|
storage_info.bucket_name |
String |
body |
是 |
OSS Bucket 名称。对应控制台Bucket字段。 |
|
storage_info.object_key |
String |
body |
是 |
模型文件所在 OSS 路径前缀,需以 |
响应示例
{
"request_id": "6c6b****-3fea-****-bc26-c9e2********",
"output": {
"job_id": "937b****-2a4f-****-8abe-c2fa********",
"model_name": "qwen3-32b-offline-20240101-abc1",
"display_name": "我的 LoRA 调优模型",
"source": "OSS",
"weight_type": "lora",
"storage_info": {
"bucket_name": "my-model-bucket",
"object_key": "models/qwen3-32b-lora/"
},
"status": "PENDING",
"gmt_create": "2024-01-01T12:00:00.000+00:00"
}
}
响应参数
|
参数 |
类型 |
说明 |
|
request_id |
String |
请求 ID。 |
|
output.job_id |
String |
|
|
output.model_name |
String |
系统生成的模型标识,格式为基础模型名称加时间戳后缀。 |
|
output.display_name |
String |
导入模型的显示名称。 |
|
output.source |
String |
导入来源,返回值为大写 |
|
output.weight_type |
String |
调优类型。 |
|
output.storage_info |
Object |
导入来源的存储信息,包含 |
|
output.status |
String |
任务状态。参见任务状态说明。 |
|
output.gmt_create |
String |
任务创建时间,ISO 8601 格式。示例: |
异常响应
当请求发生错误时,接口将返回如下格式的错误响应:
{
"request_id": "ca21****-b91b-****-bd35-c41c********",
"code": "OperationDenied",
"message": "The import job is currently running and cannot be deleted."
}
错误码
|
错误码 |
说明 |
|
InvalidParameter |
请求参数无效。例如必填参数缺失、参数格式错误或参数值不合法。 |
|
NotFound |
指定的资源不存在。例如 job_id 不存在、无权访问或基础模型不支持导入。 |
|
OperationDenied |
操作被拒绝。例如对 RUNNING 状态的任务执行删除操作。 |
|
InvalidApiKey |
API-KEY 无效或未提供。 |
|
InternalError |
系统内部错误,请稍后重试。 |