Make a key in the console, then paste these in order: start an instance, run a command, move files, stop it. Every call takes Authorization: Bearer dc_…; base address https://digicompute.app.
Keep it in an environment variable; every example below reads DC_KEY.
export DC_KEY="dc_…"
# Start an instance (it lives 10 minutes unless timeoutSec says otherwise) and keep its id
INSTANCE=$(curl --fail-with-body -sS -X POST "https://digicompute.app/v1/instances" \
-H "Authorization: Bearer $DC_KEY" \
-H "Content-Type: application/json" \
-d '{"size":"small","timeoutSec":600}')
export INSTANCE_ID=$(printf '%s' "$INSTANCE" | jq -er '.id')
echo "$INSTANCE"const BASE = "https://digicompute.app";
const headers = { Authorization: `Bearer ${process.env.DC_KEY}`, "Content-Type": "application/json" };
const res = await fetch(`${BASE}/v1/instances`, {
method: "POST",
headers,
body: JSON.stringify({ size: "small", timeoutSec: 600, network: "none" }),
});
const instance = await res.json();
console.log(instance.id); // keep it for the next stepsimport os, requests # pip install requests
BASE = "https://digicompute.app"
H = {"Authorization": f"Bearer {os.environ['DC_KEY']}"}
r = requests.post(f"{BASE}/v1/instances", headers=H,
json={"size": "small", "timeoutSec": 600, "network": "none"})
r.raise_for_status()
instance = r.json()
print(instance["id"]) # keep it for the next steps
{"id":"inst_8f2k1q9vx3","status":"running","size":"small","network":"none",
"expiresAt":"…","maxExpiresAt":"…","limits":{"cpus":1,"memoryMb":1024,"diskGb":5}, …}
The curl examples that follow use $INSTANCE_ID, set above with jq (or by hand: export INSTANCE_ID=inst_8f2k1q9vx3). --fail-with-body makes a refused call fail in scripts while still printing why. Anything that goes wrong comes back as {"error": "…"} saying what (errors).
curl --fail-with-body -sS -X POST "https://digicompute.app/v1/instances/$INSTANCE_ID/exec" \
-H "Authorization: Bearer $DC_KEY" \
-H "Content-Type: application/json" \
-d '{"command":"python3 -c \"print(6*7)\"","timeoutSec":60}'const run = await fetch(`${BASE}/v1/instances/${instance.id}/exec`, {
method: "POST",
headers,
body: JSON.stringify({ command: 'python3 -c "print(6*7)"', timeoutSec: 60 }),
});
const { exitCode, stdout, stderr } = await run.json();
console.log(exitCode, stdout);r = requests.post(f"{BASE}/v1/instances/{instance['id']}/exec", headers=H,
json={"command": 'python3 -c "print(6*7)"', "timeoutSec": 60})
out = r.json()
print(out["exitCode"], out["stdout"])
{"exitCode":0,"stdout":"42\n","stderr":"","timedOut":false,"durationMs":432}
Also cwd and env ({"DEBUG":"1"}).
Write a file (the body is the file), read it back, list a folder.
# write curl --fail-with-body -sS -X PUT "https://digicompute.app/v1/instances/$INSTANCE_ID/files?path=/work/app.py" \ -H "Authorization: Bearer $DC_KEY" --data-binary @app.py # read curl --fail-with-body -sS "https://digicompute.app/v1/instances/$INSTANCE_ID/files?path=/work/app.py" \ -H "Authorization: Bearer $DC_KEY" -o app.py # list curl --fail-with-body -sS "https://digicompute.app/v1/instances/$INSTANCE_ID/list?path=/work" \ -H "Authorization: Bearer $DC_KEY"
const file = (path) => `${BASE}/v1/instances/${instance.id}/files?path=${encodeURIComponent(path)}`;
const auth = { Authorization: headers.Authorization };
// write
await fetch(file("/work/app.py"), { method: "PUT", headers: auth, body: 'print("hello")\n' });
// read
const text = await (await fetch(file("/work/app.py"), { headers: auth })).text();
// list
const list = await (await fetch(`${BASE}/v1/instances/${instance.id}/list?path=/work`, { headers: auth })).json();files = f"{BASE}/v1/instances/{instance['id']}/files"
# write
requests.put(files, headers=H, params={"path": "/work/app.py"}, data=b'print("hello")\n')
# read
text = requests.get(files, headers=H, params={"path": "/work/app.py"}).text
# list
listing = requests.get(f"{BASE}/v1/instances/{instance['id']}/list", headers=H,
params={"path": "/work"}).json()
It stops by itself when its time runs out (how long it lives); more time is one call.
# 30 more minutes
curl --fail-with-body -sS -X POST "https://digicompute.app/v1/instances/$INSTANCE_ID/extend" \
-H "Authorization: Bearer $DC_KEY" -H "Content-Type: application/json" \
-d '{"seconds":1800}'
# done: stop it (the counting stops too)
curl --fail-with-body -sS -X DELETE "https://digicompute.app/v1/instances/$INSTANCE_ID" -H "Authorization: Bearer $DC_KEY"await fetch(`${BASE}/v1/instances/${instance.id}/extend`, {
method: "POST", headers, body: JSON.stringify({ seconds: 1800 }),
});
await fetch(`${BASE}/v1/instances/${instance.id}`, { method: "DELETE", headers });requests.post(f"{BASE}/v1/instances/{instance['id']}/extend", headers=H, json={"seconds": 1800})
requests.delete(f"{BASE}/v1/instances/{instance['id']}", headers=H)
A template is what an instance starts from. Pass "template" when you create one; without it you get base. Every template is driven the same way: commands through exec, files through the files API.
| template | What it is | What's in it |
|---|---|---|
| base default | Linux sandbox A plain Linux sandbox: Node, Python, git and build tools. No agent. | Debian 12 (bookworm) · Node.js 24 and npm · Python 3.11 with pip and venv (python, pip) · git, curl, wget, jq, ripgrep, zip · build-essential (gcc, make), pkg-config |
| openclaw | OpenClaw OpenClaw general agent: headless browser, code, files. | Everything in Linux sandbox · OpenClaw (openclaw on PATH) · Headless Chromium for its browser tool · Bring your model key as env (ANTHROPIC_API_KEY, OPENAI_API_KEY…) |
An OpenClaw instance: your model key goes in as env (only its name is kept; never shown back), and it needs the internet to reach the model ("network": "open", when your plan includes it).
# Start an OpenClaw instance with your model key
INSTANCE=$(curl --fail-with-body -sS -X POST "https://digicompute.app/v1/instances" \
-H "Authorization: Bearer $DC_KEY" \
-H "Content-Type: application/json" \
-d '{"template":"openclaw","size":"medium","network":"open","timeoutSec":1800,
"env":{"ANTHROPIC_API_KEY":"'"$ANTHROPIC_API_KEY"'"}}')
export INSTANCE_ID=$(printf '%s' "$INSTANCE" | jq -er '.id')
# Give it a task
curl --fail-with-body -sS -X POST "https://digicompute.app/v1/instances/$INSTANCE_ID/exec" \
-H "Authorization: Bearer $DC_KEY" \
-H "Content-Type: application/json" \
-d '{"command":"openclaw agent --local --model anthropic/claude-sonnet-5-5 --message \"Find the latest Node.js LTS version and write it to /work/node.txt\"","timeoutSec":600}'
# Every template there is
curl --fail-with-body -sS "https://digicompute.app/v1/templates"const BASE = "https://digicompute.app";
const headers = { Authorization: `Bearer ${process.env.DC_KEY}`, "Content-Type": "application/json" };
const box = await (await fetch(`${BASE}/v1/instances`, {
method: "POST", headers,
body: JSON.stringify({
template: "openclaw", size: "medium", network: "open", timeoutSec: 1800,
env: { ANTHROPIC_API_KEY: process.env.ANTHROPIC_API_KEY },
}),
})).json();
const turn = await (await fetch(`${BASE}/v1/instances/${box.id}/exec`, {
method: "POST", headers,
body: JSON.stringify({
command: 'openclaw agent --local --model anthropic/claude-sonnet-5-5 --message "Find the latest Node.js LTS version and write it to /work/node.txt"',
timeoutSec: 600,
}),
})).json();
console.log(turn.stdout);import os, requests # pip install requests
BASE = "https://digicompute.app"
H = {"Authorization": f"Bearer {os.environ['DC_KEY']}"}
box = requests.post(f"{BASE}/v1/instances", headers=H, json={
"template": "openclaw", "size": "medium", "network": "open", "timeoutSec": 1800,
"env": {"ANTHROPIC_API_KEY": os.environ["ANTHROPIC_API_KEY"]}}).json()
turn = requests.post(f"{BASE}/v1/instances/{box['id']}/exec", headers=H, json={
"command": 'openclaw agent --local --model anthropic/claude-sonnet-5-5 '
'--message "Find the latest Node.js LTS version and write it to /work/node.txt"',
"timeoutSec": 600}).json()
print(turn["stdout"])
{"id":"inst_…","status":"running","template":"openclaw","size":"medium","network":"open", …}
An instance stops by itself when its time runs out: 10 minutes unless it's made with timeoutSec. Nobody needs to come back to this site for more time; your code asks for it, up to the plan's longest life, counted from when the instance started (Free: 200 hours). You're billed for the time it runs, not the time asked for, so delete it when the work is done.
Every instance's answer has expiresAt (when it stops now) and maxExpiresAt (the latest it can be moved to).
# Stops after 15 minutes without a command or file call
curl --fail-with-body -sS -X POST "https://digicompute.app/v1/instances" \
-H "Authorization: Bearer $DC_KEY" -H "Content-Type: application/json" \
-d '{"size":"small","timeoutSec":900,"extendOnActivity":true}'
# Switch it on (or off) for one that's running
curl --fail-with-body -sS -X PATCH "https://digicompute.app/v1/instances/$INSTANCE_ID" \
-H "Authorization: Bearer $DC_KEY" -H "Content-Type: application/json" \
-d '{"extendOnActivity":true}'// Stops after 15 minutes without a command or file call
const agentBox = await (await fetch(`${BASE}/v1/instances`, {
method: "POST", headers,
body: JSON.stringify({ size: "small", timeoutSec: 900, extendOnActivity: true }),
})).json();
console.log(agentBox.expiresAt, agentBox.maxExpiresAt);# Stops after 15 minutes without a command or file call
box = requests.post(f"{BASE}/v1/instances", headers=H, json={
"size": "small", "timeoutSec": 900, "extendOnActivity": True}).json()
print(box["expiresAt"], box["maxExpiresAt"])
201 {"id":"inst_…","status":"running","expiresAt":"…T10:15:00Z",
"maxExpiresAt":"…T11:00:00Z","extendOnActivity":true, …}
A persistent instance has its own disk at /work. It stops by itself when idle (no compute hours while stopped) and starts again on the next command or file call, files where they were. Delete it to remove the disk.
curl --fail-with-body -sS -X POST "https://digicompute.app/v1/instances" \
-H "Authorization: Bearer $DC_KEY" -H "Content-Type: application/json" \
-d '{"size":"small","persistent":true,"diskGb":10,"idleTimeoutSec":900}'
# later, even after it stopped: it starts again
curl --fail-with-body -sS -X POST "https://digicompute.app/v1/instances/$INSTANCE_ID/exec" \
-H "Authorization: Bearer $DC_KEY" -H "Content-Type: application/json" \
-d '{"command":"ls /work"}'
# stop and start by hand
curl --fail-with-body -sS -X POST "https://digicompute.app/v1/instances/$INSTANCE_ID/stop" -H "Authorization: Bearer $DC_KEY"
curl --fail-with-body -sS -X POST "https://digicompute.app/v1/instances/$INSTANCE_ID/start" -H "Authorization: Bearer $DC_KEY"const ws = await (await fetch(`${BASE}/v1/instances`, {
method: "POST", headers,
body: JSON.stringify({ size: "small", persistent: true, diskGb: 10, idleTimeoutSec: 900 }),
})).json();
// later, even after it stopped: it starts again
const ls = await (await fetch(`${BASE}/v1/instances/${ws.id}/exec`, {
method: "POST", headers, body: JSON.stringify({ command: "ls /work" }),
})).json();ws = requests.post(f"{BASE}/v1/instances", headers=H, json={
"size": "small", "persistent": True, "diskGb": 10, "idleTimeoutSec": 900}).json()
# later, even after it stopped: it starts again
ls = requests.post(f"{BASE}/v1/instances/{ws['id']}/exec", headers=H,
json={"command": "ls /work"}).json()
Describe one tool to your model; when it calls the tool, your code starts an instance, runs the command, returns the output and deletes the instance. Any model or framework with tool calls works the same way.
{
"name": "run_code",
"description": "Run a shell command in a fresh, isolated Linux computer and return its output.",
"input_schema": {
"type": "object",
"properties": {
"command": { "type": "string", "description": "e.g. python3 -c \"print(6*7)\"" },
"files": { "type": "object", "description": "Optional: path → contents, written before the command" }
},
"required": ["command"]
}
}
When the model calls it, run this and hand back what it returns:
# The same four calls, from a shell
INSTANCE=$(curl --fail-with-body -sS -X POST "https://digicompute.app/v1/instances" \
-H "Authorization: Bearer $DC_KEY" -H "Content-Type: application/json" \
-d '{"size":"small","network":"none","timeoutSec":600}')
INSTANCE_ID=$(printf '%s' "$INSTANCE" | jq -er '.id')
curl --fail-with-body -sS -X PUT "https://digicompute.app/v1/instances/$INSTANCE_ID/files?path=/work/main.py" \
-H "Authorization: Bearer $DC_KEY" --data-binary @main.py
curl --fail-with-body -sS -X POST "https://digicompute.app/v1/instances/$INSTANCE_ID/exec" -H "Authorization: Bearer $DC_KEY" \
-H "Content-Type: application/json" -d '{"command":"python3 /work/main.py","timeoutSec":60}'
curl --fail-with-body -sS -X DELETE "https://digicompute.app/v1/instances/$INSTANCE_ID" -H "Authorization: Bearer $DC_KEY"const BASE = "https://digicompute.app";
const headers = { Authorization: `Bearer ${process.env.DC_KEY}`, "Content-Type": "application/json" };
export async function runCode({ command, files = {} }) {
const inst = await (await fetch(`${BASE}/v1/instances`, {
method: "POST", headers,
body: JSON.stringify({ size: "small", network: "none", timeoutSec: 600 }),
})).json();
try {
for (const [path, contents] of Object.entries(files)) {
await fetch(`${BASE}/v1/instances/${inst.id}/files?path=${encodeURIComponent(path)}`, {
method: "PUT", headers: { Authorization: headers.Authorization }, body: contents,
});
}
const out = await (await fetch(`${BASE}/v1/instances/${inst.id}/exec`, {
method: "POST", headers, body: JSON.stringify({ command, timeoutSec: 60 }),
})).json();
return { exitCode: out.exitCode, stdout: out.stdout, stderr: out.stderr };
} finally {
await fetch(`${BASE}/v1/instances/${inst.id}`, { method: "DELETE", headers });
}
}import os, requests # pip install requests
BASE = "https://digicompute.app"
H = {"Authorization": f"Bearer {os.environ['DC_KEY']}"}
def run_code(command: str, files: dict[str, str] | None = None) -> dict:
inst = requests.post(f"{BASE}/v1/instances", headers=H,
json={"size": "small", "network": "none", "timeoutSec": 600}).json()
try:
for path, contents in (files or {}).items():
requests.put(f"{BASE}/v1/instances/{inst['id']}/files", headers=H,
params={"path": path}, data=contents.encode())
out = requests.post(f"{BASE}/v1/instances/{inst['id']}/exec", headers=H,
json={"command": command, "timeoutSec": 60}).json()
return {k: out.get(k) for k in ("exitCode", "stdout", "stderr")}
finally:
requests.delete(f"{BASE}/v1/instances/{inst['id']}", headers=H)
Give the agent its own key (API keys in the console), so its instances, sizes and hours have their own limits.
| Size | vCPU | Memory | Disk | Compute hours per hour |
|---|---|---|---|---|
| mini | 0.5 | 512 MB | 2 GB | 0.5 |
| small | 1 | 1 GB | 5 GB | 1 |
| medium | 2 | 4 GB | 10 GB | 2 |
| large | 4 | 8 GB | 20 GB | 4 |
network: none (no network), limited (allowed hosts only) or open, when your plan includes the internet.
| POST | /v1/instances | template (base when none), size, network, timeoutSec, extendOnActivity, env, metadata; persistent, diskGb, idleTimeoutSec; waitSec to wait for room instead of a 503 |
| GET | /v1/instances | yours that run; ?all=1 for stopped ones too |
| GET | /v1/instances/:id | |
| POST | /v1/instances/:id/extend | seconds, up to maxExpiresAt |
| PATCH | /v1/instances/:id | name, metadata, extendOnActivity; idleTimeoutSec and autoStop for persistent ones |
| POST | /v1/instances/:id/stop · /start | persistent instances |
| DELETE | /v1/instances/:id | |
| POST | /v1/instances/:id/exec | command, cwd, env, timeoutSec |
| PUT · GET | /v1/instances/:id/files?path= | |
| GET | /v1/instances/:id/list?path= | |
| GET | /v1/usage | this month: instances, running time, compute hours, your limits |
| GET | /v1/templates | the templates an instance can start from (kind: sandbox); no key needed |
| Code | When |
|---|---|
| 400 | Something sent is wrong; the message says what |
| 401 | No key, or a wrong or revoked one |
| 402 | This month's compute hours are used up (plan and hour packs) |
| 403 | Not in your plan or key: a bigger size, the internet, a longer life; or the account is suspended |
| 404 | No such instance for this key |
| 409 | The instance has stopped |
| 429 | Too many instances at once for this key or plan |
| 503 | No server has room for that size right now: try again shortly |