更新时间:2025-08-19 GMT+08:00

查询服务详情

功能介绍

查询模型服务详情,根据服务ID查询服务详情。

调试

您可以在API Explorer中调试该接口,支持自动认证鉴权。API Explorer可以自动生成SDK代码示例,并提供SDK代码示例调试功能。

URI

GET /v1/{project_id}/services/{service_id}

表1 路径参数

参数

是否必选

参数类型

描述

project_id

String

用户项目ID。获取方法请参见获取项目ID和名称

service_id

String

服务ID,在创建服务时即可在返回体中获取,也可通过查询服务列表接口获取当前用户拥有的服务,其中service_id字段即为服务ID。

请求参数

表2 请求Header参数

参数

是否必选

参数类型

描述

X-Auth-Token

String

用户Token。通过调用IAM服务获取用户Token接口获取(响应消息头中X-Subject-Token的值)。

响应参数

状态码:200

表3 响应Body参数

参数

参数类型

描述

service_id

String

服务ID。

service_name

String

服务名称。

description

String

服务描述。

tenant

String

服务归属租户。

project

String

服务归属项目。

owner

String

服务归属用户。

publish_at

Number

服务最新的发布时间,距“1970.1.1 0:0:0 UTC”的毫秒数。

infer_type

String

推理方式,取值包含:

  • real-time:在线服务

  • batch:批量服务

  • edge: 边缘服务

workspace_id

String

工作空间ID。

cluster_id

String

在线/批量服务使用的专属资源池ID或边缘服务使用的边缘资源池ID,仅当配置专属资源池或边缘资源池时返回。

vpc_id

String

在线服务实例所在的虚拟私有云ID,服务自定义网络配置时返回。

subnet_network_id

String

在线服务实例所在的子网的网络ID,服务自定义网络配置时返回。

security_group_id

String

在线服务实例所在的安全组,服务自定义网络配置时返回。

status

String

服务状态,取值包含:

  • running:运行中,服务正常运行。

  • deploying:部署中,服务正在部署,包含打镜像和调度资源部署。

  • concerning:告警,后端实例部分存在异常。

  • failed:失败,服务部署失败,失败原因可以看事件和日志标签页。

  • stopped:停止。

  • finished:只有批量服务会有这个状态,表示运行完成。

  • stopping: 停止中。

  • deleting: 删除中。

  • pending: 待启动,仅在线有这个状态。

  • waiting: 资源排队中,仅在线服务有这个状态。

progress

Integer

部署进度,当状态是deploying时返回。

error_msg

String

错误信息,当status为failed时,返回这个信息注明失败原因。

config

Array of QueryServiceConfig objects

服务配置(如果是共享过来的服务,只返回model_id ,model_name, model_version)。

access_address

String

推理请求的访问地址,仅当infer_type为real-time,且服务部署完成后才会确保该字段有值。

bind_access_address

String

自定义域名的推理请求地址,绑定域名后会返回此值。

invocation_times

Number

服务的总调用次数。

failed_times

Number

服务调用失败次数。

is_shared

Boolean

是否是订阅的服务。

shared_count

Number

订阅的服务数。

schedule

Array of Schedule objects

服务调度配置,未配置则不返回。

update_time

Number

服务当前运行所用配置的更新时间,距“1970.1.1 0:0:0 UTC”的毫秒数。

debug_url

String

在线服务在线调试地址,只有当模型支持在线调试且只有一个实例的时候会存在。

due_time

Number

在线服务自动停止时间,距“1970.1.1 0:0:0 UTC”的毫秒数,未配置自动停止则不返回。

operation_time

Number

当前请求的操作时间。

transition_at

Number

服务状态转化时间。

is_free

Boolean

服务是否是免费规格类型。

additional_properties

Map<String,String>

服务附加属性。

pool_name

String

在线/批量服务使用的AI专属资源池弹性集群的资源池ID,仅当配置专属资源池时返回。

load_balancer_policy

String

在线同步服务设置elb后端转发策略详情枚举值:ROUND_ROBIN(加权轮询算法),LEAST_CONNECTIONS(加权最少连接),SOURCE_IP(源ip算法)

priority

Integer

抢占优先级,取值范围[1, 3],通过设置优先级保障高优先级的业务调度。

表4 QueryServiceConfig

参数

参数类型

描述

model_version

String

模型版本。

finished_time

Number

任务完成时间,距“1970.1.1 0:0:0 UTC”的毫秒数;任务未结束时不返回。

custom_spec

CustomSpec object

自定义资源规格配置,仅当specification配置为custom时返回。

envs

Map<String,String>

运行模型需要的环境变量键值对。

specification

String

资源规格,例如:modelarts.vm.cpu.2u/modelarts.vm.gpu.pnt004/modelarts.vm.ai1.snt3等。特别的,当取值为custom时,代表使用自定义规格,与custom_spec字段配套。

