vastai-api

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Vastai-Api Skill

Vastai-Api 技能文档

Comprehensive assistance with the Vast.ai API for managing GPU instances, machine operations, and automating AI/ML workflows. This skill provides access to official documentation for programmatically controlling the Vast.ai platform.
为管理GPU实例、机器操作以及自动化AI/ML工作流提供全面的Vast.ai API使用指导。本技能文档包含用于程序化控制Vast.ai平台的官方文档内容。

When to Use This Skill

何时使用本技能文档

This skill should be triggered when working with:
  • GPU Instance Management: Creating, destroying, starting, stopping, or managing GPU instances
  • Machine Operations: Listing machines for rent, setting pricing, managing maintenance windows
  • SSH & Authentication: Managing SSH keys, API keys, and secure connections to instances
  • Billing & Credits: Viewing invoices, earnings, deposits, or transferring credits
  • Network Volumes: Creating, listing, or managing network storage volumes
  • Serverless Endpoints: Working with Vast.ai serverless workergroups and endpoints
  • Data Transfer: Copying data between instances or cloud services
  • Account Management: Managing subaccounts, environment variables, or team roles
  • CLI Operations: Using the
    vastai
    command-line tool
  • API Integration: Building applications that integrate with Vast.ai's REST API
在处理以下场景时可使用本技能文档:
  • GPU实例管理:创建、销毁、启动、停止或管理GPU实例
  • 机器操作:列出可出租机器、设置定价、管理维护窗口
  • SSH与身份验证:管理SSH密钥、API密钥以及与实例的安全连接
  • 账单与信用额度:查看发票、收益、存款或转账信用额度
  • 网络卷:创建、列出或管理网络存储卷
  • 无服务器端点:使用Vast.ai无服务器工作组和端点
  • 数据传输:在实例之间或与云服务之间复制数据
  • 账户管理:管理子账户、环境变量或团队角色
  • CLI操作:使用
    vastai
    命令行工具
  • API集成:构建与Vast.ai REST API集成的应用

Quick Reference

快速参考

Creating and Managing Instances

创建与管理实例

Create a New GPU Instance

创建新的GPU实例

bash
undefined
bash
undefined

Create instance from an offer

Create instance from an offer

vastai create instance <offer_id>
--image pytorch/pytorch:latest
--disk 50
--ssh
undefined
vastai create instance <offer_id>
--image pytorch/pytorch:latest
--disk 50
--ssh
undefined

List Your Active Instances

列出您的活跃实例

bash
undefined
bash
undefined

Show all instances

Show all instances

vastai show instances
vastai show instances

Show specific instance details

Show specific instance details

vastai show instance <instance_id>
undefined
vastai show instance <instance_id>
undefined

Manage Instance State

管理实例状态

bash
undefined
bash
undefined

Stop an instance (pause GPU billing, storage still charged)

Stop an instance (pause GPU billing, storage still charged)

vastai stop instance <instance_id>
vastai stop instance <instance_id>

Start a stopped instance

Start a stopped instance

vastai start instance <instance_id>
vastai start instance <instance_id>

Reboot instance without losing GPU priority

Reboot instance without losing GPU priority

vastai reboot instance <instance_id>
vastai reboot instance <instance_id>

Destroy instance permanently (irreversible)

Destroy instance permanently (irreversible)

vastai destroy instance <instance_id>
undefined
vastai destroy instance <instance_id>
undefined

SSH Key Management

SSH密钥管理

Add SSH Key to Account

为账户添加SSH密钥

bash
undefined
bash
undefined

Add your public SSH key

Add your public SSH key

vastai create ssh-key "ssh-rsa AAAAB3NzaC1yc2EA... user@host"
vastai create ssh-key "ssh-rsa AAAAB3NzaC1yc2EA... user@host"

List all SSH keys

List all SSH keys

vastai show ssh-keys
vastai show ssh-keys

Attach SSH key to specific instance

Attach SSH key to specific instance

vastai attach ssh <instance_id> <ssh_key>
undefined
vastai attach ssh <instance_id> <ssh_key>
undefined

Search and Filter Offers

搜索与筛选报价

Search for GPU Offers

搜索GPU报价

bash
undefined
bash
undefined

Search with filters

Search with filters

vastai search offers
--gpu_name RTX_4090
--num_gpus 2
--disk_space 100
vastai search offers
--gpu_name RTX_4090
--num_gpus 2
--disk_space 100

Order by price

Order by price

