Glows.ai SDK 的 API 文件
使用 SDK 啟動一個新的執行個體
| from_image_id required | string 映像檔 ID,例如:6np5yvq2 |
| gpu_name required | string GPU 機器名稱,例如:NVIDIA L40S PCIe |
| custom_meta_key required | string 使用者自訂的執行個體唯一識別碼,與執行個體 ID 不同 |
| instance_category required | string 機器底層技術類型,例如:container、vm |
| region_name required | string 機器所在區域,例如:TW-03、TW-04 等。 |
| remark | string 使用者自訂的執行個體備註名稱 |
| public_ip_id | string 綁定的 Public IP 對應 ID,例如:net-abcdefg |
| envs | string 預設環境變數,例如:foo=bar;tik=tok |
| ports | string 自訂對外開放的連接埠,採 JSON 字串格式,例如:[{"port":7890,"protocol":2}, {"port":3306,"protocol":1}],其中 protocol=1 代表 SSH 協定,protocol=2 代表 HTTP 協定 |
| cmd | string 進入點指令,僅支援 container 模式。指令必須能持續執行(hang),否則指令結束後執行個體會自動被釋放。例如:python -m http.server 8080 |
| code | integer 回傳代碼,0 代表成功,其他(非 0)代表失敗 |
| msg | string 回傳訊息,通常為失敗描述 |
object |
curl --http1.1 \ --request POST \ --url 'https://a.glows.ai/sdk/v1/instance' \ --header 'Authorization: Bearer YOUR_SDK_TOKEN' \ --header 'Content-Type: application/json' \ --data '{ "from_snap_id": "6ypgvgpw", "custom_meta_key": "cpu_test.009", "cpu_name": "Intel(R) Xeon(R) Platinum 8468", "instance_category": "container", "region_name": "TW-04", "public_ip_id": "net-abcdefg" }'
{- "code": 0,
- "msg": "",
- "instance": {
- "instanceID": "boyqp4g8",
- "category": "container",
- "status": "SchedQueued",
- "priceCent": 0,
- "hardware": {
- "gpuName": "NVIDIA GeForce RTX 4090",
- "cpuName": "",
- "gpuNum": 0,
- "gpuRamMB": 0,
- "cpuCoresNum": 0,
- "ramMB": 0,
- "diskGB": 0
}, - "baseImage": {
- "imageID": "87p9kq26",
- "imageName": "Ubuntu20.04 CUDA12.2 Python3.9"
}, - "baseSnap": null,
- "sshCred": {
- "user": "root",
- "password": "YOUR_INSTANCE_PASSWORD"
}, - "accesses": [
- {
- "protocol": "ssh",
- "listenPort": 22,
- "url": ""
}, - {
- "protocol": "http",
- "listenPort": 8888,
- "url": ""
}, - {
- "protocol": "http",
- "listenPort": 7890,
- "url": ""
}
], - "domain": 2,
- "createTime": {
- "seconds": 1726810944
}, - "cmd": "",
- "envs": "foo=bar",
- "remark": "this is from sdk",
- "metaKey": "order.123456",
- "sourceType": "SourceSDK",
- "regionName": "TW-03"
}
}查詢指定執行個體的資訊
| request_id | string 執行個體 ID(建立執行個體回應中的 instanceID)。request_id 與 meta_key 須擇一提供。 |
| meta_key | string 建立執行個體時指定的 meta_key,全域唯一。request_id 與 meta_key 須擇一提供。 |
| code | integer 回傳代碼,0 代表成功,其他(非 0)代表失敗 |
| msg | string 回傳訊息,通常為失敗描述 |
object |
curl --http1.1 \ --request GET \ --url 'https://a.glows.ai/sdk/v1/instance?meta_key=cpu_test.009' \ --header 'Authorization: Bearer YOUR_SDK_TOKEN'
{- "code": 0,
- "msg": "",
- "instance": {
- "instanceID": "boyqp4g8",
- "category": "container",
- "status": "Running",
- "priceCent": 65,
- "hardware": {
- "gpuName": "NVIDIA GeForce RTX 4090",
- "cpuName": "Intel(R) Xeon(R) Platinum 8352V CPU @ 2.10GHz",
- "gpuNum": 1,
- "gpuRamMB": 24564,
- "cpuCoresNum": 10,
- "ramMB": 43008,
- "diskGB": 100
}, - "baseImage": {
- "imageID": "87p9kq26",
- "imageName": "Ubuntu20.04 CUDA12.2 Python3.9"
}, - "baseSnap": null,
- "sshCred": {
- "user": "root",
- "password": "YOUR_INSTANCE_PASSWORD"
}, - "accesses": [
- {
- "protocol": "ssh",
- "listenPort": 22,
- "url": "ssh://tw-01.access.glows.ai:15692"
}, - {
- "protocol": "http",
- "listenPort": 8888,
}, - {
- "protocol": "http",
- "listenPort": 7890,
}
], - "domain": 2,
- "createTime": {
- "seconds": 1726810944
}, - "cmd": "",
- "envs": "foo=bar",
- "remark": "this is from sdk",
- "metaKey": "order.123456",
- "sourceType": "SourceSDK",
- "regionName": "TW-03"
}
}透過 request_id 或 meta_key 釋放執行個體
| request_id | string 執行個體 ID(建立執行個體回應中的 instanceID)。request_id 與 meta_key 須擇一提供。 |
| meta_key | string 建立執行個體時指定的 meta_key,全域唯一。request_id 與 meta_key 須擇一提供。 |
| code | integer 回傳代碼,0 代表成功,其他(非 0)代表失敗 |
| msg | string 回傳訊息,通常為失敗描述 |
curl --http1.1 \ --request DELETE \ --url 'https://a.glows.ai/sdk/v1/instance?meta_key=cpu_test.009' \ --header 'Authorization: Bearer YOUR_SDK_TOKEN'
{- "code": 0,
- "msg": ""
}查詢執行個體的統計資料
| code | integer 回傳代碼,0 代表成功,其他(非 0)代表失敗 |
| msg | string 回傳訊息,通常為失敗描述 |
object 各狀態對應的執行個體數量;統計為 0 的狀態不會顯示 |
curl --http1.1 \ --request GET \ --url 'https://a.glows.ai/sdk/v1/instance/stats' \ --header 'Authorization: Bearer YOUR_SDK_TOKEN'
{- "code": 0,
- "msg": "",
- "stats": {
- "Running": 1
}
}以分頁與篩選條件取得執行個體列表
| page required | integer 分頁編號 |
| per_page required | integer 每頁筆數 |
| ascending | boolean 是否以建立時間遞增排序,預設為遞減排序 |
| statuses | Array of strings 只顯示指定狀態的執行個體 |
| code | integer 回傳代碼,0 代表成功,其他(非 0)代表失敗 |
| msg | string 回傳訊息,通常為失敗描述 |
object | |
Array of objects |
curl --http1.1 \ --request GET \ --url 'https://a.glows.ai/sdk/v1/instance/list?page=1&per_page=10&statuses=Running' \ --header 'Authorization: Bearer YOUR_SDK_TOKEN'
{- "code": 0,
- "msg": "",
- "pagination": {
- "total": 0,
- "numPages": 0,
- "page": 1,
- "perPage": 10
}, - "instances": [ ]
}