Quickstart
Create an isolated machine, run a shell command in it, then hand it to a coding agent, all from a few lines of TypeScript.
1. Install the SDK
npm install @tangle-network/sandbox2. Get an API key
Create an sk-tan- key from Authentication and export it:
export TANGLE_API_KEY=sk-tan-...One key authenticates every Tangle product. Pass it to the client as apiKey; the SDK does not read env vars for you.
3. Create a sandbox and run a command
import { Sandbox } from "@tangle-network/sandbox";
const client = new Sandbox({
apiKey: process.env.TANGLE_API_KEY!,
baseUrl: process.env.SANDBOX_BASE_URL ?? "https://sandbox.tangle.tools",
});
const box = await client.create({ image: "universal", name: "agent-smoke" });
try {
const result = await box.exec("node --version && npm --version");
console.log(result.stdout);
} finally {
await box.delete();
}create returns a live machine; delete releases it. You never provision infrastructure yourself.
4. Run a coding agent
Each sandbox runs one coding harness. Choose it with backend.type. opencode (OpenCode) is the default and needs no extra key. claude-code (Claude Code) runs on Tangle Router by default with no extra key. To bring your own Anthropic credential, pass backend: { type: 'claude-code', model: { apiKey: process.env.ANTHROPIC_API_KEY } }. See supported harnesses for the full list.
const box = await client.create({
image: "universal",
backend: { type: "opencode" },
});
try {
const result = await box.prompt("List the files in this project and summarize what it does");
console.log(result);
} finally {
await box.delete();
}For runs that must survive a client crash or a browser reload, use box.dispatchPrompt(message, { sessionId }) and reconnect with box.session(sessionId). See durable sessions in the SDK reference.
5. Check before you build (optional)
These calls are safe to run without creating a sandbox:
curl -fsS https://sandbox.tangle.tools/health
curl -fsS https://sandbox.tangle.tools/v1/public-templatesNext
- SDK reference for durable sessions, GPU leases, and the core API.
- Connect to Intelligence: send each run’s trace so you can see why an agent failed and what to fix.