Integrations
TypeScript SDK
npm client for Node and Next.js server-side agent apps.
Install
npm install @inis-run/sdkQuick example
import { Client } from "@inis-run/sdk";
const client = new Client({ token: process.env.INIS_API_KEY! });
const session = await client.sessions.create();
try {
const result = await session.exec(["bash", "-c", "echo hello"]);
console.log(result.stdout);
await session.writeFile("/workspace/script.py", "print('hello')");
await session.exec(["python3", "/workspace/script.py"]);
const { previewUrl } = await session.expose(8080);
console.log(previewUrl);
} finally {
await session.destroy();
}Prefer await using session = await client.sessions.create() where your runtime supports Symbol.asyncDispose (destroys on scope exit).
API surface
| Method | Description |
|---|---|
client.sessions.create() / .attach(id) / .list() / .get(id) | Create, reattach, list, inspect |
session.exec(argv) | Run a command |
session.execStream(argv) | SSE stream of stdout/stderr |
session.runCode(code) / restartContext() | Persistent Python interpreter |
session.readFile / writeFile / listFiles | File I/O (encoding: "base64" for binary) |
session.files.read/write/list | Text-only convenience aliases |
session.writeFiles / findFiles / grepFiles | Batch write, glob find, content grep |
session.mkdir / remove / rename / uploadFile / downloadFile | Path ops and large-file streams |
session.startProcess / listProcesses / getProcess / killProcess | Named background processes |
session.getProcessLogs / streamProcessLogs | Buffered or live process output |
session.expose / unexpose | HTTPS preview URLs |
session.pause / resume / fork | Lifecycle |
session.checkpoint / restore / checkpoints | Named checkpoints |
session.saveAsTemplate / client.templates | Templates |
client.execute({ language, code }) | Stateless run via /v1/sessions/exec |
session.pty({ cols, rows, command? }) | Interactive PTY — see below |
sessions.create also takes template, size, env, secrets, timers, and egress — see Sessions API.
const client = new Client({
token: process.env.INIS_API_KEY,
baseUrl: "https://api.inis.run",
timeoutMs: 120_000,
});Common response types are exported from @inis-run/sdk. Node 18+; no browser bundle — keep API keys server-side.
Streaming exec
for await (const chunk of session.execStream(["python3", "-u", "train.py"])) {
if (chunk.stream === "stdout") process.stdout.write(chunk.data);
else if (chunk.stream === "exit") console.log(`exit code: ${chunk.exitCode}`);
}Interactive terminal (PTY)
const term = await session.pty({ cols: 80, rows: 24 });
try {
await term.write("python3 -c 'print(1 + 1)'\n");
for await (const chunk of term) {
process.stdout.write(chunk);
if (Buffer.from(chunk).includes("2\n")) {
await term.write("exit()\n");
}
}
console.log(term.exitCode);
} finally {
await term.close();
}Pass command: ["python3", "-i"] for a REPL. term.resize / term.kill as needed.
Embedding a terminal in your own product. Authenticate with your INIS_API_KEY server-side and proxy frames to the browser — never put the key in client code (browsers also cannot set Authorization on WebSocket).