AI开发平台MODELARTS-部署服务:请求示例

时间:2024-04-30 18:34:11

请求示例

  • 请求示例,创建在线服务。

    POST https://{endpoint}/v1/{project_id}/services
    
    {
      "infer_type" : "real-time",
      "service_name" : "mnist",
      "description" : "mnist service",
      "config" : [ {
        "specification" : "modelarts.vm.cpu.2u",
        "weight" : 100,
        "model_id" : "0e07b41b-173e-42db-8c16-8e1b44cc0d44",
        "instance_count" : 1
      } ]
    }
  • 请求示例,创建在线服务且配置多版本分流

    POST https://{endpoint}/v1/{project_id}/services
    
    {
      "service_name" : "mnist",
      "description" : "mnist service",
      "infer_type" : "real-time",
      "config" : [ {
        "model_id" : "xxxmodel-idxxx",
        "weight" : "70",
        "specification" : "modelarts.vm.cpu.2u",
        "instance_count" : 1,
        "envs" : {
          "model_name" : "mxnet-model-1",
          "load_epoch" : "0"
        }
      }, {
        "model_id" : "xxxxxx",
        "weight" : "30",
        "specification" : "modelarts.vm.cpu.2u",
        "instance_count" : 1
      } ]
    }
  • 请求示例,创建专属资源池自定义规格在线服务样例

    POST https://{endpoint}/v1/{project_id}/services
    
    {
      "service_name" : "realtime-demo",
      "description" : "",
      "infer_type" : "real-time",
      "cluster_id" : "8abf68a969c3cb3a0169c4acb24b0000",
      "config" : [ {
        "model_id" : "eb6a4a8c-5713-4a27-b8ed-c7e694499af5",
        "weight" : "100",
        "cluster_id" : "8abf68a969c3cb3a0169c4acb24b0000",
        "specification" : "custom",
        "custom_spec" : {
          "cpu" : 1.5,
          "memory" : 7500,
          "gpu_p4" : 0,
          "ascend_a310" : 0
        },
        "instance_count" : 1
      } ]
    }
  • 请求示例,创建在线服务设置自动停止

    POST https://{endpoint}/v1/{project_id}/services
    
    {
      "service_name" : "service-demo",
      "description" : "demo",
      "infer_type" : "real-time",
      "config" : [ {
        "model_id" : "xxxmodel-idxxx",
        "weight" : "100",
        "specification" : "modelarts.vm.cpu.2u",
        "instance_count" : 1
      } ],
      "schedule" : [ {
        "type" : "stop",
        "time_unit" : "HOURS",
        "duration" : 1
      } ]
    }
  • 请求示例,创建批量服务且输入数据映射方式为“file”

    POST https://{endpoint}/v1/{project_id}/services
    
    {
      "service_name" : "batchservicetest",
      "description" : "",
      "infer_type" : "batch",
      "cluster_id" : "8abf68a969c3cb3a0169c4acb24b****",
      "config" : [ {
        "model_id" : "598b913a-af3e-41ba-a1b5-bf065320f1e2",
        "specification" : "modelarts.vm.cpu.2u",
        "instance_count" : 1,
        "src_path" : "https://infers-data.obs.xxxxx.com/xgboosterdata/",
        "dest_path" : "https://infers-data.obs.xxxxx.com/output/",
        "req_uri" : "/",
        "mapping_type" : "file"
      } ]
    }
  • 请求示例,创建批量服务且输入数据映射方式为“csv”

    POST https://{endpoint}/v1/{project_id}/services
    
    {
      "service_name" : "batchservicetest",
      "description" : "",
      "infer_type" : "batch",
      "config" : [ {
        "model_id" : "598b913a-af3e-41ba-a1b5-bf065320f1e2",
        "specification" : "modelarts.vm.cpu.2u",
        "instance_count" : 1,
        "src_path" : "https://infers-data.obs.xxxxx.com/xgboosterdata/",
        "dest_path" : "https://infers-data.obs.xxxxx.com/output/",
        "req_uri" : "/",
        "mapping_type" : "csv",
        "mapping_rule" : {
          "type" : "object",
          "properties" : {
            "data" : {
              "type" : "object",
              "properties" : {
                "req_data" : {
                  "type" : "array",
                  "items" : [ {
                    "type" : "object",
                    "properties" : {
                      "input5" : {
                        "type" : "number",
                        "index" : 0
                      },
                      "input4" : {
                        "type" : "number",
                        "index" : 1
                      },
                      "input3" : {
                        "type" : "number",
                        "index" : 2
                      },
                      "input2" : {
                        "type" : "number",
                        "index" : 3
                      },
                      "input1" : {
                        "type" : "number",
                        "index" : 4
                      }
                    }
                  } ]
                }
              }
            }
          }
        }
      } ]
    }
  • 请求示例,创建边缘服务样例

    POST https://{endpoint}/v1/{project_id}/services
    
    {
      "service_name" : "service-edge-demo",
      "description" : "",
      "infer_type" : "edge",
      "config" : [ {
        "model_id" : "eb6a4a8c-5713-4a27-b8ed-c7e694499af5",
        "specification" : "custom",
        "instance_count" : 1,
        "custom_spec" : {
          "cpu" : 1.5,
          "memory" : 7500,
          "gpu_p4" : 0,
          "ascend_a310" : 0
        },
        "envs" : { },
        "nodes" : [ "2r8c4fb9-t497-40u3-89yf-skui77db0472" ]
      } ]
    }
support.huaweicloud.com/api-modelarts/CreateService.html