使用任务模板
模板把"用什么镜像、装什么环境、开哪些端口、启动时跑什么"打包成一份可复用配置。模板优先是平台推荐的上手方式。
浏览与使用
进入控制台 模板(/app/templates),按热度浏览官方与社区模板。卡片上有图标、标签、使用次数。
点击「使用」会带着该模板进入算力市场,作为"当前模板"预选,并据其需求筛选兼容机器。
bash
# 列出模板(自有 + 公开),按使用次数排序
curl -s "$ARK_API/templates?page=1&limit=20" \
-H "Authorization: Bearer $ARK_TOKEN" | jq '.templates[] | {id, name, launch_mode, use_count}'
# "使用"某模板:返回其规格,并把 use_count +1
curl -X POST "$ARK_API/templates/$TEMPLATE_ID/use" \
-H "Authorization: Bearer $ARK_TOKEN"/use 返回的 template 字段即可用于预填创建表单(镜像、端口、env、磁盘建议等)。
模板字段
GET/POST /templates 的模板对象:
| 字段 | 说明 |
|---|---|
name | 模板名称(必填) |
description | 描述 |
icon_url | 图标 |
category / tags | 分类 / 标签 |
launch_mode | interactive 或 batch(默认 batch) |
is_public | 是否公开(默认私有,仅本组织可见) |
featured | 是否精选(官方维护) |
use_count | 使用次数(只读) |
version | 版本号 |
template | JSONB 规格,见下 |
template 规格(JSONB)
template 字段承载启动配置,典型键:
| 键 | 说明 |
|---|---|
image | Docker 镜像 |
entrypoint | 覆盖启动命令 |
app | 交互式应用类型:jupyter / terminal / custom |
cuda | 需要的 CUDA 版本(用于市场筛选兼容机器) |
disk_gb | 建议磁盘大小 |
gpu | 建议 GPU 卡数 |
ports | 要暴露的端口数组,每项 { port, label, open_button, proto } |
env | 环境变量 |
on_start | 启动脚本(容器起来后执行) |
字段以创建实例时实际接受的入参为准(见 交互式实例)。模板只是这些入参的一份预设。
创建自己的模板
把常用环境固化为模板,方便团队复用:
bash
curl -X POST "$ARK_API/templates" \
-H "Authorization: Bearer $ARK_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "vLLM 推理服务",
"launch_mode": "interactive",
"category": "inference",
"tags": ["llm", "vllm"],
"template": {
"image": "vllm/vllm-openai:latest",
"app": "custom",
"cuda": "12.1",
"disk_gb": 80,
"gpu": 1,
"ports": [{ "port": 8000, "label": "openai-api", "open_button": true, "proto": "tcp" }],
"env": { "MODEL": "Qwen/Qwen2.5-7B-Instruct" }
}
}'GET /templates/:id、PUT /templates/:id、DELETE /templates/:id分别用于查看 / 更新 / 删除(软删除,仅本组织可操作)。- 把
is_public设为true可分享给平台所有用户。
模板与镜像的关系
模板引用的镜像可以是公开镜像、私有仓库镜像(在创建实例时提供 registry 凭证),或你保存的自定义镜像。模板固化"环境定义",镜像固化"已装好的环境",两者配合使用。
下一步 → 交互式实例。