vastai search offers --order dph_total
undefined
vastai search offers --order dph_total
undefined

Environment Variables (Secrets)

环境变量(机密信息)

Manage Environment Variables

管理环境变量

bash
undefined
bash
undefined

Create encrypted environment variable

Create encrypted environment variable

vastai create env-var MY_API_KEY "secret_value_here"
vastai create env-var MY_API_KEY "secret_value_here"

List all environment variables

List all environment variables

vastai show env-vars
vastai show env-vars

Update existing variable

Update existing variable

vastai update env-var MY_API_KEY "new_secret_value"
vastai update env-var MY_API_KEY "new_secret_value"

Delete environment variable

Delete environment variable

vastai delete env-var MY_API_KEY
undefined
vastai delete env-var MY_API_KEY
undefined

Billing and Credits

账单与信用额度

View Billing Information

查看账单信息

bash
undefined
bash
undefined

Show invoices

Show invoices

vastai show invoices
vastai show invoices

Show earnings (for hosts)

Show earnings (for hosts)

vastai show earnings
vastai show earnings

Show deposit for specific instance

Show deposit for specific instance

vastai show deposit <instance_id>
vastai show deposit <instance_id>

Transfer credits to another user

Transfer credits to another user

vastai transfer credit recipient@email.com 25.00
undefined
vastai transfer credit recipient@email.com 25.00
undefined

Instance Logs

实例日志

Retrieve Container Logs

获取容器日志

bash
undefined
bash
undefined

Get last 100 lines of logs

Get last 100 lines of logs

vastai show logs <instance_id> --tail 100
vastai show logs <instance_id> --tail 100

Filter logs with grep pattern

Filter logs with grep pattern

vastai show logs <instance_id> --filter "error"
vastai show logs <instance_id> --filter "error"

Get daemon system logs

Get daemon system logs

vastai show logs <instance_id> --daemon-logs
undefined
vastai show logs <instance_id> --daemon-logs
undefined

Data Transfer Operations

数据传输操作

Copy Between Instances

在实例之间复制数据

bash
undefined
bash
undefined

Copy from one instance to another

Copy from one instance to another

vastai copy <src_id> <dst_id> /source/path /destination/path
vastai copy <src_id> <dst_id> /source/path /destination/path

Cloud copy using rclone

Cloud copy using rclone

vastai cloud copy <instance_id> remote:bucket/path /local/path
undefined
vastai cloud copy <instance_id> remote:bucket/path /local/path
undefined

Machine Management (for Hosts)

机器管理(针对主机方)

List Your Machine for Rent

列出可出租的机器

bash
undefined
bash
undefined

List machine with pricing

List machine with pricing

vastai list machine <machine_id>
--price_gpu 0.50
--price_disk 0.10
vastai list machine <machine_id>
--price_gpu 0.50
--price_disk 0.10

Unlist machine (stop renting)

Unlist machine (stop renting)

vastai unlist machine <machine_id>
vastai unlist machine <machine_id>

Schedule maintenance window

Schedule maintenance window

vastai schedule maint <machine_id>
--sdate "2025-11-01T10:00:00"
--duration 3600
undefined
vastai schedule maint <machine_id>
--sdate "2025-11-01T10:00:00"
--duration 3600
undefined

Key Concepts

核心概念

Instance Types

实例类型

  • On-Demand Instances: Pay-as-you-go GPU instances you create and manage
  • Interruptible Instances: Lower-cost instances that can be reclaimed by hosts
  • Reserved Instances: Pre-paid instances with usage discounts (up to 40%)
  • 按需实例:您创建和管理的按需付费GPU实例
  • 可中断实例:成本更低,但可能被主机方收回的实例
  • 预留实例:预付费实例,可享受使用折扣(最高40%)

Pricing Model

定价模型

  • GPU Pricing: Charged per hour while instance is running
  • Storage Pricing: Charged for disk space even when instance is stopped
  • Network Transfer: Upload/download bandwidth costs
  • Discounts: Available through prepayment on reserved instances
  • GPU定价:实例运行时按小时计费
  • 存储定价:即使实例停止,仍会对磁盘空间计费
  • 网络传输:上传/下载带宽费用
  • 折扣:通过预留实例预付费可享受折扣

Instance States

