Skip to content

For coding agents

If you are a coding agent writing code against dvm.run, this page gives you everything you need to start. Each step links to the full guide.

Terminal window
pip install dvm-run # Python 3.12 or newer; imports as `dvm`
npm install dvm-run # Node 22.12 or newer; ES modules only
cargo add dvm-run tokio --features tokio/macros,tokio/rt-multi-thread

Export the API key your user provides:

Terminal window
export DVM_API_KEY=...

Every SDK reads DVM_API_KEY when no key is passed in code. Do not run dvm-run login without a person present to approve it in a browser: it blocks waiting for approval. If you do not have a key, ask your user to create one on the panel’s API keys page; their account must be off the waitlist first (Getting in). Do not print the key, and never pass it into a sandbox.

python/examples/first_sandbox.py
from dvm import Sandbox
with Sandbox.create("python:3.12") as sandbox:
result = sandbox.run(["python", "-c", "print('hello from a sandbox')"])
print(result.exit_code, result.stdout.decode(), end="")
sandbox.write_file("/tmp/notes.txt", b"written before the end\n")
sandbox.end()
point = sandbox.seek()
print(point.read_file("/tmp/notes.txt").decode(), end="")

Key behaviors to rely on:

  • run returns the exit code along with stdout and stderr as bytes. A nonzero exit code is a normal result, not an error; a command killed by a signal exits with 128 + signal.
  • A string runs as a shell script (/bin/bash -lc if the image includes bash, otherwise /bin/sh -c); a list runs directly as argv with no shell.
  • Commands run as root in the image’s environment and working directory. Create a sandbox with no command and no entrypoint, as above, to start a session (a sandbox that accepts commands); pass either to run a one-program sandbox instead.
  • End every sandbox when finished: use a with block, await using, scope, or end(). A sandbox left running continues consuming credit until it hits its time limit.
  • When the API rejects a request, the SDK raises an error containing the service’s reason: read it (Errors).
  • Images must be public; pulls are anonymous.
  • /llms.txt: overview of dvm.run and every page’s Markdown URL.
  • /llms-full.txt: all documentation pages in one Markdown file.
  • /llms-small.txt: the same content with asides and extra whitespace stripped.
  • Any individual page: append .md to its URL. For example, this page is https://docs.dvm.run/start/agents.md, and the home page is https://docs.dvm.run/index.md.

The SDK source code and Rust API types (dvm-api) are in github.com/deterministic-machines/sdk.