Skip to content
arvm
Docs menu

For agents

An AI agent uses arvm the way any program does: an API key, the HTTP API, and a machine it can run anything on. This page is for the person who sets the agent up, and for the agent that reads it.

Read the docs as Markdown

  • llms.txt lists every page of this documentation with a one-line description.
  • Every page is served as Markdown at its own path with .md at the end. An agent can fetch docs/machines.md and get Markdown, with no HTML to strip.
  • The API reference is generated from the OpenAPI document, so it does not drift from the API. Each operation has a curl example built from the document’s own example values. Put your own machine’s ID or name in place of the example’s.

Give the agent a key

Create a key for the agent alone, with an expiry. This key expires after 24 hours:

Terminal
$ curl -s -X POST "https://api.arvm.dev/v1/api-keys" \
    -H "Authorization: Bearer $ARVM_API_KEY" \
    -H "Idempotency-Key: $(uuidgen)" \
    -H "Content-Type: application/json" \
    -d '{"name": "agent-run-42", "expires_in_seconds": 86400}'

Know what the key can do before you hand it over. A full key (the default) has full power in its org: it can create and delete machines and snapshots, run commands, read files, and create more keys. A read_only key can inspect machines, events, metrics and billing, without changing anything or reading env values or signed endpoint links (Read-only keys). Neither kind of key can spend money by itself: subscribing, topping up and enabling auto top-up each require a signed-in person in the dashboard, and usage can never take the balance below zero.

So the most an agent with a key can cost you is the balance you have, and the most it can destroy is the machines and snapshots in the org. If that is too much, give the agent its own account.

The loop an agent runs

  1. Create a machine and wait for it. Send a new Idempotency-Key. If the request fails with a network error, send it again with the same key.

    Terminal
    $ curl -s -X POST "https://api.arvm.dev/v1/machines?wait=running&timeout=120" \
        -H "Authorization: Bearer $ARVM_API_KEY" \
        -H "Idempotency-Key: $(uuidgen)" \
        -H "Content-Type: application/json" \
        -d '{"size": "default", "labels": {"owner": "agent-run-42"}}'
    

    Read id, phase and desired from the response. If phase is not running yet and desired is still running, get the machine again with ?wait=running. Stop asking when phase is deleted or desired is no longer running: the machine will not run. When the platform stopped it, its stop says why, and a failure is one of the reasons. A phase of failed while desired is still running is a start after a failure, on its way.

  2. Run commands. command is a list of arguments. Check exit_code, timed_out and truncated in each result. A 200 means the command ran. machine_unreachable means it did not, and exec_outcome_unknown means whether it ran is unknown: see the table below.

    Terminal
    $ curl -s -X POST "https://api.arvm.dev/v1/machines/m_01jcz3k8x0e5v9w2r4t6y8a0bq/exec" \
        -H "Authorization: Bearer $ARVM_API_KEY" \
        -H "Content-Type: application/json" \
        -d '{"command": ["sh", "-c", "git clone https://github.com/example/app /home/dev/app && cd /home/dev/app && make test"], "timeout_seconds": 1800}'
    
  3. Move files with the file operations. Run commands and move files has each call.

  4. Stop or delete the machine when the work is done. A stopped machine costs nothing and keeps its disk. A deleted machine is gone.

    Terminal
    $ curl -s -X DELETE "https://api.arvm.dev/v1/machines/m_01jcz3k8x0e5v9w2r4t6y8a0bq" \
        -H "Authorization: Bearer $ARVM_API_KEY"
    

Use the machine’s ID, not its name, in a program. The ID never changes.

What an agent should know about the machine

  • It is a full Linux virtual machine: Ubuntu 24.04, systemd, Docker, and sudo with no password for the user dev. Commands run as dev unless the request sets user.
  • A command is killed at its timeout_seconds. The default is 30 seconds and the most is 3,600.
  • A process that a command leaves running is killed when the command exits. nohup and & do not keep a job alive, and the response still shows an exit_code of 0. For longer work, start the job with sudo systemd-run and ask systemctl is-active for its state. Run a job that outlives the request shows how, and the CLI’s arvm job start does it for you.
  • Each of stdout and stderr is cut at 8 MiB. Write large output to a file and read the file.
  • The machine is stopped after 60 minutes with no API command, SSH session or endpoint request and with CPU utilization below the idle threshold. A background job that sleeps or waits on I/O can still be stopped, so turn idle stop off for long jobs and delete the machine afterwards.
  • Outbound TCP port 25 is blocked.
  • The acceptable use policy applies to what the agent runs. The account holder answers for it.

Errors an agent must handle