实例状态

  • starting
    : Instance is initializing
  • running
    : Instance is active and billable
  • stopped
    : Container stopped (storage still billable)
  • exited
    : Container exited or failed
  • rebooting
    : In process of restarting
  • recycling
    : Being destroyed and recreated from fresh image
  • starting
    :实例正在初始化
  • running
    :实例处于活跃状态并计费
  • stopped
    :容器已停止(仍对存储计费)
  • exited
    :容器已退出或运行失败
  • rebooting
    :正在重启过程中
  • recycling
    :正在销毁并从全新镜像重新创建

Authentication

身份验证

  • API Keys: Used for programmatic access via REST API
  • SSH Keys: For secure shell access to running instances
  • Environment Variables: Encrypted secrets injected into containers
  • API密钥:用于通过REST API进行程序化访问
  • SSH密钥:用于安全连接到运行中的实例
  • 环境变量:注入到容器中的加密机密信息

Templates

模板

Pre-configured setups containing:
  • Docker image specifications
  • Environment variables
  • Onstart scripts
  • Resource requirements
  • Port mappings
Popular templates include PyTorch, TensorFlow, Jupyter, ComfyUI, and Stable Diffusion.
预配置的环境设置,包含:
  • Docker镜像规格
  • 环境变量
  • 启动脚本
  • 资源需求
  • 端口映射
热门模板包括PyTorch、TensorFlow、Jupyter、ComfyUI和Stable Diffusion。

Network Volumes

网络卷

Shared network storage that can be:
  • Attached to multiple instances
  • Persisted independently of instance lifecycle
  • Used for datasets and model weights
  • Scaled independently
可共享的网络存储,具备以下特性:
  • 可附加到多个实例
  • 独立于实例生命周期持久化
  • 可用于存储数据集和模型权重
  • 可独立扩展

Serverless Architecture

无服务器架构

  • Endpoints: Top-level routing and configuration
  • Workergroups: Pools of GPU instances that autoscale
  • Test Workers: Exploration phase for performance profiling
  • Target Utilization: Controls scaling behavior
  • 端点:顶层路由与配置
  • 工作组:可自动扩缩容的GPU实例池
  • 测试工作节点:用于性能分析的探索阶段
  • 目标利用率:控制扩缩容行为

Reference Files

参考文档

This skill includes comprehensive documentation in
references/
:
本技能文档包含
references/
目录下的完整文档:

llms-full.md

llms-full.md

Complete API reference with all endpoints organized by category:
  • Accounts: API keys, SSH keys, user management, subaccounts
  • Billing: Invoices, earnings, deposits, credit transfers
  • Instances: Create, manage, destroy, reboot, logs, SSH
  • Machines: List for rent, pricing, maintenance, default jobs
  • Network Volumes: Create, list, manage shared storage
  • Search: Find offers, benchmarks, filter GPU availability
  • Serverless: Endpoints, workergroups, autoscaling configuration
Each endpoint includes:
  • HTTP method and path
  • Detailed description
  • CLI usage examples
  • Parameter specifications
  • Source documentation links
完整的API参考文档,所有端点按类别组织:
  • 账户:API密钥、SSH密钥、用户管理、子账户
  • 账单:发票、收益、存款、信用额度转账
  • 实例:创建、管理、销毁、重启、日志、SSH
  • 机器:列出可出租机器、定价、维护、默认任务
  • 网络卷:创建、列出、管理共享存储
  • 搜索:查找报价、基准测试、筛选GPU可用性
  • 无服务器:端点、工作组、自动扩缩容配置
每个端点包含:
  • HTTP方法与路径
  • 详细描述
  • CLI使用示例
  • 参数说明
  • 源文档链接

llms-txt.md

llms-txt.md

Focused documentation covering:
  • Serverless workergroup parameters and configuration
  • Endpoint management
  • QuickStart guide with setup instructions
  • Common questions and answers
  • Schema.org structured data for better searchability
聚焦于以下内容的文档:
  • 无服务器工作组参数与配置
  • 端点管理
  • 包含设置说明的快速入门指南
  • 常见问题与解答
  • 用于提升搜索可见性的Schema.org结构化数据

llms.md

llms.md

Curated list of all API operations with brief descriptions and CLI examples, organized by category for quick lookup.
按类别组织的所有API操作精选列表,包含简要描述和CLI示例,便于快速查阅。

Working with This Skill

使用本技能文档的指南

For Beginners

面向初学者

Start here:
  1. Review the QuickStart section in
    llms-txt.md
  2. Follow the 4-step setup process (signup, add credit, prepare SSH, create instance)
  3. Try the basic examples in Quick Reference above
  4. Learn about instance states and pricing model in Key Concepts
