Local API and smolvm serve

smolvm serve exposes local machine operations over HTTP. Use it for integrations that need a long-running local REST endpoint or already depend on the older smolvm-sdk client.

For new Node.js and Python applications, use the embedded smolmachines SDK instead. It runs the local engine in-process and can use the same Machine API with smol cloud. It does not require smolvm serve.

Start the local server

Listen on loopback:

smolvm serve start --listen 127.0.0.1:8080

Or listen on a Unix socket, which is the default: smolvm serve start with no --listen uses $XDG_RUNTIME_DIR/smolvm.sock on Linux when that variable is set, and /tmp/smolvm.sock otherwise, including on macOS. To name another path:

smolvm serve start --listen unix:///path/to/smolvm.sock

Generate the OpenAPI specification for the installed version:

smolvm serve openapi

One server to a host, unless you move a second port

Every smolvm serve also binds a guest ingress port, 127.0.0.1:10081 by default, which --listen does not move. A second server on the same host therefore fails at start whatever address it was given:

Error: config operation failed: bind guest rollout ingress: 127.0.0.1:10081: Address already in use

Give the second server its own port with --guest-rollout-port PORT, or SMOLVM_GUEST_ROLLOUT_HOST_PORT, and the two run side by side. A running machine keeps the port it started with.

Operator flags

FlagWhat it does
--cache-disk-dir DIRDirectory of cache disk bases the API may attach, named by file name in cacheDisk on create and never by path. POST /api/v1/machines/:name/cache-disk/publish writes a stopped machine’s cache, base and writes together, into it as a new base under a new name. Unset, the API refuses cache disks
--cache-disk-max-gb GiBMost the bases in --cache-disk-dir, which it requires, may hold: past it the least recently used unattached bases are removed and fetched again when needed. Half that directory’s filesystem by default, and a tenth of the filesystem is always kept free
--insecure-no-authFrom v1.38.0, serve a --listen address that is not loopback with no authentication, which is otherwise refused unless mutual TLS is configured; the server prints a warning at every start
--allow-nested-virtPermit machines created with nestedVirt. Off by default, because it exposes the host kernel’s nested virtualization to the guest; turning it off again also stops existing nested machines from starting
--egress-watchlist PATHRecord guest traffic to destinations named in a file of <label> dns-sha256:<hex> or <label> ip-sha256:<hex> lines, and block it on a line that ends in block: a matching lookup is answered as nonexistent and a matching connection is dropped. Matches come back as egressSignals on the machine, the file is re-read when it changes, and it applies to virtio-net machines. A TLS server name is matched like a DNS name, and a stratum login is recorded as the signal stratum
--shutdown-grace SECSSeconds in-flight requests get once the server stops accepting connections, five by default and capped at 3600. Connections are refused for the whole grace, so to restart without cutting off a long exec, wait for GET /inflight on the loopback door to report nothing in flight
--mtls-client-cn CNRequire this subject CN on the mTLS client certificate. Only applies when serve TLS is configured; unset, every certificate the client CA signed is accepted for every route
--mtls-allow-peer-blobsWith --mtls-client-cn, also accept other certificates the client CA signed, but only on the peer blob routes under /p2p/, for sibling hosts that fetch cached layers from this one
--local-image-dir DIRDirectory of local images the API may create machines from: docker save or OCI archives and unpacked rootfs directories. A request’s image path must resolve inside it; unset, the API accepts registry images only
--restore-cache-entries NRestored checkpoints kept extracted after their machines are gone, so restoring one again reuses it; 32 by default, 0 keeps none
--restore-cache-gib GiBSpace those kept checkpoints may hold together, 256 GiB by default
--lazy-disksFrom v1.37.0, boot a restored machine before its disks are copied: each disk is read from the checkpoint store as the guest touches it and filled in the background. Needs the libkrun bundled with this smolvm
--lazy-ramFrom v1.37.0, with --lazy-disks, also rebuild a restored machine’s RAM from the checkpoint store as the guest touches it, on a Linux host that runs each VM as its own user; on macOS it changes nothing, and without --lazy-disks the server does not start. Off by default, because each such machine holds its own copy of the checkpoint’s RAM that the host cannot evict, where an ordinary restore shares one the page cache can drop
--prepared-checkpoint-cache-gib GiBSpace for captured checkpoints kept on this host, so restoring one here skips the download; 64 GiB by default, and SMOLVM_PREPARED_CHECKPOINT_CACHE_MAX_BYTES takes precedence when set
--cors-origin ORIGINAn origin whose web pages may call the API, repeatable; localhost:8080 and localhost:3000 by default, and naming one replaces both. From v1.36.0 a request from any other page’s origin answers 403, and a loopback listener answers only a Host that is localhost, an IP address or a --cors-origin host, so a client or proxy that reaches it under another name, such as host.docker.internal, needs --cors-origin http://NAME:PORT
--seed-digest-ttl SECSFrom v1.37.1, reuse the digest an image tag resolved to for that many seconds when a new machine is seeded, so creates and starts of the same image skip the registry until it expires. 0, the default, resolves every time
--json-logsWrite logs as structured JSON for a log aggregator