Code Status What the agent does
insufficient_balance 402 Stop and tell the person. Only a person can add money.
limit_exceeded 403 Delete or stop machines the agent created, then try again.
name_taken 409 Leave name out, and the API generates a name.
machine_not_running 409 Start the machine, wait for running, then try again.
rate_limited 429 Wait for the seconds in Retry-After.
no_capacity 503 Wait for Retry-After, then try again. Do not loop without a pause.
machine_unreachable 503 Try again after a pause. From exec, the command did not run.
exec_outcome_unknown 502 Whether the command ran is unknown: no sign that it started came back, or the connection to it was lost. It may not have started, may have run, or may still be running. Check what it changes (a file, a process, a deploy) before you run it again.
internal 500 Try again with the same Idempotency-Key.

Switch on code, never on the text of title or detail.

Clean up

A machine that an agent forgets keeps using the balance until idle stop ends it, and it stays in the org’s list of machines until it is deleted. Label every machine the agent creates, and delete by label when a run ends:

Terminal
$ curl -s "https://api.arvm.dev/v1/machines?label=owner=agent-run-42" \
    -H "Authorization: Bearer $ARVM_API_KEY"

Delete each machine in the response’s data by its id.

An agent that uses the CLI

The CLI carries its own instructions for an agent. Print them into the AGENTS.md of a repository whose agent may use arvm:

Terminal
$ arvm agent-instructions

The page it prints is written for the installed version of the CLI: its commands, its JSON output, its exit codes, and what a command does when nobody is there to answer a question. This documentation does not repeat it. An agent needs ARVM_API_KEY in its environment and no arvm login.

For multi-worktree coding agents, arvm init scaffolds an arvm.toml manifest, arvm dev boots and binds a VM to the current git worktree, arvm exec -- wakes sleeping boxes over ?wake=true, arvm browser drives headless Chromium over CDP, and arvm proxy start (arvmd) exposes bound boxes at http://box-<id>.localhost:<port>. Concurrency scales across Free (2 parallel default VMs), Pro (10 parallel), Max (50 parallel) and Ultra (250 parallel).

Four additional commands exist for agents in particular:

  • arvm context answers in one call what an agent reads before it creates a machine: the machines it can reuse, the ready snapshots, the balance, the plan’s limits and a recommended size.
  • arvm job start, status, logs and stop run a command that outlives the request, as a systemd unit in the machine.
  • arvm sync copies a directory into a machine in one upload, without .git, node_modules or target.
  • arvm mcp serves the CLI’s commands to the agent as Model Context Protocol tools.

An agent that speaks MCP

Claude Code, Codex, OpenCode, Pi, Antigravity and Cursor can each start arvm mcp as an MCP server. Its tools are arvm_context, arvm_new, arvm_exec, arvm_job, arvm_files, arvm_sync, arvm_expose, arvm_snapshot, arvm_stop and arvm_rm. Each runs one CLI command with --json, so a failed call returns the CLI’s error code and hint. Print the line that adds the server to each harness on this computer:

Terminal
$ arvm skill setup --mcp

The server reads ARVM_API_KEY from the environment the harness starts it with.

A snippet for AGENTS.md, for an agent that uses the API

Paste this into the AGENTS.md of a repository whose agent calls the API itself. It assumes ARVM_API_KEY is set in the agent’s environment.

markdown
## Machines on arvm

You can create Linux virtual machines on arvm for work that should not run on this computer: builds, tests, anything that needs Docker or root.

- Docs for agents: https://arvm.dev/llms.txt. Every docs page is Markdown at its URL plus `.md`.
- API base URL: https://api.arvm.dev. Send `Authorization: Bearer $ARVM_API_KEY`.
- Create: `POST /v1/machines?wait=running` with a new `Idempotency-Key` header and the body `{"size": "default", "labels": {"owner": "<this run>"}}`. Keep the `id` from the response.
- Run a command: `POST /v1/machines/{id}/exec` with `{"command": ["sh", "-c", "<line>"], "timeout_seconds": 600}`. Check `exit_code`. A command is killed at its timeout, at most 3600 seconds.
- A process that a command leaves running is killed when the command exits. Do not use `nohup` or `&`. For a job longer than an hour, send `{"command": ["sudo", "systemd-run", "--unit=<name>", "--uid=dev", "--gid=dev", "sh", "-c", "(<line>) > /home/dev/<name>.log 2>&1"]}`. Then poll `{"command": ["systemctl", "is-active", "<name>"]}` and read `stdout`: `active` means running, `inactive` means it ended with status 0, and `failed` means it failed. Before you start the job, send `PATCH /v1/machines/{id}` with `{"idle_timeout_seconds": null}`, or idle stop can end the job.
- Files: `PUT` and `GET /v1/machines/{id}/files?path=<absolute path>`.
- The machine is Ubuntu 24.04 with systemd and Docker. You are the user `dev` and `sudo` needs no password.
- When you finish, delete every machine you created: `DELETE /v1/machines/{id}`. A machine left running costs money.
- If a response has the code `insufficient_balance`, stop and tell the user. Do not retry.
- If a response has the code `no_capacity` or `rate_limited`, wait for the `Retry-After` seconds before you try again.
- Do not run cryptocurrency miners, port scans, proxies for other people, or anything that sends bulk email. The account is suspended for these.