# For coding agents

> Quickest path for coding agents to install an SDK, authenticate without a browser, run a sandbox, and fetch the docs as Markdown.

This is the Markdown of https://docs.dvm.run/start/agents/. Every page of the dvm.run docs is served as Markdown at its address plus `.md`; the list of pages is https://docs.dvm.run/llms.txt.

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.

## 1. Install an SDK



```sh
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
```

## 2. Authenticate without a browser

Export the API key your user provides:



```sh
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](https://sandbox.dvm.run/keys); their account must be off the waitlist first ([Getting in](/start/access/)). Do not print the key, and never pass it into a sandbox.

## 3. Start a sandbox and read its output

* Python

  `python/examples/first_sandbox.py`

  ```python
  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="")
  ```

* TypeScript

  `js/examples/first-sandbox.ts`

  ```ts
  import { Sandbox } from "dvm-run";

  await using sandbox = await Sandbox.create("python:3.12");
  const result = await sandbox.run(["python", "-c", "print('hello from a sandbox')"]);
  console.log(result.exitCode, new TextDecoder().decode(result.stdout));

  await sandbox.writeFile("/tmp/notes.txt", new TextEncoder().encode("written before the end\n"));
  await sandbox.end();

  const point = await sandbox.seek();
  console.log(new TextDecoder().decode(await point.readFile("/tmp/notes.txt")));
  ```

* Rust

  `rust/dvm-run/examples/first_sandbox.rs`

  ```rust
  #[tokio::main]
  async fn main() -> dvm_run::Result<()> {
      let client = dvm_run::Client::from_env()?;
      let sandbox = client.create_sandbox("python:3.12").await?;
      sandbox
          .scope(async |sandbox| {
              let result = sandbox
                  .run(["python", "-c", "print('hello from a sandbox')"])
                  .await?;
              print!(
                  "{} {}",
                  result.exit_code,
                  String::from_utf8_lossy(&result.stdout)
              );
              sandbox
                  .write_file("/tmp/notes.txt", b"written before the end\n")
                  .await?;
              Ok(())
          })
          .await?;

      let point = sandbox.seek_end().await?;
      let notes = point.read_file("/tmp/notes.txt").await?;
      print!("{}", String::from_utf8_lossy(&notes));
      Ok(())
  }
  ```

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](/guides/programs/) 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](/reference/errors/)).
* Images must be public; pulls are anonymous.

## 4. Read the docs as Markdown

* [/llms.txt](/llms.txt): overview of dvm.run and every page’s Markdown URL.
* [/llms-full.txt](/llms-full.txt): all documentation pages in one Markdown file.
* [/llms-small.txt](/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](https://github.com/deterministic-machines/sdk).