First tasks to try:
  • Create an API key for authentication
  • Add your SSH public key to your account
  • Search for available GPU offers
  • Create your first instance with a template
入门步骤:
  1. 查看
    llms-txt.md
    中的快速入门部分
  2. 遵循4步设置流程(注册、添加信用额度、准备SSH、创建实例)
  3. 尝试上述快速参考中的基础示例
  4. 学习核心概念中的实例状态与定价模型
推荐首次尝试的任务:
  • 创建用于身份验证的API密钥
  • 将您的SSH公钥添加到账户
  • 搜索可用的GPU报价
  • 使用模板创建您的首个实例

For Intermediate Users

面向中级用户

Focus on:
  • Environment variable management for secrets
  • Data transfer between instances and cloud storage
  • Instance lifecycle management (stop/start/reboot vs destroy)
  • Billing optimization with reserved instances
  • Custom template creation for your workflows
Useful patterns:
  • Set up auto-billing to avoid instance interruptions
  • Use environment variables for API keys and credentials
  • Schedule regular backups with copy commands
  • Monitor costs with invoice and earnings endpoints
重点关注:
  • 机密信息的环境变量管理
  • 实例与云存储之间的数据传输
  • 实例生命周期管理(停止/启动/重启 vs 销毁)
  • 使用预留实例优化账单成本
  • 为您的工作流创建自定义模板
实用模式:
  • 设置自动账单以避免实例中断
  • 使用环境变量存储API密钥和凭证
  • 使用复制命令定期备份数据
  • 通过发票和收益端点监控成本

For Advanced Users

面向高级用户

Advanced topics:
  • Serverless endpoint and workergroup configuration
  • Machine hosting and marketplace optimization
  • Network volume architecture for shared datasets
  • Team and subaccount management
  • API integration in custom applications
  • Automated scaling strategies
Power user tips:
  • Use filter operators in search (eq, neq, gt, lt, gte, lte, in, nin)
  • Leverage launch_args for advanced instance customization
  • Implement monitoring and alerting via logs API
  • Optimize costs with bid price adjustments
  • Build workflows with cloud copy for data pipelines
高级主题:
  • 无服务器端点与工作组配置
  • 机器托管与市场优化
  • 用于共享数据集的网络卷架构
  • 团队与子账户管理
  • 在自定义应用中集成API
  • 自动化扩缩容策略
高级用户技巧:
  • 在搜索中使用过滤运算符(eq、neq、gt、lt、gte、lte、in、nin)
  • 利用launch_args进行高级实例自定义
  • 通过日志API实现监控与告警
  • 通过调整竞价价格优化成本
  • 使用云复制命令构建数据管道工作流

Navigation Tips

导航技巧

Finding API endpoints:
  • All endpoints documented in
    llms-full.md
    with full details
  • Organized by category (accounts, billing, instances, machines, etc.)
  • Each includes CLI usage examples
Quick lookups:
  • llms.md
    provides condensed list of all operations
  • Use browser search (Ctrl+F) to find specific commands
  • Look for "CLI Usage:" sections for command syntax
Understanding concepts:
  • Key Concepts section above for terminology
  • QuickStart in
    llms-txt.md
    for getting started
  • Workergroup Parameters section for serverless configuration
查找API端点:
  • 所有端点的完整详情记录在
    llms-full.md
  • 按类别组织(账户、账单、实例、机器等)
  • 每个端点都包含CLI使用示例
快速查阅:
  • llms.md
    提供了所有操作的精简列表
  • 使用浏览器搜索(Ctrl+F)查找特定命令
  • 查找“CLI Usage:”部分获取命令语法
理解概念:
  • 核心概念部分包含术语解释
  • llms-txt.md
    中的快速入门指南帮助您上手
  • 工作组参数部分介绍无服务器配置

Common Workflows

常见工作流

Setting Up a New Development Environment

设置新的开发环境

  1. Create API key with appropriate permissions
  2. Add SSH key to account for access
  3. Create environment variables for secrets
  4. Search for GPU offers matching requirements
  5. Create instance from template
  6. Connect via SSH and verify setup
  1. 创建具备适当权限的API密钥
  2. 为账户添加SSH密钥以实现访问
  3. 创建用于存储机密信息的环境变量
  4. 搜索符合需求的GPU报价
  5. 使用模板创建实例
  6. 通过SSH连接并验证环境设置

Managing Long-Running Training Jobs

