Start a cloud agent

A cloud agent is a coding agent (Claude Code, Codex, OpenCode, or nanocode) running in its own Linux sandbox. It has a real filesystem, a shell, package installs, and git. It keeps working when your laptop sleeps, and you can run ten of them at once. You send it prompts from the SDK, the CLI, or HTTP, and you delete it, or let it stop itself, when the work is done.

Choose how the agent pays for its model

4 rows
CredentialUse it whenModel usage is billed to
Claude subscriptionYou have Claude Pro or Max and want Claude Code in the cloud.Your Claude plan
ChatGPT plan or OpenAI keyYou use Codex with your ChatGPT login or an OpenAI key.Your ChatGPT plan or OpenAI account
Coding planYou pay for Z.ai GLM, Kimi, MiniMax, or another provider's plan.That provider
Tangle Router (default)You want no setup: pass no credential at all.Your Tangle credit

Tangle bills sandbox compute per second in every case. With your own subscription or key, model tokens never touch your Tangle credit. See Cost, limits & spin-down.

Claude Code on your subscription, in one call

Create a token with claude setup-token (it prints a long-lived OAuth token for your Claude account), then:

TypeScript
import { Sandbox } from "@tangle-network/sandbox";

const client = new Sandbox({
  apiKey: process.env.TANGLE_API_KEY!,
  baseUrl: "https://sandbox.tangle.tools",
});

// Once per token. The value is encrypted at rest and never returned.
await client.secrets.create("CLAUDE_TOKEN", process.env.CLAUDE_CODE_OAUTH_TOKEN!);

const agent = await client.create({
  name: "my-claude",
  backend: {
    type: "claude-code",
    model: {
      cliAuth: { account: "me", secretEnv: "CLAUDE_TOKEN", format: "token" },
    },
  },
  secrets: ["CLAUDE_TOKEN"],
  git: { url: "https://github.com/your-org/your-repo" },
  idleTimeoutSeconds: 900,
});
await agent.waitFor("running");

const result = await agent.prompt("Find the failing test and fix it.", {
  sessionId: "fix-tests",
});
console.log(result.success, result.response);

Or from a terminal:

Bash
tangle secret create CLAUDE_TOKEN --value-stdin <<< "$CLAUDE_CODE_OAUTH_TOKEN"
tangle sandbox create --name my-claude --backend claude-code --cli-auth CLAUDE_TOKEN \
  --git-url https://github.com/your-org/your-repo --idle-timeout 900
tangle agent prompt <sandbox-id> "Find the failing test and fix it." --session fix-tests --stream

The sandbox is ready in seconds. The agent runs as a durable session: sessionId keeps the conversation, so a second prompt() with the same id continues where the first stopped, from this process or another one.

nanocode, with no credential

nanocode runs as backend.type: "nanocode". Pass no credential and its model calls go through Tangle Router on your Tangle credit:

TypeScript
const nc = await client.create({
  name: "my-nanocode",
  backend: { type: "nanocode", model: { provider: "zai", model: "glm-5.3" } },
});
await nc.waitFor("running");
await nc.prompt("Create hello.txt containing nanocode-ok.", { sessionId: "hello" });

A second prompt() with the same sessionId resumes the same nanocode session.

Watch it work

streamPrompt() yields events while the agent thinks, edits files, and runs commands:

TypeScript
for await (const event of agent.streamPrompt("Now add a regression test.", {
  sessionId: "fix-tests",
})) {
  if (event.type === "message.part.updated") {
    const part = event.data.part as { type?: string };
    if (part?.type === "text" && typeof event.data.delta === "string") {
      process.stdout.write(event.data.delta);
    }
  }
  if (event.type === "done" || event.type === "result" || event.type === "error") {
    break;
  }
}

Pick it up later

The sandbox and its sessions outlive your process. Keep agent.id, fetch the sandbox from anywhere, and keep going:

TypeScript
const again = await client.get(agentId);
await again?.session("fix-tests").prompt("Open a pull request with the fix.");

From a terminal, tangle agent prompt <sandbox-id> "…" --session fix-tests --stream continues the same session, tangle ssh <sandbox-id> opens a shell beside the agent, and the dashboard shows the session live.

Spin it down

TypeScript
await agent.delete(); // permanent: the sandbox and its files are gone

idleTimeoutSeconds stops an agent nobody is talking to, and maxLifetimeSeconds caps how long it may run. A stopped sandbox keeps its files and resumes with agent.resume(). See Cost, limits & spin-down for a live cost meter.

How your credential is handled

  • The token is stored as an encrypted account secret. The create request carries only its name (secretEnv), never its value.
  • The sandbox receives the token at start, and only for the harness you chose. The platform does not mint a Tangle model key for that sandbox.
  • Delete the secret (client.secrets.delete("CLAUDE_TOKEN")) or revoke the token at its provider to cut access.

Next