weight

Integer

权重,分配到此模型的流量权重。

source_type

String

模型来源,当模型是由自动学习产生时返回此字段,取值为auto。

model_id

String

模型ID。

src_path

String

批量任务输入数据的OBS路径,例如:“https://xxx.obs.myhwclouds.com/image/”。

req_uri

String

批量任务中调用的推理路径,例如:“/”。

mapping_type

String

输入数据的映射类型,取值为file或csv。

start_time

Number

任务启动时间,距“1970.1.1 0:0:0 UTC”的毫秒数;任务未开始时不返回。

cluster_id

String

服务实例使用的专属资源池或边缘资源池ID,仅当配置专属资源池或边缘资源池时返回。

nodes

Array of Nodes objects

边缘节点信息,仅当配置ModelArts边缘节点时返回。

mapping_rule

Object

输入参数与csv数据的映射关系,仅当mapping_type为csv时会返回。

model_name

String

模型名称。

src_type

String

数据来源类型,仅当指定为ManifestFile时返回。

dest_path

String

批量任务输出结果的OBS路径。例如:“https://xxx.obs.myhwclouds.com/res/”。

instance_count

Integer

模型部署的实例数。

status

String

服务状态,取值包含:

  • running:运行中,服务正常运行。

  • deploying:部署中,服务正在部署,包含打镜像和调度资源部署。

  • concerning:告警,后端实例部分存在异常。

  • failed:失败,服务部署失败,失败原因可以看事件和日志标签页。

  • stopped:停止。

  • finished:只有批量服务会有这个状态,表示运行完成。

scaling

Boolean

是否启用弹性伸缩。

support_debug

Boolean

模型是否支持在线调试。

additional_properties

Map<String,ModelAdditionalProperties>

模型部署附加属性。

pool_name

String

服务实例使用的AI专属资源池弹性集群的资源池ID,仅当配置专属资源池时返回。

affinity

ServiceAffinity object

服务亲和信息

specification_details

ServiceSpecificationDetails object

规格详细信息

表5 CustomSpec

参数

参数类型

描述

gpu_p4

Float

GPU个数,可选,默认不使用,支持配置小数,输入值不能小于0(最多支持2位小数,小数点后第3位做四舍五入处理)。

memory

Integer

内存,单位为MB,仅支持整数。

cpu

Float

CPU核数,支持配置小数,输入值不能小于0.01(最多支持2位小数,小数点后第3位做四舍五入处理)。

ascend_a310

Integer

Ascend芯片个数,可选,默认不使用,不支持与gpu同时配置。

表6 Nodes

参数

参数类型

描述

memory

Integer

内存数(MB)。

os_version

String

节点操作系统版本。

cpu

Integer

CPU核心数。

created_at

String

创建时间,格式为YYYY-MM-DDThh:mm:ss,UTC时间。

description

String

节点描述信息。

message

String

当instance_status为failed或者是notReady时的解释原因。

predict_url

String

在该节点的预测URL。

enable_gpu

Boolean

是否开启GPU。

gpu_num

Integer

gpu个数。

host_ips

Array of strings

节点主机IP。

updated_at

String

更新时间,格式为YYYY-MM-DDThh:mm:ss,UTC时间。

node_label

String

节点标签。

os_type

String

节点操作系统类型。

name

String

边缘节点名称。

os_name

String

节点操作系统名称。

arch

String

节点架构。

id

String

边缘节点ID。

instance_status

String

模型实例在该节点的运行状态,取值为:

  • running:运行中。

  • stopped:已停止。

  • notReady:未就绪。

  • failed:运行失败。

state

String

主机状态,取值为RUNNING/FAIL/UNCONNECTED,表示运行中/故障/未连接。

deployment_num

Integer

部署在该节点上的应用实例个数。

host_name

String

节点主机名。

表7 ModelAdditionalProperties

参数

参数类型

描述

log_volume

Array of LogVolume objects

主机日志目录挂载。

仅支持使用专属资源池部署服务场景。如果用户使用公共资源池部署服务,则不支持配置该参数,否则会报错。

max_surge

Float

必须大于0,不配置默认值为1。当小于1时,代表滚动升级时增加的实例数的百分比;当大于1时,代表滚动升级时最大扩容的实例数。

max_unavailable

Float

必须大于0,不配置默认值为0。当小于1时,代表滚动升级时允许缩容的实例数的百分比;当大于1时,代表滚动升级时允许缩容的实例数。

termination_grace_period_seconds

Integer

容器优雅停止时间。

persistent_volumes

Array of PersistentVolumes objects

持久化存储挂载配置。

dew_secret

DewSecret object

DEW凭据

表8 LogVolume

参数

参数类型

描述

host_path

String

主机上要映射的日志路径。

mount_path

String

容器中的日志路径。

表9 PersistentVolumes

参数

参数类型

描述

name

String

