TypeScript SDK
The official, fully-typed TypeScript SDK for Krova Cloud — provision and manage Cubes, run commands and move files over a Cube's SSH, browse the catalog, and reach every REST API operation from Node.js.
@krovacloud/sdk is the official TypeScript client for Krova Cloud. Request bodies, responses, and path params are generated from the Krova Cloud OpenAPI spec, so you get end-to-end types and editor autocomplete for the whole API. Ergonomic helpers cover Cubes, the catalog, domains, snapshots, TCP mappings, imports, backups, and webhooks; a fully-typed escape hatch (client.raw) reaches every operation, and @krovacloud/sdk/ssh runs commands and moves files over a Cube's own SSH. It's published on npm as @krovacloud/sdk.
Install
Add it with your package manager. The only runtime dependency is openapi-fetch; TypeScript declarations are bundled (no @types/* needed).
npm i @krovacloud/sdk
# or: pnpm add @krovacloud/sdk / yarn add @krovacloud/sdkRequires Node.js 22 or newer (it uses the global fetch). It also works in any modern runtime with a WHATWG fetch — Deno, Bun, and edge — and you can pass a custom fetch if the global isn't available.
Authenticate
Create an API key per space from Settings → API keys in the dashboard (see API keys). Keys are scoped to a single space, inherit the permissions of the membership that created them, and look like kro_…. Load the key from an environment variable or a secrets manager — never commit it or embed it in a browser bundle. A key can have an expiry; krova.getSpace() returns it as apiKey.expiresAt, or null when the key never expires.
import { KrovaClient } from "@krovacloud/sdk";
const krova = new KrovaClient({
apiKey: process.env.KROVA_API_KEY!, // a "kro_..." token
});By default the key is sent as the X-API-KEY header. If your gateway expects a bearer token, pass authScheme: "bearer".
Quickstart
Every space-scoped call takes the spaceId as its first argument. Because an API key already belongs to one space, use the space id shown in your dashboard (or resolve it once and reuse it).
// List Cubes in a space
const cubes = await krova.cubes.list("space_123");
// Create a Cube (sshPublicKey is required)
const cube = await krova.cubes.create("space_123", {
name: "web-server",
image: "ubuntu-24.04",
resources: { vcpu: 2, ramGb: 4, diskGb: 40 },
sshPublicKey: "ssh-ed25519 AAAA...your-key... you@host",
});
console.log(`Created cube ${cube.id} (${cube.state})`);
// Power it off, then start it again (both are asynchronous / enqueued)
await krova.cubes.powerOff("space_123", cube.id);
await krova.cubes.wake("space_123", cube.id);
// Cold-restart in place — the only way to pick up a refreshed guest kernel
await krova.cubes.restart("space_123", cube.id);new KrovaClient(options)
new KrovaClient({
apiKey: string, // required — your "kro_..." token
baseUrl?: string, // default: "https://krova.cloud/api/v1"
authScheme?: "x-api-key" | "bearer", // default: "x-api-key"
maxRetries?: number, // default: 2 — retries 429/503 (honors Retry-After); 0 disables
fetch?: typeof fetch, // optional fetch override (proxy, tests)
});baseUrl is optional and defaults to Krova's own API. Throws if apiKey is missing. Exposes client.baseUrl, client.cubes, client.domains, client.snapshots, client.tcpMappings, client.imports, client.backups, client.backupShares, client.webhooks, client.catalog, client.getSpace(), and client.raw. Mutating POST/DELETE endpoints are rate-limited (10 requests / 60s per client IP); the client automatically retries 429 and 503 up to maxRetries times, honoring Retry-After.
client.cubes — the Cube lifecycle
Ergonomic helpers that unwrap the response body and throw a typed KrovaError on any non-2xx status.
list(spaceId)— every Cube in the space.get(spaceId, cubeId)— one Cube.create(spaceId, body, opts?)— the created Cube.update(spaceId, cubeId, body)— change the port sshd listens on inside the Cube.setTerminationProtection(spaceId, cubeId, enabled)— turn termination protection on or off. While it is on,deletethrowsTerminationProtectedError(aKrovaErrorfor the API's 409).rename(spaceId, cubeId, name)— rename a Cube: 1 to 64 printable characters, and names don't have to be unique.setIdleTimeout(spaceId, cubeId, minutes | null)— power the Cube off after that many idle minutes, from 10 to 10080, ornullfor off. Its disk is kept.resize(spaceId, cubeId, { vcpu?, ramGb?, diskGb? }, opts?)— queue a resize. Send only what changes; disk can only grow. The result says whether it applies live (isLive) or restarts the Cube (requiresRestart), and the Cube keeps its size until the change is applied.powerOff/wake/restart/delete(spaceId, cubeId)— asynchronous lifecycle transitions.restartis a cold restart: it re-reads the host kernel, which arebootinside the Cube cannot do.
// create — sshPublicKey is required; region + userData (cloud-init) are optional.
// opts.idempotencyKey (<=255 chars, per-space) makes retries safe.
const cube = await krova.cubes.create(
"space_123",
{
name: "web-server",
image: "ubuntu-24.04",
resources: { vcpu: 2, ramGb: 4, diskGb: 40 },
sshPublicKey: "ssh-ed25519 AAAA... you@host",
region: "us", // optional — slug from catalog.regions()
userData: "#cloud-config\n", // optional — cloud-init (max 16 KB)
terminationProtection: true, // optional — refuse deletes until turned off
idleTimeoutMinutes: 60, // optional — power off after 60 idle minutes (10 to 10080)
},
{ idempotencyKey: "deploy-2026-07-01" },
);
// update — the port sshd listens on inside the Cube
await krova.cubes.update("space_123", cube.id, { cubePort: 2222 });
// termination protection — delete is refused until it is turned off
await krova.cubes.setTerminationProtection("space_123", cube.id, false);
// rename, idle timeout and resize
await krova.cubes.rename("space_123", cube.id, "web-1");
await krova.cubes.setIdleTimeout("space_123", cube.id, 120); // null turns it off
const job = await krova.cubes.resize("space_123", cube.id, { ramGb: 8, diskGb: 60 });
if (job.requiresRestart) console.log("the Cube restarts to apply this");The Cube type is exported for your own signatures:
import type { Cube } from "@krovacloud/sdk";
// {
// id: string; name: string;
// state: "pending" | "booting" | "running" | "stopped" | "stopping" | "resizing" | "error" | "deleted";
// publicIpv4: string | null;
// resources: { vcpu: number; ramGb: number; diskGb: number };
// image: string; costPerHour: number;
// terminationProtection: boolean;
// createdAt: string; updatedAt: string;
// }client.catalog — regions, images, pricing
Read-only catalog endpoints. Use these to discover the valid image and region slugs before creating a Cube.
const regions = await krova.catalog.regions(); // regions with available capacity
const images = await krova.catalog.images(); // available OS images
const pricing = await krova.catalog.pricing(); // per-resource hourly rates + volume tiersDomains, snapshots & TCP mappings
Typed helpers for a Cube's attached resources — each unwraps the response and throws KrovaError on failure.
// Custom domains
const { domain, records } = await krova.domains.create("space_123", "cube_123", {
domain: "app.example.com",
port: 8080,
});
// records: the DNS records to publish for it, with their exact values
await krova.domains.list("space_123", "cube_123");
await krova.domains.update("space_123", "cube_123", domain.id, { responseCompression: true });
// PROXY protocol: "v1", "v2", or null to turn it off
await krova.domains.update("space_123", "cube_123", domain.id, { proxyProtocol: "v2" });
await krova.domains.delete("space_123", "cube_123", domain.id);
// Snapshots + restore
const snap = await krova.snapshots.create("space_123", "cube_123", { name: "nightly" });
await krova.snapshots.list("space_123", "cube_123");
await krova.cubes.restore("space_123", "cube_123", snap.id); // replace the disk from a snapshot
await krova.snapshots.delete("space_123", "cube_123", snap.id);
// TCP port mappings (expose a Cube port on the host)
const mapping = await krova.tcpMappings.create("space_123", "cube_123", {
cubePort: 5432,
whitelistIps: ["203.0.113.4/32"],
});
await krova.tcpMappings.list("space_123", "cube_123");
await krova.tcpMappings.delete("space_123", "cube_123", mapping.id);There are also krova.imports (create / get / complete / cancel a .cube import) and krova.backups.download for a time-limited backup URL, plus krova.getSpace() to resolve the space your key is scoped to and krova.cubes.ssh() for a Cube's SSH connection info. Domain, Snapshot, TcpMapping, Backup, and BackupShare are exported types.
Backups and sharing them
A backup keeps a Cube's disk and configuration after the Cube is gone. You can offer another space its own copy. Nothing is copied until that space accepts, within 48 hours, and from then the copy is its own and billed to it. Your backup and your bill stay the same.
const backups = await krova.backups.list("space_123");
const backup = await krova.backups.get("space_123", backups[0]!.id);
// Offer a copy. Through the API this is always a pending request.
const share = await krova.backups.share(
"space_123",
backup.id,
{ destinationSpaceId: "space_456" },
{ idempotencyKey: "share-nightly-2026-10-07" },
);
// In the destination space: see what is waiting, then accept or decline.
const { incoming } = await krova.backupShares.list("space_456");
const { backup: copy } = await krova.backupShares.accept("space_456", share.id);
// Or: krova.backupShares.decline("space_456", share.id)
// The source can withdraw it first: krova.backupShares.cancel("space_123", share.id)The key's member needs View Backups to list and get, and Manage Backups for everything else. Only the destination space's owner, or a member there with Manage Backups, can accept or decline. accept throws a KrovaError with status 422 when the destination cannot take the copy, for example with no backup allowance left on its plan.
Webhooks
krova.webhooks manages a space's webhook endpoints. create is the only call that returns the signing secret, so store it straight away. To verify deliveries, see Webhooks.
const endpoint = await krova.webhooks.create("space_123", {
url: "https://example.com/hook",
events: ["cube.running", "cube.stopped"],
description: "deploy notifier", // optional
});
// endpoint.secret is returned only here: store it now
await krova.webhooks.list("space_123");
await krova.webhooks.get("space_123", endpoint.id);
await krova.webhooks.deliveries("space_123", endpoint.id, { limit: 20 }); // last 30 days
await krova.webhooks.delete("space_123", endpoint.id);client.raw — every endpoint
The helpers cover Cubes, the catalog, domains, snapshots, TCP mappings, imports, backups, and webhooks. When you would rather handle the error yourself than catch an exception, use client.raw, the fully typed openapi-fetch client. It returns { data, error, response } and never throws — path, method, params, and body are all type-checked against the spec.
const { data, error } = await krova.raw.GET("/spaces/{spaceId}/cubes/{cubeId}", {
params: { path: { spaceId: "space_123", cubeId: "cube_123" } },
});
if (error) {
console.error("Cube lookup failed:", error.error);
} else {
console.log(data);
}The generated paths and components types are also exported for advanced use:
import type { paths, components } from "@krovacloud/sdk";
type Domain = components["schemas"]["Domain"];Error handling
The cubes.* / catalog.* helpers throw a KrovaError on any non-2xx response. (client.raw never throws — it returns the error in { error }.) The error carries the HTTP status, the API message, an optional error code, and a requestId — quote the request id when contacting support.
import { KrovaError } from "@krovacloud/sdk";
try {
await krova.cubes.get("space_123", "cube_missing");
} catch (err) {
if (err instanceof KrovaError) {
console.error(`[${err.status}] ${err.message}`);
if (err.code) console.error("code:", err.code);
if (err.requestId) console.error("request id:", err.requestId);
} else {
throw err;
}
}Run commands and move files
Commands and files go over the Cube's own SSH, with a private key you supply, through the Node-only @krovacloud/sdk/ssh entry. The main entry never loads it, so browser and edge code is unaffected.
import { KrovaClient } from "@krovacloud/sdk";
import { connectCube } from "@krovacloud/sdk/ssh";
const krova = new KrovaClient({ apiKey: process.env.KROVA_API_KEY! });
const shell = await connectCube(krova, spaceId, cubeId, {
privateKey: process.env.CUBE_SSH_KEY!, // the private half of a key on the Cube
});
try {
const { stdout, stderr, exitCode } = await shell.run(["ls", "-la"], { cwd: "/srv" });
await shell.files.write("/srv/hello.txt", "hello");
const bytes = await shell.files.read("/srv/hello.txt");
await shell.files.upload("./build.tar.gz", "/srv/build.tar.gz");
await shell.files.download("/var/log/app.log", "./app.log");
} finally {
await shell.close();
}run(command, { cwd?, env?, timeoutMs?, stdin? }) returns { stdout, stderr, exitCode, signal? }. A string runs as written in the Cube's shell; a string array has each argument quoted for you, as are cwd and the env values. A command that outlasts timeoutMs rejects with RunTimeoutError.
Every connection checks the Cube's host keys, which come from krova.cubes.ssh(). A key that doesn't match, or a Cube with no keys yet, throws HostKeyMismatchError. If you keep your own pinned keys, pass them as hostKeys. The SDK uses your key for the connection only and never logs or stores it; an encrypted key takes passphrase. File paths are used as written, so ~ and $VAR aren't expanded. files.read and files.write hold the whole file in memory, so use upload and download for large ones.
Tools for the Vercel AI SDK
@krovacloud/ai-sdk gives an agent a Cube as its machine. It adds three tools to the Vercel AI SDK: krova_run runs a shell command, krova_read_file reads a text file, and krova_write_file writes one. It builds on connectCube, so the same host-key check applies.
npm install @krovacloud/ai-sdk @krovacloud/sdk ai zodimport { KrovaClient } from "@krovacloud/sdk";
import { createKrovaSandbox } from "@krovacloud/ai-sdk";
import { generateText, isStepCount } from "ai";
const krova = new KrovaClient({ apiKey: process.env.KROVA_API_KEY! });
const sandbox = await createKrovaSandbox({ krova, spaceId, cubeId, privateKey: process.env.CUBE_SSH_KEY! });
try {
const { text } = await generateText({
model, // any model from your AI SDK provider
tools: sandbox.tools,
stopWhen: isStepCount(10),
prompt: "Write a script that prints the first 10 primes, run it, and show the output.",
});
console.log(text);
} finally {
await sandbox.close();
}The Cube must be running, and the public half of privateKey must be in its authorized_keys. Each krova_run call is a fresh shell, so cd and exported variables don't carry over. Output is cut at 32 KB for each of stdout, stderr and a file read, and the result says when it was; change that with maxOutputBytes. The agent can run any command as the Cube's user, so give it a Cube of its own. Working from Python? See the Python SDK.
Next steps
- API keys — create and scope the key the SDK authenticates with.
- Python SDK — create Cubes and run commands on them from Python, with tools for LangChain, CrewAI and the OpenAI Agents SDK.
- CLI — the same API from your terminal, plus SSH and port forwarding.
- Webhooks — receive and verify the events the API emits.
- REST API reference — the interactive OpenAPI spec every helper is built on.