Selected HTTP endpoints

MethodPathOperation
POST/api/v1/machinesCreate a machine
GET/api/v1/machinesList machines. A machine whose guest agent does not answer is listed as unreachable; from v1.38.0 one 4 second bound covers the whole probe, connection included, so a slow guest cannot hold up the list
GET/api/v1/machines/:nameGet one machine
POST/api/v1/machines/:name/startStart a machine
POST/api/v1/machines/:name/stopStop a machine
POST/api/v1/machines/:name/pause, /resumeSave a running machine’s execution durably and stop it; resume it under the same name
POST/api/v1/machines/:name/resizeGrow a running machine’s CPUs, memory or disks: cpus, memoryMb, storageGb or overlayGb, one kind per request. Asking for two together answers 400 resize CPUs, RAM, and disks in separate requests, although machine resize takes them together. CPUs or memory on a stopped machine answer 400; change those with machine update
POST/api/v1/machines/:name/egressChange the egress allow list, the API form of machine update --allow-host and its siblings, below
GET/api/v1/machines/:name/egress-eventsOutbound connections and lookups the egress policy refused; ?limit= keeps the newest that many, 200 by default
PUT/api/v1/machines/:name/networkFrom v1.37.0, replace the egress policy in the cloud API’s shape: {"mode": "blocked"}, {"mode": "open"}, or {"mode": "allowCidrs", "hosts": [...], "cidrs": [...]}. A running machine takes one allow list for another at once; switching it to or from open, or blocking it, answers 409 until it is stopped. On a stopped machine that has credential bindings, blocked answers 400: remove them first
PATCH/api/v1/machines/:name/labelsFrom v1.37.0, change some labels in any state, leaving the rest: {"labels": {"team": "docs", "old": null}} sets team and removes old. A key is 1 to 63 lowercase letters, digits, ., _, / and -, starting and ending with a letter or digit, a value at most 255 characters, and a machine holds at most 32 labels; a change that breaks any of these answers 422
GET/api/v1/machines/:name/metricsFrom v1.37.0, the machine’s CPU time, memory, disk and egress at that moment, in the cloud API’s shape. A stopped machine answers with its sizes and egressBytes, and null for its CPU, memory and pressure readings; diskUsedMb is measured in any state on a Linux host and is null on macOS
POST/api/v1/machines/:name/syncCopy a running machine’s staged mounts back to the host without stopping it
POST/api/v1/machines/:name/branchesBranch a running source started branchable into a new running child; any other source is refused
POST/api/v1/machines/:name/branches/batchFrom v1.37.0, branch a running branchable source into many running children in one call, {"count": N} from 1 to 64, named after the source with -1, -2 and on, or {"names": [...]}; labels are added to the source’s. All or nothing: when one child fails, those already made are deleted
PUT/api/v1/machines/:name/cpu-limitCap the host CPU a running machine’s VMM may use, as {"millicpus": N} across all its vCPUs (200 is a fifth of one CPU), or {"millicpus": null} to clear it; the guest still sees every vCPU, and the limit holds across restarts until cleared. A stopped machine answers 409. It needs the VMM in a cgroup smolvm controls, so the request is refused with 400 on macOS, and on Linux unless serve runs as root on systemd or can write its own cgroup, as in a systemd unit with Delegate=yes. The CLI has no equivalent
PUT/api/v1/machines/:name/credential-valuesSupply the values for a machine’s credential bindings as {"values": {"<binding>": "<value>"}}, 204; a running machine uses them at once, and a name with no binding answers 400, as does a value longer than 8192 bytes from v1.37.0
PUT/api/v1/machines/:name/credential-bindingsReplace a machine’s credential bindings with the whole set, as {"credentials": [{"name": "gh", "environment_variable": "GH_TOKEN", "allowed_hosts": ["api.github.com"]}]}, and answer {"bindings", "live", "atNextStart"}. A running machine that started with bindings uses them from its next request (live); one running that started without bindings (atNextStart), or a stopped one (both false), from its next start. A running machine that smolvm v1.34 to v1.36 booted with bindings answers 409 when a server from v1.37.0 or later changes them: the bindings are saved and apply from its next start. From v1.37.0 a change that adds a binding to a machine whose networking is off answers 400. Supply a new binding’s value with credential-values. On an atNextStart machine that route answers 409 but keeps the value for that start, and every HTTPS request from a command started after the change fails its certificate check until it restarts, to a host with no binding too, so stop and start it right away
PUT/api/v1/machines/:name/envFrom v1.37.0, replace a machine’s environment with the whole set, as {"env": {"NAME": "value"}}, so a variable left out is removed. A running machine gives it to commands started from then on, a stopped one at its next start. A name must be ASCII letters, digits and _, start with a letter or _, and be at most 256 bytes; any other answers 400
PUT/api/v1/machines/:name/extra-ca-rootsFrom v1.38.0, replace a stopped machine’s extra CA roots, as {"extraCaRoots": "<PEM certificates>"}, or remove them with null, from its next start. The PEM text itself, never a path on the server, at most 2 MiB; a private key or text with no certificate answers 400, and a running or paused machine 409. A create body takes the same extraCaRoots
DELETE/api/v1/machines/:nameDelete a machine. From v1.38.0, ?force=true does not wait on a running guest: its staged mounts get 30 seconds to copy back, and later changes are lost, then it is ended without its shutdown handshake
PUT/api/v1/machines/:name/portsReplace a machine’s published ports with the whole set, as {"ports": [{"host": 8080, "guest": 80}]}; an empty list removes them all. TCP changes apply live while it runs; a UDP change on a running machine answers 409, and so does a taken host port, with PORT_IN_USE
GET, POST, DELETE/api/v1/machines/:name/mountsList, add or remove host directories mounted into a running machine; POST takes source, target and readonly, DELETE takes ?target=, and a stopped machine answers 409
POST/api/v1/machines/:name/execExecute a command
POST/api/v1/machines/:name/exec/streamStream execution over SSE
POST, GET/api/v1/machines/:name/execsStart an exec session, or list them
GET, DELETE/api/v1/machines/:name/execs/:execRead a session’s output after ?after=, or end it
POST/api/v1/machines/:name/execs/:exec/stdin, /resizeSend numbered stdin frames, or resize its terminal
PUT/api/v1/machines/:name/files/*pathUpload a file: up to 1 GiB with a Content-Length, 100 MiB without, 413 beyond. ?uid=, ?gid= and ?mode= (octal) set its owner and permissions; with no owner it belongs to the workload’s user
GET/api/v1/machines/:name/files/*pathDownload a file. From v1.38.0 it streams as the guest sends it, with no Content-Length, and a guest error after the first bytes cuts the response short, so check the length you received
GET/api/v1/machines/:name/logsStream logs over SSE
POST/api/v1/machines/:name/images/pullPull an OCI image
POST/api/v1/poolsCreate a warm pool of branched workers from a branchable source
GET, DELETE/api/v1/pools/:nameRead or delete a pool
PUT/api/v1/pools/:name/sizeChange how many clean workers a pool keeps ready
POST/api/v1/pools/:name/leasesLease one clean worker
POST/api/v1/pools/:name/leases/:lease/heartbeatExtend a lease
POST/api/v1/pools/:name/leases/:lease/completeFinish a lease; the pool replaces its worker

POST /egress adds to or takes from the allow list rather than replacing the whole policy:

curl -X POST http://127.0.0.1:8080/api/v1/machines/dev/egress \
  -H 'content-type: application/json' -d '{"allowHosts": ["pypi.org"]}'

Its body takes allowHosts, allowHostPatterns, allowCidrs, allowUdp, removeAllowHosts, removeAllowCidrs, removeAllowUdp, outboundLocalhostOnly, resetAllowList and allowAll, and refuses any other field with 422. allowAll permits a removal or reset that leaves no entry. A stopped machine takes any change from its next start. A running machine takes, from its next connection or lookup, any change that keeps an allow list in force; one that lifts the list, or gives one to a machine running without one, answers 409 until the machine is stopped. A request that names no change, such as an empty body or allowAll alone, answers 400 request contains no egress changes. A host added through this route, or by machine create --allow-host from v1.38.0, is kept as a name only, so removing it closes its addresses too. A machine that machine create --allow-host made before v1.38.0 also holds the addresses the name resolved to then, in the allowed CIDRs, and removing the host leaves them; take them out with removeAllowCidrs. resetAllowList with the entries to keep leaves exactly those.

An exec session belongs to the machine rather than the connection that started it, so a client can drop off and read the rest later. Choose its execId, 8 to 64 of A-Z, a-z, 0-9, _ and -, before the first try, and a retried start finds the session the first one made instead of running the command twice. Read output with ?after= set to the last answer’s next until done, then DELETE it. smolvm serve openapi gives the frame format.

A warm pool keeps desiredReady workers branched from a source machine and ready to hand out. The source must be started branchable and its workload must reach its branch point by running under smolvm-branch-ready; until it does, the pool stays provisioning. A lease takes an idempotencyKey: repeating a request with the same key and the same body returns the same lease, and the same key with a different body is refused with 409. A lease expires unless heartbeated, 300 seconds by default, and completing it retires the worker while the pool branches a fresh one.

The HTTP API covers common lifecycle, execution, file, image, volume, export, and branch operations. It does not have complete parity with every CLI command or interactive CLI behavior. Use the generated OpenAPI document as the wire-level reference for your installed release.

A branch request waits for the source up to 60 seconds plus 20 seconds per GiB of its memory, at most 540 seconds, then answers a retryable 503. With "keepMachineId": true the child keeps the source’s /etc/machine-id, for tools that key a cache by it; its hostname is still its own name.

A start takes branchable, branchPoolSize and cudaVramLimitMib in its JSON body or its query string; when both carry one, the query string wins.

From v1.37.5, a start whose machine boots but whose image workload fails to launch still answers with state running, and adds workloadError with the reason, such as start workload: executable file `/app/server` not found: No such file or directory. The machine takes exec, but its server is not running, so a caller that needs the workload checks that field. A start on a machine that is running returns without launching anything, so stop the machine before starting it again to retry. The server’s Prometheus endpoint, GET /metrics, counts these starts as smolvm_workload_launch_failures_total.

A create body is validated strictly: an unknown field is refused with 422 and a message naming the field and listing the ones it accepts, and so is a known field of the wrong type. A field this release does not have is refused rather than dropped in silence.

A create body’s diskVolumes lists guest paths kept on the machine’s storage disk instead of its overlay root, the API form of -v /var/lib/docker. A running machine’s record carries cpuLimitMillicpus while a CPU limit is set and, on a virtio-net machine, egressFlows: its open TCP flows, how many distinct peers they reach and the oldest one, refreshed about every 15 seconds. A running machine in the list also carries pressure, the guest’s CPU, memory and IO stall figures that machine stats prints, sampled about every 15 seconds.

Choose an integration

Use npm or PyPI package smolmachines for new Node.js and Python applications.

  • The local engine is embedded through native bindings
  • No separate server process is required
  • The API can target local machines or smol cloud
  • This is the current SDK path in the smol repository

See SDK Quick Start and Use SDK in Local for installation and code examples.

Legacy REST client: smolvm-sdk

The older smolvm-sdk repository holds npm, Python and Go REST clients for a running smolvm serve process. Its npm and Python packages are named smolvm in source, but the smolvm on npm is an empty placeholder and the smolvm on PyPI is a different project, so neither registry installs these clients.

Use this path when:

  • An existing integration already uses the local REST API
  • A separate local runtime process is part of the deployment design
  • The application language cannot use the embedded Node.js or Python packages

Do not confuse the package names:

PackageConnection modelRecommended use
smolmachinesEmbedded local engine; optional cloud transportNew Node.js and Python applications
The smolvm-sdk clients, named smolvm in sourceHTTP client to smolvm serveExisting or server-oriented REST integrations

Security and deployment boundary

Without mutual TLS (SMOLVM_SERVE_TLS_CERT, _KEY, _CLIENT_CA) the local server has no authentication. Bind it to loopback or a protected Unix socket. Do not expose port 8080 to an untrusted network.

From v1.38.0, serve start refuses a --listen address that is not loopback, such as 0.0.0.0, [::] or a LAN address, before it binds anything, unless mutual TLS is configured or --insecure-no-auth is passed:

Error: config operation failed: serve listen address: refusing to serve the API on 0.0.0.0:8080 without authentication: it is not a loopback address, and anyone who reaches it could create machines and run commands in them. Configure mutual TLS by setting SMOLVM_SERVE_TLS_CERT, SMOLVM_SERVE_TLS_KEY and SMOLVM_SERVE_TLS_CLIENT_CA, or pass --insecure-no-auth to serve it unauthenticated anyway. For local use, listen on the default Unix socket or 127.0.0.1

127.0.0.0/8 and ::1 count as loopback.

If another host or user must reach the API, place it behind an authenticated, encrypted proxy and enforce host-level account isolation. Anyone who can call the API can ask the runtime to create machines and execute workloads with the capabilities granted to the server process.

smolvm serve is a per-host runtime API. It is not the standalone smol cloud fleet control plane.

A machine serve starts cannot reach a private, carrier-NAT or loopback address even when its allowedCidrs names one: serve raises the egress floor for every machine it starts, and no allow list entry lowers it. To lift it, set SMOLVM_EGRESS_FLOOR before starting serve: metadata keeps only the link-local range that holds cloud metadata blocked, so a machine reaches the host’s loopback services through host.smolvm.internal, as a CLI machine on the virtio-net backend does by default, and off blocks nothing.