存储卷的名称。

mount_path

String

存储卷在容器中的挂载路径。如:/tmp。请不要挂载在系统目录下,如“/”、“/var/run”等,会导致容器异常。建议挂载在空目录下,若目录不为空,请确保目录下无影响容器启动的文件,否则文件会被替换,导致容器启动异常,工作负载创建失败。

storage_type

String

挂载类型sfs_turbo极速文件系统挂载。

source_address

String

挂载源路径,挂载为极速文件时为sfs turbo id。

表10 DewSecret

参数

参数类型

描述

secret_name

String

DEW凭据名称

表11 ServiceAffinity

参数

参数类型

描述

node_affinity

NodeAffinity object

节点亲和的时候填入该字段

表12 NodeAffinity

参数

参数类型

描述

mode

String

节点亲和的方式,required表示强亲和,服务实例只能调度到指定节点,指定节点不存在则失败。preferred表示弱亲和,服务实例倾向于调度到指定节点,指定节点不满足调度条件,则会调度到其他节点。

pool_infos

Array of AffinityPoolInfo objects

配置亲和策略到指定的集群,并指定集群的节点。

表13 AffinityPoolInfo

参数

参数类型

描述

pool_name

String

集群名称,集群名称必须在外层pool_name中

nodes

Array of AffinityNodeInfo objects

亲和的节点列表信息

表14 AffinityNodeInfo

参数

参数类型

描述

name

String

节点名称,实际上对应的是节点的私有ip

表15 ServiceSpecificationDetails

参数

参数类型

描述

display_en

String

规格的英文展示名。

display_cn

String

规格的中文展示名。

category

String

规格的分类,包含CPU(即不含加速卡)、GPU(加速卡类型为GPU)、NPU(加速卡类型为NPU)。

cpu_info

CpuDisplayInfo object

CPU的详细展示信息。

memory_info

MemoryDisplayInfo object

内存的详细展示信息。

gpu_info

GpuDisplayInfo object

GPU的详细展示信息。

npu_info

NpuDisplayInfo object

NPU的详细展示信息。

表16 CpuDisplayInfo

参数

参数类型

描述

cpu

Double

CPU核数。

arch

String

CPU的架构,包含x86和arm。

表17 MemoryDisplayInfo

参数

参数类型

描述

memory

Integer

内存容量。

unit

String

内存容量的单位,例如MB、GB。

表18 GpuDisplayInfo

参数

参数类型

描述

gpu

Double

GPU卡数。

brand

String

GPU的品牌。

version

String

GPU的型号。

memory

Integer

GPU显存容量。

unit

String

GPU显存容量的单位,例如MB、GB。

表19 NpuDisplayInfo

参数

参数类型

描述

npu

Integer

NPU卡数。

brand

String

NPU的品牌。

version

String

NPU的型号。

memory

Integer

NPU显存容量。

unit

String

NPU显存容量的单位,例如MB、GB。

表20 Schedule

参数

参数类型

描述

duration

Integer

对应时间单位的数值,比如2小时后停止,则time_unit填HOURS,duration填2。

time_unit

String

调度时间单位,可选DAYS/HOURS/MINUTES。

type

String

调度类型,当前仅支持取值为stop,即运行指定时间后自动停止。

请求示例

GET https://{endpoint}/v1/{project_id}/services/{service_id}

响应示例

状态码:200

服务详情

{
  "service_id" : "f76f20ba-78f5-44e8-893a-37c8c600c02f",
  "service_name" : "service-demo",
  "tenant" : "xxxxx",
  "project" : "xxxxx",
  "owner" : "xxxxx",
  "publish_at" : 1585809231902,
  "update_time" : 1585809358259,
  "infer_type" : "real-time",
  "status" : "running",
  "progress" : 100,
  "access_address" : "https://xxxxx.apigw.xxxxx.com/v1/infers/088458d9-5755-4110-97d8-1d21065ea10b/f76f20ba-78f5-44e8-893a-37c8c600c02f",
  "cluster_id" : "088458d9-5755-4110-97d8-1d21065ea10b",
  "workspace_id" : "0",
  "additional_properties" : { },
  "is_shared" : false,
  "invocation_times" : 0,
  "failed_times" : 0,
  "shared_count" : 0,
  "operation_time" : 1586249085447,
  "config" : [ {
    "model_id" : "044ebf3d-8bf4-48df-bf40-bad0e664c1e2",
    "model_name" : "jar-model",
    "model_version" : "1.0.1",
    "specification" : "custom",
    "custom_spec" : { },
    "status" : "notReady",
    "weight" : 100,
    "instance_count" : 1,
    "scaling" : false,
    "envs" : { },
    "additional_properties" : { },
    "support_debug" : false
  } ],
  "transition_at" : 1585809231902,
  "is_free" : false
}

状态码

状态码

描述

200

服务详情

错误码

请参见错误码