管理长期运行的训练任务

  1. Create instance with sufficient disk space
  2. Set up auto-billing to prevent interruptions
  3. Use reserved instance with prepayment for discounts
  4. Monitor with logs endpoint
  5. Copy model checkpoints to cloud storage
  6. Stop (not destroy) when paused to save costs
  1. 创建具备足够磁盘空间的实例
  2. 设置自动账单以防止中断
  3. 使用预付费预留实例享受折扣
  4. 通过日志端点监控任务
  5. 将模型检查点复制到云存储
  6. 暂停时停止(而非销毁)实例以节省成本

Hosting Machines for Profit

托管机器获取收益

  1. Set machine pricing with list command
  2. Define minimum bid thresholds
  3. Configure default jobs for background work
  4. Schedule maintenance windows when needed
  5. Monitor earnings and clean up expired contracts
  6. Adjust pricing based on market conditions
  1. 使用list命令设置机器定价
  2. 定义最低竞价阈值
  3. 配置用于后台任务的默认作业
  4. 在需要时安排维护窗口
  5. 监控收益并清理过期合约
  6. 根据市场情况调整定价

Best Practices

最佳实践

Cost Management

成本管理

  • Destroy vs Stop: Use stop for short pauses, destroy for long breaks
  • Disk Space: Choose carefully - cannot be changed later
  • Reserved Instances: Prepay for 40% discount on long-running work
  • Auto-billing: Set threshold above daily spend to prevent interruptions
  • Low Balance Alerts: Enable email notifications as backup
  • 销毁 vs 停止:短期暂停使用停止,长期闲置使用销毁
  • 磁盘空间:谨慎选择,后续无法更改
  • 预留实例:预付费长期运行工作负载可享受40%折扣
  • 自动账单:设置高于每日支出的阈值以避免中断
  • 低余额告警:启用邮件通知作为备份

Security

安全

  • API Keys: Use permission scoping, rotate regularly
  • SSH Keys: Use different keys for different purposes
  • Environment Variables: Store secrets as encrypted env vars
  • Subaccounts: Use for team members with restricted access
  • API密钥:使用权限范围限制,定期轮换
  • SSH密钥:为不同用途使用不同密钥
  • 环境变量:将机密信息存储为加密环境变量
  • 子账户:为团队成员创建受限访问的子账户

Performance

性能

  • Template Caching: Pre-pulled images start much faster (seconds vs minutes)
  • Network Volumes: Use for large datasets shared across instances
  • Bid Pricing: Higher bids get better hardware availability
  • Test Workers: Let serverless explore before scaling
  • 模板缓存:预拉取的镜像启动速度更快(秒级 vs 分钟级)
  • 网络卷:用于在多个实例之间共享大型数据集
  • 竞价价格:更高的竞价可获得更好的硬件可用性
  • 测试工作节点:让无服务器架构先探索再扩缩容

Reliability

可靠性

  • Logs: Monitor regularly for errors
  • Health Checks: Implement in your applications
  • Data Backup: Copy critical data off instances regularly
  • Redundancy: For critical work, run on multiple instances
  • 日志:定期监控以排查错误
  • 健康检查:在您的应用中实现健康检查
  • 数据备份:定期将关键数据复制到实例外
  • 冗余:对于关键工作负载,在多个实例上运行

Resources

资源

Official Links

官方链接

Support

支持

  • Minimum deposit: $5
  • Balance shown at top right of dashboard
  • Email verification required to rent or create teams
  • Auto-billing prevents interruptions when configured
  • 最低存款:5美元
  • 余额显示在控制台右上角
  • 出租机器或创建团队需要验证邮箱
  • 配置自动账单可防止实例中断

Notes

说明

  • This skill was automatically generated from official Vast.ai documentation
  • Reference files preserve structure and examples from source docs
  • CLI examples use the
    vastai
    command-line tool
  • API endpoints support both REST API and CLI access
  • All prices in USD, billed per hour for compute and storage
  • 本技能文档由Vast.ai官方文档自动生成
  • 参考文档保留了源文档的结构和示例
  • CLI示例使用
    vastai
    命令行工具
  • API端点同时支持REST API和CLI访问
  • 所有价格以美元计价,计算资源和存储按小时计费

Updating

更新

To refresh this skill with updated documentation:
  1. Re-run the scraper with the same configuration
  2. The skill will be rebuilt with the latest API information
  3. Check for API version changes or deprecated endpoints
如需使用最新文档更新本技能:
  1. 使用相同配置重新运行抓取工具
  2. 技能文档将使用最新API信息重建
  3. 检查API版本变更或已弃用的端点