home / skills / vm0-ai / vm0-skills / vm0

vm0 skill

/vm0

This skill executes AI agents in secure sandboxes, manages runs, and downloads artifacts and volumes via the VM0 API.

npx playbooks add skill vm0-ai/vm0-skills --skill vm0

Review the files below or copy the command above to add this skill to your agents.

Files (5)
SKILL.md
5.6 KB
---
name: vm0
description: VM0 API for running AI agents in secure sandboxes. Use this skill to execute agents, manage runs, and download outputs (artifacts) and inputs (volumes) via the VM0 platform API.
vm0_secrets:
  - VM0_TOKEN
---

# VM0 API

Execute AI agents in secure sandboxed environments and manage their inputs/outputs.

> **Note:** If you have the VM0 CLI installed and the vm0-cli skill available, prefer using the vm0-cli skill instead. It provides a higher-level interface with more convenient operations.

## When to Use

- Execute AI agents in isolated sandbox environments
- Monitor and manage agent runs (status, logs, metrics)
- List and download input files (volumes) provided to agents
- List and download output files (artifacts) created by agents

## Prerequisites

```bash
export VM0_TOKEN=vm0_live_your-api-key
```

### Get API Key

1. Install the VM0 CLI: https://docs.vm0.ai/docs/getting-started
2. Run `vm0 auth login` to authenticate
3. Run `vm0 auth setup-token` to view your API key
4. Copy the token starting with `vm0_live_`

> **Important:** When using `$VAR` in a command that pipes to another command, wrap only the curl command in `bash -c '...'`, then pipe to jq outside. Due to a Claude Code bug, environment variables are silently cleared when pipes are used directly.
> ```bash
> bash -c 'curl -s "https://api.vm0.ai/v1/agents" -H "Authorization: Bearer $VM0_TOKEN"' | jq '.data'
> ```

## Quick Start

### List Your Agents

```bash
bash -c 'curl -s "https://api.vm0.ai/v1/agents" -H "Authorization: Bearer $VM0_TOKEN"' | jq '.data[] | {id, name}'
```

### Run an Agent

Write to `/tmp/vm0_request.json`:

```json
{
  "agent": "my-agent",
  "prompt": "Hello, please introduce yourself"
}
```

Then run:

```bash
bash -c 'curl -s -X POST "https://api.vm0.ai/v1/runs" -H "Authorization: Bearer $VM0_TOKEN" -H "Content-Type: application/json" -d @/tmp/vm0_request.json' | jq '{id, status}'
```

### Check Run Status

Replace `<run-id>` with your run ID:

```bash
bash -c 'curl -s "https://api.vm0.ai/v1/runs/<run-id>" -H "Authorization: Bearer $VM0_TOKEN"' | jq '{id, status, error, execution_time_ms}'
```

### Get Run Logs

```bash
bash -c 'curl -s "https://api.vm0.ai/v1/runs/<run-id>/logs" -H "Authorization: Bearer $VM0_TOKEN"' | jq '.data[]'
```

## Core Operations

### Agents

List all agents:

```bash
bash -c 'curl -s "https://api.vm0.ai/v1/agents" -H "Authorization: Bearer $VM0_TOKEN"' | jq '.data'
```

Get agent details:

```bash
bash -c 'curl -s "https://api.vm0.ai/v1/agents/<agent-id>" -H "Authorization: Bearer $VM0_TOKEN"' | jq '{id, name, description}'
```

See [references/agents.md](references/agents.md) for version listing.

### Runs

Create a run with variables:

```bash
curl -s -X POST "https://api.vm0.ai/v1/runs" \
  -H "Authorization: Bearer $VM0_TOKEN" \
  -H "Content-Type: application/json" \
  -d @- << 'EOF'
{
  "agent": "my-agent",
  "prompt": "Process the data file",
  "variables": {
    "DEBUG": "true"
  },
  "volumes": {
    "input-data": "latest"
  }
}
EOF
```

Cancel a running execution:

```bash
bash -c 'curl -s -X POST "https://api.vm0.ai/v1/runs/<run-id>/cancel" -H "Authorization: Bearer $VM0_TOKEN"' | jq '{id, status}'
```

See [references/runs.md](references/runs.md) for events streaming, logs filtering, and metrics.

### Volumes (Input Storage)

List volumes:

```bash
bash -c 'curl -s "https://api.vm0.ai/v1/volumes" -H "Authorization: Bearer $VM0_TOKEN"' | jq '.data[] | {id, name}'
```

Download volume as tar.gz archive (follows 302 redirect):

