Skip to main content

Create Task

更新时间:2025-05-08 17:32:25
Create single-node or distributed training tasks.
POST
https://api.alayanew.com/api/serverless-train/v1/task
Authorizations
AuthorizationsStringHeaderRequired

用户可通过已获取Open API Key做验证,例如:plain Credential=[YOUR_AK],Signature=[YOUR_SK]。

Body
application/json
nameStringRequired

Task name, e.g., my-debug.

typeStringRequired

Task type is 'task', default value is 'task'.

templateIdString

Template ID.

extensionsMap<String,String>

Used to pass custom customer extensions for subsequent task queries.

configObject

Response
状态码:application/json
codeInt

code is a common return value form, representing the execution result of the query operation.

0 is the success identifier, indicating the operation completed successfully.
dataObject

data.idString

Task ID.

msgStringRequired

Returns exception information when the code return value is -1.

curl -X POST 'https://api.alayanew.com/api/serverless-train/v1/task' 
     -H 'Authorization: plain Credential=YOUR_AK,Signature=YOUR_SK' 
    -H 'Content-Type: application/json' 
    -d '{
        "name": "my-debug",
        "type": "task",
        "templateId": "5df0ef3c-252a-44c8-aba3-a87e23615c76",
        "config": {
        "cmd": ["bash", "-c", "python3 main.py"],
        "resource": {
            "cpu": 2,
            "mem": 8,
            "gpu": {
            "count": 1,
            "gpuType": "nvidia.com/gpu-tesla-p4"
            },
            "epheneralStorage": 32
        },
        "image": "registry.hd-01.alayanew.com/aladdin/python:3.13",
        "vksId": "vc3jedd7crnd",
        "namespace": "default"
        }
    }'
{
  "code": 0,
  "data": {
    "id": "6ef0ef3c-252a-44c8-aba3-a87e23615c76"
  }
}


tip
  • 如果同时提供了templateIdconfig对象,系统将基于templateId指定的模板创建任务,并使用config对象中的参数对模板内容进行覆盖和更新。

  • 如果仅提供了templateId而未提供config对象,系统将直接使用templateId对应的模板创建任务。