vastai-workflow
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseVast.ai Workflow
Vast.ai 工作流
Overview
概述
Use this skill for provider-level Vast.ai automation only.
Keep it project-agnostic and parameter-driven.
本技能仅用于服务商级别的Vast.ai自动化操作。保持与项目无关,采用参数驱动。
Scope Boundaries
范围边界
- Handle only Vast API workflow logic: offers, create, poll, SSH attach, lifecycle, billing.
- Do not embed project-specific repo paths, branch names, labels, or training commands.
- If the user asks for workload-specific execution (for example Reparo training), switch to the corresponding workload skill after infrastructure provisioning.
- 仅处理Vast API工作流逻辑:报价、创建、轮询、SSH附加、生命周期、计费。
- 请勿嵌入项目特定的仓库路径、分支名称、标签或训练命令。
- 如果用户请求特定工作负载的执行(例如Reparo训练),请在基础设施配置完成后切换到对应的工作负载技能。
Dialog-First Required Fields
对话优先的必要字段
Before any create/order call, confirm required runtime fields in dialog.
If the user does not provide them, propose defaults and ask for confirmation.
Required fields and default suggestions:
- : default
api_key_sourceenvironment variable.VAST_API_KEY- If missing, suggest loading from a local file path the user confirms (for example ).
keys/.vast_env
- If missing, suggest loading from a local file path the user confirms (for example
- (offer filter): default
instance_type.gpu_name="RTX 4090"- Ask whether to lock by exact GPU, VRAM minimum, region, max price, and reliability.
- : default
image.pytorch/pytorch:latest - : default
disk_gb.64 - : default
count.1 - : do not ask by default.
label- Derive from Vast account identity when possible (nickname or email local-part).
- Fallback label: .
vast-user
Suggested minimal question set:
- Which action now (,
offers,create,status,ssh,destroy)?billing - Confirm runtime fields (,
image, instance filter).disk_gb - Confirm API key source (env vs file path).
VAST_API_KEY
If the user approves defaults, proceed without extra questions.
在进行任何创建/下单调用前,需通过对话确认必要的运行时字段。如果用户未提供,需给出默认建议并请求确认。
必要字段及默认建议:
- :默认值为
api_key_source环境变量。VAST_API_KEY- 如果缺失,建议从用户确认的本地文件路径加载(例如)。
keys/.vast_env
- 如果缺失,建议从用户确认的本地文件路径加载(例如
- (报价筛选):默认值为
instance_type。gpu_name="RTX 4090"- 询问是否要按精确GPU型号、最小显存、地域、最高价格和可靠性进行锁定筛选。
- :默认值为
image。pytorch/pytorch:latest - :默认值为
disk_gb。64 - :默认值为
count。1 - :默认不询问。
label- 尽可能从Vast账户身份信息中推导(昵称或邮箱本地部分)。
- 备用标签:。
vast-user
建议的最简问题集:
- 现在执行哪个操作(、
offers、create、status、ssh、destroy)?billing - 确认运行时字段(、
image、实例筛选条件)。disk_gb - 确认API密钥来源(环境变量 vs 文件路径)。
VAST_API_KEY
如果用户认可默认值,无需额外询问即可继续。
Workflow
工作流
1) Preflight
1) 预检
- Check active instances first.
- If any instances are unintentionally active, ask whether to stop/destroy before creating a new one.
- Ensure API key is loaded and never echo it.
- 首先检查活跃实例。
- 如果存在非预期的活跃实例,询问是否要在创建新实例前停止/销毁它们。
- 确保API密钥已加载,且绝不回显密钥。
2) Find offers
2) 查找报价
- Query offers (is commonly reliable in practice).
/bundles - Apply user filters plus mandatory and
rentable=true.rented=false - Sort by user objective (price, performance, reliability).
- Use user policy for selection:
- Default: choose cheapest valid offer.
- Optional conservative mode: choose second cheapest.
- 查询报价(实际使用中接口通常更可靠)。
/bundles - 应用用户筛选条件,加上强制的和
rentable=true。rented=false - 根据用户目标(价格、性能、可靠性)排序。
- 遵循用户策略选择报价:
- 默认:选择最便宜的有效报价。
- 可选保守模式:选择第二便宜的报价。
3) Create instance
3) 创建实例
- Create from a single selected offer ().
PUT /asks/{id} - Use confirmed , resolved
image, andlabel.disk_gb - Parse and store the returned instance ID.
- If create fails (or already taken), re-query and retry once with next candidate.
no_such_ask
Label resolution order:
- Load profile/account endpoint data and use nickname when present.
- If nickname missing, use the email local-part when available.
- If neither field is available, use .
vast-user
- 从单个选中的报价创建实例()。
PUT /asks/{id} - 使用已确认的、解析后的
image和label。disk_gb - 解析并存储返回的实例ID。
- 如果创建失败(或报价已被占用),重新查询并使用下一个候选报价重试一次。
no_such_ask
标签解析顺序:
- 加载个人资料/账户端点数据,若存在则使用昵称。
- 如果没有昵称,使用可用的邮箱本地部分。
- 如果上述两者都不可用,使用。
vast-user
4) Readiness and access
4) 就绪状态与访问
- Poll instance status until running.
- Add SSH key to account and attach to instance.
- Retry SSH readiness for up to 2 minutes before declaring failure.
- 轮询实例状态直到其运行。
- 将SSH密钥添加到账户并附加到实例。
- 重试SSH就绪检查最多2分钟,之后判定为失败。
5) Lifecycle and billing
5) 生命周期与计费
- Support start/stop/restart when available.
- Use destroy promptly when requested to prevent costs.
- Verify final state and check usage/invoices when needed.
- 支持可用的启动/停止/重启操作。
- 收到请求后立即执行销毁操作以避免产生费用。
- 必要时验证最终状态并检查使用情况/发票。
Request Templates
请求模板
Use explicit, reproducible requests and validate JSON before chaining calls.
bash
curl -sS -L -G "https://console.vast.ai/api/v0/<endpoint>/" \
--data-urlencode "api_key=$VAST_API_KEY" \
--data-urlencode "<param>=<value>"bash
curl -sS -L -X PUT "https://console.vast.ai/api/v0/asks/$OFFER_ID/?api_key=$VAST_API_KEY" \
-H "Content-Type: application/json" \
-d "{\"image\":\"$IMAGE\",\"disk\":$DISK_GB,\"label\":\"$LABEL\"}"使用明确、可复现的请求,在链式调用前验证JSON格式。
bash
curl -sS -L -G "https://console.vast.ai/api/v0/<endpoint>/" \
--data-urlencode "api_key=$VAST_API_KEY" \
--data-urlencode "<param>=<value>"bash
curl -sS -L -X PUT "https://console.vast.ai/api/v0/asks/$OFFER_ID/?api_key=$VAST_API_KEY" \
-H "Content-Type: application/json" \
-d "{\"image\":\"$IMAGE\",\"disk\":$DISK_GB,\"label\":\"$LABEL\"}"Error Handling
错误处理
- : API key missing, invalid, or not authorized for requested org/action.
401/403 - : rate limit; retry with backoff.
429 - : invalid endpoint or params; re-check request shape and required fields.
4xx - : provider-side issue; retry with backoff and re-validate state.
5xx - Empty/parse failures: retry once, then save response to a temp file and parse from file.
- :API密钥缺失、无效,或无权请求的组织/操作。
401/403 - :请求频率超限;退避后重试。
429 - :端点或参数无效;重新检查请求格式和必要字段。
4xx - :服务商端问题;退避后重试并重新验证状态。
5xx - 空响应/解析失败:重试一次,然后将响应保存到临时文件并从文件解析。
Resources
资源
- : concise endpoint map and safe calling checklist.
references/api.md - Treat as the working source for endpoint details and refresh it against official docs regularly.
references/api.md
- :简洁的端点映射和安全调用检查清单。
references/api.md - 将作为端点详情的工作来源,并定期对照官方文档更新。
references/api.md