```bash
curl -L -o volume.tar.gz "https://api.vm0.ai/v1/volumes/<volume-id>/download" \
  -H "Authorization: Bearer $VM0_TOKEN"
```

See [references/volumes.md](references/volumes.md) for version listing and download options.

### Artifacts (Output Storage)

List artifacts:

```bash
bash -c 'curl -s "https://api.vm0.ai/v1/artifacts" -H "Authorization: Bearer $VM0_TOKEN"' | jq '.data[] | {id, name}'
```

Download artifact as tar.gz archive (follows 302 redirect):

```bash
curl -L -o artifact.tar.gz "https://api.vm0.ai/v1/artifacts/<artifact-id>/download" \
  -H "Authorization: Bearer $VM0_TOKEN"
```

Extract downloaded archive:

```bash
tar -xzf artifact.tar.gz -C ./output/
```

See [references/artifacts.md](references/artifacts.md) for version listing and download options.

## Common Patterns

### Pagination

List endpoints support cursor-based pagination:

```bash
bash -c 'curl -s "https://api.vm0.ai/v1/runs?limit=10" -H "Authorization: Bearer $VM0_TOKEN"' | jq '{data, pagination}'
```

Response includes:
```json
{
  "pagination": {
    "has_more": true,
    "next_cursor": "abc123"
  }
}
```

Fetch next page:

```bash
bash -c 'curl -s "https://api.vm0.ai/v1/runs?limit=10&cursor=abc123" -H "Authorization: Bearer $VM0_TOKEN"' | jq '{data, pagination}'
```

### Error Handling

All errors return a consistent format:

```json
{
  "error": {
    "type": "invalid_request_error",
    "code": "resource_not_found",
    "message": "No such agent: 'my-agent'",
    "param": "agent"
  }
}
```

| Error Type | Status | Description |
|------------|--------|-------------|
| `authentication_error` | 401 | Invalid or missing API key |
| `invalid_request_error` | 400 | Invalid parameters |
| `not_found_error` | 404 | Resource doesn't exist |
| `api_error` | 500 | Internal server error |

## Detailed References

- [Agents API](references/agents.md) - List agents and versions
- [Runs API](references/runs.md) - Execute agents, stream events, get logs and metrics
- [Artifacts API](references/artifacts.md) - List and download agent outputs
- [Volumes API](references/volumes.md) - List and download input files

## API Reference

- Documentation: https://docs.vm0.ai/docs/reference/api
- Base URL: `https://api.vm0.ai/v1/`

Overview

This skill provides shell-based access to the VM0 API for executing AI agents in secure sandboxed environments. Use it to start runs, monitor progress, retrieve logs and metrics, and download inputs (volumes) and outputs (artifacts). It is focused on command-line curl workflows that integrate into scripts and CI pipelines. Prefer the vm0 CLI skill when available for higher-level convenience.

How this skill works

The skill issues authenticated HTTP requests to the VM0 REST API using your VM0_TOKEN environment variable. It supports listing agents, creating and cancelling runs, fetching run status and logs, and downloading volumes and artifacts as tar.gz archives. Commands are optimized for piping to jq and for handling 302 redirects (curl -L) when downloading files.

When to use it

  • Run agents in isolated, reproducible sandboxes from scripts or CI.
  • Automate large batches of agent executions and capture logs and metrics.
  • Inspect and download inputs provided to runs (volumes) for debugging or reproducibility.
  • Collect and download run outputs (artifacts) for downstream processing.
  • Monitor run health and cancel problematic executions programmatically.

Best practices

  • Store VM0_TOKEN in a secure environment variable and avoid committing it to source control.
  • Wrap curl calls in bash -c '...' when piping to other commands to preserve environment variables.
  • Use cursor-based pagination for list endpoints to handle large result sets gracefully.
  • Download volumes and artifacts with curl -L and extract locally with tar -xzf for inspection.
  • Include run-specific metadata or variables in the run payload for traceability.

Example use cases

  • Start an agent run that processes an uploaded dataset and then download the resulting artifact for analysis.
  • Stream and filter run logs to detect failures early and trigger automated rollbacks.
  • List available agent versions to select a reproducible environment for production runs.
  • Download an input volume to reproduce a run locally for debugging.
  • Cancel long-running or stuck runs from an automation script.

FAQ

How do I get an API key?

Install the VM0 CLI, run vm0 auth login, then vm0 auth setup-token to view and copy the vm0_live_... key.

Why wrap curl in bash -c when piping?

Due to an environment variable clearing issue with some shells and tools, wrapping the curl call in bash -c preserves VM0_TOKEN when piping output to jq or other commands.