vastai

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

vastai

vastai

Manage GPU instances, templates, volumes, serverless endpoints, SSH keys, and billing on Vast.ai.
Command is
vastai
(lowercase). Always use
--raw
for machine-readable JSON output.
在Vast.ai上管理GPU实例、模板、存储卷、无服务器端点、SSH密钥及账单。
命令为
vastai
(小写)。如需机器可读的JSON输出,请始终使用
--raw
参数。

Install

安装

bash
undefined
bash
undefined

PyPI (recommended)

PyPI(推荐方式)

pip install vastai
undefined
pip install vastai
undefined

Quick start

快速开始

bash
vastai set api-key <YOUR_API_KEY>                   # Authenticate (one-time); Create API Key in account at https://console.vast.ai/manage-keys/
vastai show user                                    # Verify auth + check balance
vastai create ssh-key ~/.ssh/id_ed25519.pub         # Register SSH key (do BEFORE create)
vastai search offers 'gpu_name=RTX_4090 num_gpus=1 verified=true direct_port_count>=1 rentable=true' -o 'dlperf_usd-'
bash
vastai set api-key <YOUR_API_KEY>                   # 完成身份验证(仅需一次);请在账户页面https://console.vast.ai/manage-keys/创建API密钥
vastai show user                                    # 验证身份并查看账户余额
vastai create ssh-key ~/.ssh/id_ed25519.pub         # 注册SSH密钥(请在创建实例前完成此操作)
vastai search offers 'gpu_name=RTX_4090 num_gpus=1 verified=true direct_port_count>=1 rentable=true' -o 'dlperf_usd-'

Note the offer ID from the output

记录输出中的报价ID

vastai create instance <OFFER_ID> --image pytorch/pytorch:@vastai-automatic-tag --disk 20 --ssh --direct
vastai create instance <OFFER_ID> --image pytorch/pytorch:@vastai-automatic-tag --disk 20 --ssh --direct

Automatically grab appropriate image tag; Response: {"success": true, "new_contract": <INSTANCE_ID>}

自动获取适配的镜像标签;响应示例:{"success": true, "new_contract": <INSTANCE_ID>}

vastai show instance <INSTANCE_ID> # Poll until actual_status == "running" (see Instance status values below) vastai ssh-url <INSTANCE_ID> # Get SSH connection string vastai copy local:./data/ <INSTANCE_ID>:/workspace/ # Upload files vastai destroy instance <INSTANCE_ID> -y # Clean up (stops all billing; -y skips confirmation)

API key: https://console.vast.ai/manage-keys/
vastai show instance <INSTANCE_ID> # 轮询实例状态,直到actual_status为"running"(状态说明见下文) vastai ssh-url <INSTANCE_ID> # 获取SSH连接字符串 vastai copy local:./data/ <INSTANCE_ID>:/workspace/ # 上传文件 vastai destroy instance <INSTANCE_ID> -y # 清理资源(停止所有计费;-y参数跳过确认步骤)

API密钥获取地址:https://console.vast.ai/manage-keys/

Global flags

全局参数

Available on every command:
--api-key KEY    Override stored API key
--raw            Output machine-readable JSON (agents should always use this)
--full           Print full results (don't page with less)
--explain        Show underlying API calls (useful for debugging)
--curl           Show equivalent curl command
--no-color       Disable colored output
--url URL        Override server REST API URL
--retry RETRY    Set retry limit for API calls
--version        Show CLI version
所有命令均支持以下参数:
--api-key KEY    覆盖已存储的API密钥
--raw            输出机器可读的JSON格式内容(Agent应始终使用此参数)
--full           打印完整结果(不使用less分页)
--explain        显示底层API调用(用于调试)
--curl           显示等效的curl命令
--no-color       禁用彩色输出
--url URL        覆盖服务器REST API地址
--retry RETRY    设置API调用的重试次数上限
--version        显示CLI版本

Query syntax

查询语法

Search commands accept filter expressions. Operators:
=
,
!=
,
>
,
>=
,
<
,
<=
,
in
,
notin
.
bash
undefined
搜索命令支持过滤表达式,可用操作符:
=
,
!=
,
>
,
>=
,
<
,
<=
,
in
,
notin
bash
undefined

Examples

示例

'gpu_name=RTX_4090 num_gpus=1' # Exact match + numeric 'gpu_ram>=48 reliability>0.95' # Greater-than filters 'geolocation=EU dph_total<=2.0' # Region + price cap

Common filter fields: `num_gpus`, `gpu_name`, `gpu_ram`, `cpu_ram`, `disk_space`, `reliability`, `compute_cap`, `inet_up`, `inet_down`, `dph_total`, `geolocation`, `direct_port_count`, `verified`, `rentable`

Common sort fields: `score` (default — overall value), `dlperf_usd` (DL perf per dollar), `dph_total` (price), `num_gpus`, `reliability`
'gpu_name=RTX_4090 num_gpus=1' # 精确匹配+数值过滤 'gpu_ram>=48 reliability>0.95' # 大于等于过滤 'geolocation=EU dph_total<=2.0' # 地域+价格上限过滤

常用过滤字段:`num_gpus`, `gpu_name`, `gpu_ram`, `cpu_ram`, `disk_space`, `reliability`, `compute_cap`, `inet_up`, `inet_down`, `dph_total`, `geolocation`, `direct_port_count`, `verified`, `rentable`

常用排序字段:`score`(默认——综合价值), `dlperf_usd`(每美元深度学习性能), `dph_total`(价格), `num_gpus`, `reliability`

Commands

命令列表

Instances

实例管理

bash
vastai show instances                                    # List all your instances
vastai show instances-v1                                 # Paginated instances with full filter/sort/cols support
vastai show instances-v1 --status running loading        # Filter by status
vastai show instances-v1 --gpu-name 'RTX 4090'           # Filter by GPU
vastai show instances-v1 --label training                # Filter by label
vastai show instances-v1 --order-by start_date desc      # Sort by column
vastai show instances-v1 --cols id,status,gpu,dph        # Custom columns
vastai show instance <id>                                # Poll single instance (use for status checks)
vastai create instance <offer-id> --image pytorch/pytorch:2.4.0-cuda12.4-cudnn9-runtime --disk 20 --ssh --direct
bash
vastai show instances                                    # 列出所有实例
vastai show instances-v1                                 # 支持完整过滤/排序/列选择的分页实例列表
vastai show instances-v1 --status running loading        # 按状态过滤
vastai show instances-v1 --gpu-name 'RTX 4090'           # 按GPU型号过滤
vastai show instances-v1 --label training                # 按标签过滤
vastai show instances-v1 --order-by start_date desc      # 按列排序
vastai show instances-v1 --cols id,status,gpu,dph        # 自定义显示列
vastai show instance <id>                                # 轮询单个实例状态(用于状态检查)
vastai create instance <offer-id> --image pytorch/pytorch:2.4.0-cuda12.4-cudnn9-runtime --disk 20 --ssh --direct

Response includes "new_contract": <id> — that is your instance ID

响应包含"new_contract": <id> —— 这就是你的实例ID

vastai launch instance --gpu-name RTX_4090 --num-gpus 1 --image pytorch/pytorch vastai start instance <id> # Start stopped instance vastai stop instance <id> # Stop (preserves disk, no GPU charges) vastai reboot instance <id> # Stop + start vastai destroy instance <id> -y # Delete permanently (irreversible; -y required for non-interactive use) vastai destroy instances <id1> <id2> -y # Batch delete (-y skips confirmation prompt) vastai label instance <id> --label "training-run-1" # Tag instance vastai update instance <id> # Recreate from updated template vastai prepay instance <id> # Deposit credits into reserved instance vastai recycle instance <id> # Destroy + recreate

**Recommended Vast.ai images** (use `@vastai-automatic-tag` to get the right tag for the machine automatically; browse pre-configured models at https://vast.ai/model-library):

<!-- Note: @vastai-automatic-tag is resolved server-side — CLI passes it unchanged -->

```bash
vastai/base-image:@vastai-automatic-tag          # Minimal Ubuntu base
vastai/pytorch:@vastai-automatic-tag             # PyTorch + CUDA
vastai/linux-desktop:@vastai-automatic-tag       # Linux desktop (VNC/RDP)
vastai launch instance --gpu-name RTX_4090 --num-gpus 1 --image pytorch/pytorch vastai start instance <id> # 启动已停止的实例 vastai stop instance <id> # 停止实例(保留磁盘,无GPU计费) vastai reboot instance <id> # 重启实例(停止后启动) vastai destroy instance <id> -y # 永久删除实例(不可恢复;非交互式使用需加-y参数) vastai destroy instances <id1> <id2> -y # 批量删除实例(-y参数跳过确认提示) vastai label instance <id> --label "training-run-1" # 为实例添加标签 vastai update instance <id> # 根据更新后的模板重新创建实例 vastai prepay instance <id> # 为预留实例存入信用额度 vastai recycle instance <id> # 删除并重新创建实例

**推荐的Vast.ai镜像**(使用`@vastai-automatic-tag`可自动获取适配机器的正确标签;可在https://vast.ai/model-library浏览预配置模型):

<!-- 注意:@vastai-automatic-tag由服务器端解析——CLI会原样传递该参数 -->

```bash
vastai/base-image:@vastai-automatic-tag          # 轻量Ubuntu基础镜像
vastai/pytorch:@vastai-automatic-tag             # PyTorch + CUDA镜像
vastai/linux-desktop:@vastai-automatic-tag       # Linux桌面镜像(支持VNC/RDP)

vLLM — set model via env vars with huggingface model example

vLLM —— 通过环境变量设置模型,以HuggingFace模型为例

vastai create instance <id> --image vastai/vllm:@vastai-automatic-tag --disk 40 --ssh --direct
--env '-e MODEL_NAME=Qwen/Qwen2.5-3B-Instruct -e HF_TOKEN=hf_xxx'
vastai create instance <id> --image vastai/vllm:@vastai-automatic-tag --disk 40 --ssh --direct
--env '-e MODEL_NAME=Qwen/Qwen2.5-3B-Instruct -e HF_TOKEN=hf_xxx'

ComfyUI — set model checkpoint via env vars with huggingface model example

ComfyUI —— 通过环境变量设置模型 checkpoint,以HuggingFace模型为例

vastai create instance <id> --image vastai/comfy:@vastai-automatic-tag --disk 40 --ssh --direct
--env '-e CHECKPOINT_MODEL=black-forest-labs/FLUX.1-schnell -e HF_TOKEN=hf_xxx'

**create instance flags:**
- `--image IMAGE` — Docker image
- `--disk DISK` — Local disk in GB
- `--ssh` / `--jupyter` — Connection type
- `--direct` — Faster direct connections
- `--label LABEL` — Instance label
- `--env ENV` — Env vars and port mappings, e.g. `'-e TZ=UTC -p 8080:8080'`
- `--onstart FILE` — Path to a startup script file
- `--onstart-cmd CMD` — Startup script as inline string (for longer scripts use `--onstart` or gzip+base64 encode)
- `--bid_price PRICE` — Interruptible (spot) pricing in $/hr
- `--template_hash HASH` — Create from template
- `--create-volume ID` — Attach new volume
- `--link-volume ID` — Attach existing volume
- `--cancel-unavail` — Fail if no machine available (vs. create stopped)

**Instance status values:**

| `actual_status` | Meaning |
|-----------------|---------|
| `null` | Provisioning |
| `created` | Instance created, not yet provisioned |
| `loading` | Image downloading / container starting |
| `running` | Active — GPU charges apply |
| `stopped` | Halted — disk charges only |
| `frozen` | Paused with memory — GPU charges apply |
| `exited` | Container process exited unexpectedly |
| `rebooting` | Restarting (transient) |
| `unknown` | No recent heartbeat from host |
| `offline` | Host disconnected from Vast servers |

> **Poll loop warning:** If `actual_status` becomes `exited`, `unknown`, or `offline` it will never reach `running`. Always add a timeout and error branch — otherwise your script loops forever while disk charges accrue. Destroy and retry with a different offer.

> **Charges:** Storage charges begin at creation. GPU charges begin when status reaches `running`.
vastai create instance <id> --image vastai/comfy:@vastai-automatic-tag --disk 40 --ssh --direct
--env '-e CHECKPOINT_MODEL=black-forest-labs/FLUX.1-schnell -e HF_TOKEN=hf_xxx'

**create instance参数说明:**
- `--image IMAGE` —— Docker镜像
- `--disk DISK` —— 本地磁盘容量(GB)
- `--ssh` / `--jupyter` —— 连接类型
- `--direct` —— 启用更快的直连模式
- `--label LABEL` —— 实例标签
- `--env ENV` —— 环境变量和端口映射,例如 `'-e TZ=UTC -p 8080:8080'`
- `--onstart FILE` —— 启动脚本文件路径
- `--onstart-cmd CMD` —— 内联启动脚本(较长脚本建议使用`--onstart`或gzip+base64编码)
- `--bid_price PRICE` —— 可中断(竞价)实例的每小时价格(美元)
- `--template_hash HASH` —— 根据模板创建实例
- `--create-volume ID` —— 挂载新存储卷
- `--link-volume ID` —— 挂载已存在的存储卷
- `--cancel-unavail` —— 若无可用机器则创建失败(而非创建已停止的实例)

**实例状态说明:**

| `actual_status` | 含义 |
|-----------------|---------|
| `null` | 正在配置 |
| `created` | 实例已创建,尚未完成配置 |
| `loading` | 镜像下载/容器启动中 |
| `running` | 实例活跃——开始GPU计费 |
| `stopped` | 实例已停止——仅收取磁盘存储费用 |
| `frozen` | 实例已暂停但保留内存——仍收取GPU费用 |
| `exited` | 容器进程意外退出 |
| `rebooting` | 实例重启中(临时状态) |
| `unknown` | 主机无近期心跳 |
| `offline` | 主机已断开与Vast服务器的连接 |

> **轮询循环警告:** 如果`actual_status`变为`exited`、`unknown`或`offline`,实例将永远无法进入`running`状态。请务必添加超时和错误分支——否则脚本会无限循环,同时磁盘费用会持续产生。此时应销毁实例并尝试使用其他报价重新创建。

> **计费说明:** 存储费用从实例创建时开始计算。GPU费用从实例状态变为`running`时开始计算。

Search

搜索功能

bash
vastai search offers                                     # Default: verified, on-demand, sorted by score
vastai search offers 'gpu_name=RTX_4090 num_gpus=1 verified=true direct_port_count>=1' -o 'dlperf_usd-'
vastai search offers 'num_gpus>=4 reliability>0.99' -o 'num_gpus-'
vastai search offers --type bid                          # Interruptible (spot) pricing
vastai search offers --type reserved                     # Reserved pricing
vastai search offers -n 'gpu_name=H100_SXM'             # No default filters
vastai search volumes                                    # Search volume offers
vastai search templates "pytorch"                        # Search templates
vastai search benchmarks                                 # Search benchmarks
vastai search invoices                                   # Search invoice history
search offers flags:
--type on-demand|reserved|bid
,
--order/-o FIELD[-]
,
--limit
,
--storage GB
,
--no-default/-n
bash
vastai search offers                                     # 默认:已验证、按需实例,按综合价值排序
vastai search offers 'gpu_name=RTX_4090 num_gpus=1 verified=true direct_port_count>=1' -o 'dlperf_usd-'
vastai search offers 'num_gpus>=4 reliability>0.99' -o 'num_gpus-'
vastai search offers --type bid                          # 搜索可中断(竞价)实例报价
vastai search offers --type reserved                     # 搜索预留实例报价
vastai search offers -n 'gpu_name=H100_SXM'             # 不使用默认过滤条件
vastai search volumes                                    # 搜索存储卷报价
vastai search templates "pytorch"                        # 搜索模板
vastai search benchmarks                                 # 搜索基准测试结果
vastai search invoices                                   # 搜索账单历史
search offers参数:
--type on-demand|reserved|bid
,
--order/-o FIELD[-]
,
--limit
,
--storage GB
,
--no-default/-n

SSH & File Transfer

SSH与文件传输

bash
vastai ssh-url <id>                                      # Get ssh:// connection URL
vastai scp-url <id>                                      # Get scp:// URL
vastai attach ssh <id> "ssh-ed25519 AAAA..."             # Attach SSH key to instance
vastai detach ssh <id> <ssh_key_id>                      # Remove SSH key (ssh_key_id from show ssh-keys)
vastai show ssh-keys                                     # List account SSH keys
vastai create ssh-key ~/.ssh/id_ed25519.pub              # Add SSH key from file (do BEFORE create instance)
vastai create ssh-key                                    # Generate new key if you don't have one
vastai create ssh-key "ssh-ed25519 AAAA..."              # Add SSH key inline
vastai delete ssh-key <id>                               # Remove SSH key from account
vastai update ssh-key <id> "ssh-ed25519 AAAA..."         # Update SSH key value
Note:
ssh-url
returns a connection string — it does not open an interactive session. Use
$(vastai ssh-url <id>)
to extract the URL, or parse
--raw
JSON output.
bash
vastai ssh-url <id>                                      # 获取ssh://连接地址
vastai scp-url <id>                                      # 获取scp://连接地址
vastai attach ssh <id> "ssh-ed25519 AAAA..."             # 为实例绑定SSH密钥
vastai detach ssh <id> <ssh_key_id>                      # 解绑SSH密钥(ssh_key_id可通过show ssh-keys命令获取)
vastai show ssh-keys                                     # 列出账户下的所有SSH密钥
vastai create ssh-key ~/.ssh/id_ed25519.pub              # 从文件添加SSH密钥(请在创建实例前完成)
vastai create ssh-key                                    # 若没有SSH密钥则生成新密钥
vastai create ssh-key "ssh-ed25519 AAAA..."              # 内联添加SSH密钥
vastai delete ssh-key <id>                               # 从账户删除SSH密钥
vastai update ssh-key <id> "ssh-ed25519 AAAA..."         # 更新SSH密钥内容
注意:
ssh-url
命令仅返回连接字符串——不会打开交互式会话。可使用
$(vastai ssh-url <id>)
提取地址,或解析
--raw
参数输出的JSON内容。

File Copy

文件复制

bash
vastai copy <src> <dst>                                  # Copy between instance and local
vastai copy local:./data/ <id>:/workspace/data/          # Local → instance (preferred format)
vastai copy <id>:/workspace/results/ local:./results/    # Instance → local
vastai copy <id-a>:/workspace/ <id-b>:/workspace/        # Instance → instance
bash
vastai copy <src> <dst>                                  # 在实例与本地之间复制文件
vastai copy local:./data/ <id>:/workspace/data/          # 本地→实例(推荐格式)
vastai copy <id>:/workspace/results/ local:./results/    # 实例→本地
vastai copy <id-a>:/workspace/ <id-b>:/workspace/        # 实例→实例

Legacy format also works: vastai copy 12345:./data ./local-data

旧格式同样可用:vastai copy 12345:./data ./local-data

vastai cloud copy --src ./data --dst s3://bucket/path
--instance 12345 --connection <conn-id>
--transfer "Instance To Cloud" # To cloud storage (add connection in UI on settings page) vastai cancel copy <dst-id> # Cancel in-progress copy

**cloud copy flags:** `--src`, `--dst`, `--instance`, `--connection`, `--transfer`
vastai cloud copy --src ./data --dst s3://bucket/path
--instance 12345 --connection <conn-id>
--transfer "Instance To Cloud" # 复制到云存储(请在UI设置页面添加连接) vastai cancel copy <dst-id> # 取消正在进行的复制任务

**cloud copy参数:** `--src`, `--dst`, `--instance`, `--connection`, `--transfer`

Logs & Exec

日志与命令执行

bash
vastai logs <id>                                         # Container logs (last 1000 lines)
vastai logs <id> --tail 100                              # Last 100 lines
vastai logs <id> --filter "error"                        # Grep filter
vastai execute <id> "nvidia-smi"                         # Run command on instance
vastai execute <id> "ls /workspace" --schedule DAILY     # Scheduled execution
bash
vastai logs <id>                                         # 获取容器日志(最后1000行)
vastai logs <id> --tail 100                              # 获取最后100行日志
vastai logs <id> --filter "error"                        # 过滤包含指定关键词的日志
vastai execute <id> "nvidia-smi"                         # 在实例上执行命令
vastai execute <id> "ls /workspace" --schedule DAILY     # 定时执行命令

Volumes

存储卷管理

bash
vastai search volumes                                    # Search available volume offers
vastai show volumes                                      # List your volumes
vastai create volume <offer_id> [-s SIZE] [-n NAME]      # Create volume (offer_id from search volumes)
vastai clone volume <source_id> <dest_id> [-s SIZE]      # Clone volume (dest_id from search volumes)
vastai delete volume <id>                                # Delete volume
vastai create network-volume ...                         # Create network volume
vastai list network-volume                               # List network volumes
vastai take snapshot <instance_id> --repo REPO --docker_login_user USER --docker_login_pass PASS  # Snapshot instance to volume
bash
vastai search volumes                                    # 搜索可用的存储卷报价
vastai show volumes                                      # 列出账户下的所有存储卷
vastai create volume <offer_id> [-s SIZE] [-n NAME]      # 创建存储卷(offer_id来自search volumes命令)
vastai clone volume <source_id> <dest_id> [-s SIZE]      # 克隆存储卷(dest_id来自search volumes命令)
vastai delete volume <id>                                # 删除存储卷
vastai create network-volume ...                         # 创建网络存储卷
vastai list network-volume                               # 列出网络存储卷
vastai take snapshot <instance_id> --repo REPO --docker_login_user USER --docker_login_pass PASS  # 将实例快照保存到存储卷

Serverless & Deployments

无服务器与部署管理

bash
vastai show endpoints                                    # List endpoint groups
vastai create endpoint --name "my-ep" ...                # Create endpoint
vastai update endpoint <id> ...                          # Update endpoint
vastai delete endpoint <id>                              # Delete endpoint
vastai get endpt-logs <id>                               # Endpoint logs

vastai show workergroups                                 # List worker groups
vastai create workergroup --name "wg" ...                # Create worker group
vastai update workergroup <id> ...                       # Update worker group
vastai update workers <id>                               # Rolling update of workers
vastai delete workergroup <id>                           # Delete worker group
vastai get wrkgrp-logs <id>                              # Worker group logs

vastai show deployments                                  # List deployments
vastai show deployment <id>                              # Deployment details
vastai show deployment-versions <id>                     # Version history
vastai delete deployment <id>                            # Delete deployment

vastai show scheduled-jobs                               # List scheduled jobs
vastai delete scheduled-job <id>                         # Delete scheduled job
bash
vastai show endpoints                                    # 列出端点组
vastai create endpoint --name "my-ep" ...                # 创建端点
vastai update endpoint <id> ...                          # 更新端点
vastai delete endpoint <id>                              # 删除端点
vastai get endpt-logs <id>                               # 获取端点日志

vastai show workergroups                                 # 列出工作者组
vastai create workergroup --name "wg" ...                # 创建工作者组
vastai update workergroup <id> ...                       # 更新工作者组
vastai update workers <id>                               # 滚动更新工作者
vastai delete workergroup <id>                           # 删除工作者组
vastai get wrkgrp-logs <id>                              # 获取工作者组日志

vastai show deployments                                  # 列出部署
vastai show deployment <id>                              # 查看部署详情
vastai show deployment-versions <id>                     # 查看部署版本历史
vastai delete deployment <id>                            # 删除部署

vastai show scheduled-jobs                               # 列出定时任务
vastai delete scheduled-job <id>                         # 删除定时任务

Templates

模板管理

bash
vastai search templates "pytorch"                        # Search templates
vastai create template --name "x" --image "img"          # Create template
vastai update template <id> ...                          # Update template
vastai delete template <id>                              # Delete template
bash
vastai search templates "pytorch"                        # 搜索模板
vastai create template --name "x" --image "img"          # 创建模板
vastai update template <id> ...                          # 更新模板
vastai delete template <id>                              # 删除模板

Account & API Keys

账户与API密钥管理

bash
vastai set api-key <key>                                 # Save API key locally
vastai show api-key <id>                                 # Show a specific key
vastai show api-keys                                     # List all your API keys
vastai create api-key --name "ci" --permissions '{...}'  # Create restricted key
vastai delete api-key <id>                               # Delete key
vastai reset api-key                                     # Reset main key (get new from console)
vastai show user                                         # Account info, credit balance
vastai show audit-logs                                   # Account action history
vastai show connections                                  # Cloud storage connections
vastai show ipaddrs                                      # IP address history
bash
vastai set api-key <key>                                 # 本地保存API密钥
vastai show api-key <id>                                 # 查看指定API密钥
vastai show api-keys                                     # 列出所有API密钥
vastai create api-key --name "ci" --permissions '{...}'  # 创建受限API密钥
vastai delete api-key <id>                               # 删除API密钥
vastai reset api-key                                     # 重置主密钥(请在控制台获取新密钥)
vastai show user                                         # 查看账户信息、信用余额
vastai show audit-logs                                   # 查看账户操作历史
vastai show connections                                  # 查看云存储连接
vastai show ipaddrs                                      # 查看IP地址历史

Billing

账单管理

bash
vastai show invoices-v1                                  # Charges/invoices (paginated)
vastai show invoices-v1 --charges                        # Charges only
vastai show invoices-v1 --invoices                       # Invoices only
vastai show invoices-v1 --start-date 2026-01-01 --end-date 2026-02-01
vastai show invoices-v1 --limit 50 --latest-first
vastai show deposit <id>                                 # Reserved instance deposit info
bash
vastai show invoices-v1                                  # 查看费用/账单(分页)
vastai show invoices-v1 --charges                        # 仅查看费用
vastai show invoices-v1 --invoices                       # 仅查看账单
vastai show invoices-v1 --start-date 2026-01-01 --end-date 2026-02-01
vastai show invoices-v1 --limit 50 --latest-first
vastai show deposit <id>                                 # 查看预留实例存款信息

Teams

团队管理

bash
vastai create team --name "myteam"                       # Create team
vastai show members                                      # List team members
vastai invite member --email user@example.com            # Invite member
vastai remove member <id>                                # Remove member
vastai create team-role --name "viewer" ...              # Create role
vastai show team-role <id>                               # Role details
vastai show team-roles                                   # List roles
vastai update team-role <id> ...                         # Update role
vastai remove team-role <id>                             # Remove role
vastai destroy team                                      # Delete team
bash
vastai create team --name "myteam"                       # 创建团队
vastai show members                                      # 列出团队成员
vastai invite member --email user@example.com            # 邀请成员
vastai remove member <id>                                # 移除成员
vastai create team-role --name "viewer" ...              # 创建角色
vastai show team-role <id>                               # 查看角色详情
vastai show team-roles                                   # 列出所有角色
vastai update team-role <id> ...                         # 更新角色
vastai remove team-role <id>                             # 删除角色
vastai destroy team                                      # 删除团队

Environment Variables

环境变量管理

bash
vastai show env-vars                                     # List user env vars
vastai create env-var KEY val                             # Create env var
vastai update env-var KEY newval                          # Update env var
vastai delete env-var KEY                                 # Delete env var
bash
vastai show env-vars                                     # 列出用户环境变量
vastai create env-var KEY val                             # 创建环境变量
vastai update env-var KEY newval                          # 更新环境变量
vastai delete env-var KEY                                 # 删除环境变量

Machine Management (hosts)

主机管理

bash
vastai show machines                                     # List your machines
vastai list machine <id>                                 # List/unlist machine on marketplace
vastai show machine <id>                                 # Machine details
vastai cleanup machine <id>                              # Clean up machine state
vastai schedule maint <id> ...                           # Schedule maintenance window
vastai cancel maint <id>                                 # Cancel scheduled maintenance
vastai show maints                                       # List maintenance windows
vastai unlist machine <id>                               # Remove from marketplace
bash
vastai show machines                                     # 列出你的主机
vastai list machine <id>                                 # 在市场上架/下架主机
vastai show machine <id>                                 # 查看主机详情
vastai cleanup machine <id>                              # 清理主机状态
vastai schedule maint <id> ...                           # 安排维护窗口
vastai cancel maint <id>                                 # 取消已安排的维护
vastai show maints                                       # 列出所有维护窗口
vastai unlist machine <id>                               # 将主机从市场下架

Common errors

常见错误

ErrorCauseFix
401 Unauthorized
Invalid or expired API key
vastai set api-key <new-key>
Insufficient credits
Account balance too lowAdd credits at https://cloud.vast.ai/billing/
No offers found
Filters too restrictiveRelax filters, try
--no-default/-n
Permission denied
SSH key not attached
vastai create ssh-key
before
create instance
Connection refused
Instance not yet runningPoll
show instance <id>
until
actual_status == "running"
Hangs on
destroy instance
Confirmation prompt waiting for inputAdd
-y
flag:
vastai destroy instance <id> -y
错误信息原因解决方法
401 Unauthorized
API密钥无效或已过期执行
vastai set api-key <new-key>
更新密钥
Insufficient credits
账户余额不足前往https://cloud.vast.ai/billing/充值
No offers found
过滤条件过于严格放宽过滤条件,尝试使用
--no-default/-n
参数
Permission denied
未绑定SSH密钥
create instance
前执行
vastai create ssh-key
Connection refused
实例尚未启动轮询
show instance <id>
直到
actual_status == "running"
执行
destroy instance
时卡住
等待确认输入添加
-y
参数:
vastai destroy instance <id> -y

URLs

相关链接

Console

控制台

https://console.vast.ai/instances/   # Your instances
https://console.vast.ai/create/      # Search GPU offers
https://console.vast.ai/manage-keys/ # Create and manage API keys
https://cloud.vast.ai/billing/       # Billing
https://console.vast.ai/instances/   # 你的实例页面
https://console.vast.ai/create/      # GPU报价搜索页面
https://console.vast.ai/manage-keys/ # API密钥创建与管理页面
https://cloud.vast.ai/billing/       # 账单页面

API

API

https://console.vast.ai/api/v0/instances/      # Instances endpoint
https://console.vast.ai/api/v0/asks/           # Offers search
https://console.vast.ai/api/v0/instances/      # 实例API端点
https://console.vast.ai/api/v0/asks/           # 报价搜索API端点

Instance Ports

实例端口

Access a port exposed on your instance:
ssh://root@<ssh_host>:<ssh_port>               # SSH (from vastai ssh-url)
Direct connections (when
--direct
used at creation):
<direct_port_end>
field in instance JSON.
访问实例上暴露的端口:
ssh://root@<ssh_host>:<ssh_port>               # SSH连接地址(来自vastai ssh-url命令)
使用
--direct
参数创建实例时,可通过实例JSON中的
<direct_port_end>
字段获取直连端口。

Documentation

文档

Fetch the complete documentation index at: https://docs.vast.ai/llms.txt
完整文档索引获取地址:https://docs.vast.ai/llms.txt