kosa8 docs Dashboard
esc
↑ ↓ move↵ openRuns in your browser; nothing you type is sent anywhere.

Guides / SDKs / Overview

SDKs in five languages

kosa8 has an official SDK for Python, TypeScript, Go, Ruby and Java. Each one lets your program create sealed machines, run code in them, save their state and roll it back. All five do the same things with the same names, so you can switch languages without relearning anything.

In plain words#

When an AI agent writes code and runs it, that code can do anything your user account can do. It can delete files, read your SSH keys, or send your API keys to someone else. kosa8 stops that by running the code in a sandbox: a small, separate computer that boots in seconds on your own machine. Code in the sandbox cannot see your files unless you share them, and cannot reach the internet unless you allow it.

The kosa8 app (a background program called the daemon) runs those sandboxes. An SDK is a library your own program uses to talk to it. With a few lines of code you can:

  • Create a sandbox, choosing how much CPU, memory and network it gets.
  • Run commands in it and read their output, live or when they finish.
  • Take a checkpoint, a save point, before a risky step, and rewind to it if the step goes wrong. Running programs come back exactly where they were.
  • Fork a sandbox into several copies and try different ideas at once, then keep the one that worked (explore).
  • Delete it when you are done, optionally overwriting its disks.

With the local client, everything happens on your machine: nothing is uploaded, and you need no account. Each SDK also ships a separate Cloud client for kosa8 Cloud, which runs sandboxes on kosa8's hosts instead. It calls https://api.kosa8.com with an API key (KOSA8_API_KEY, starting k8c_live_) from an app.kosa8.com account, and it sends nothing unless you create it. See kosa8 Cloud from the SDKs below.

Install#

For local sandboxes, first install kosa8 itself (Install) and make sure it is running (kosa8 daemon start). Then add the SDK for your language. The current releases are Python and JavaScript 0.7.0, Go v0.6.1, and Ruby and Java 0.6.0:

LanguagePackageInstallNeedsStart here
Pythonkosa8 on PyPIpip install kosa8==0.7.0 Python 3.9+Python quickstart
TypeScript / JavaScript@kosa8/sdk on npmnpm install @kosa8/sdk@0.7.0 Node 18+JS quickstart
Gogithub.com/kosa8ai/kosa8-gogo get github.com/kosa8ai/kosa8-go@v0.6.1 Go 1.21+Go quickstart
Rubykosa8 on RubyGemsgem install kosa8 -v 0.6.0 Ruby 2.6+Ruby quickstart
Javacom.kosa8:kosa8 on Maven Centralcom.kosa8:kosa8:0.6.0 (Maven or Gradle, below) Java 17+Java quickstart

For Java, the Maven dependency is:

<dependency>
  <groupId>com.kosa8</groupId>
  <artifactId>kosa8</artifactId>
  <version>0.6.0</version>
</dependency>

and for Gradle (Kotlin DSL): implementation("com.kosa8:kosa8:0.6.0").

None of the SDKs has a runtime dependency. Each uses only its language's standard library, so adding one brings nothing else into your build. All are MIT licensed, and the source is on GitHub: kosa8-py, kosa8-js, kosa8-go, kosa8-rb, kosa8-java.

The same program in every language#

Create a sandbox with no network, run a command, delete it.

# Python
import kosa8
k = kosa8.Kosa8Client()
k.create_sandbox(name="demo", egress="deny")
k.pull_into_sandbox("demo", "alpine:latest")
print(k.run("demo", "alpine:latest", ["echo", "hello"]).stdout)
k.delete_sandbox("demo")
// TypeScript
import { Kosa8Client } from "@kosa8/sdk";
const k = new Kosa8Client();
await k.createSandbox({ name: "demo", egress: "deny" });
await k.pullIntoSandbox("demo", "alpine:latest");
console.log((await k.run("demo", "alpine:latest", ["echo", "hello"])).stdout);
await k.deleteSandbox("demo");
// Go
k, _ := kosa8.New(kosa8.Options{})
k.CreateSandbox(ctx, kosa8.CreateOptions{Name: "demo", Egress: "deny"})
k.PullIntoSandbox(ctx, "demo", "alpine:latest")
res, _ := k.Run(ctx, "demo", "alpine:latest", []string{"echo", "hello"}, nil)
fmt.Print(res.Stdout())
k.DeleteSandbox(ctx, "demo", kosa8.DeleteOptions{})
# Ruby
require "kosa8"
k = Kosa8::Client.new
k.create_sandbox(name: "demo", egress: "deny")
k.pull_into_sandbox("demo", "alpine:latest")
puts k.run("demo", "alpine:latest", ["echo", "hello"]).stdout
k.delete_sandbox("demo")
// Java
Kosa8Client k = Kosa8Client.builder().build();
k.createSandbox(new Options.Create().name("demo").egress("deny"));
k.pullIntoSandbox("demo", "alpine:latest");
System.out.print(k.run("demo", "alpine:latest", List.of("echo", "hello")).stdout());
k.deleteSandbox("demo");

The names follow each language's own style (create_sandbox in Python and Ruby, createSandbox in TypeScript and Java, CreateSandbox in Go), but the operations, their options and what they return are the same.

What every SDK covers#

AreaOperations
Daemonhealth, version, pull an image to the host
Sandboxeslist, get, create, start, stop, delete (with disk wipe), pull an image into one, list its images and containers, read its network policy and decisions
Running coderun to completion, start a detached container, exec in it, interactive containers with stdin, attach to output, raw output frames
Snapshotssnapshot (optionally encrypted), list, restore under a new name, delete (with wipe or force)
Fork and exploreN live copies of a running sandbox; best-of-N that runs one idea per copy and keeps the fastest success
Checkpointscheckpoint, list, rewind to the latest or to a named one; shared with kosa8 checkpoint and kosa8 rewind
Toolboxrun a Python, JavaScript or TypeScript snippet (with chart artifacts), read and write files in the sandbox's /workspace, git, shell sessions that keep cd and export, terminals, signed preview links, lifecycle (auto-stop, auto-delete, TTL, ephemeral), templates built from a Dockerfile
Connectionslocal socket by default; remote workers over HTTPS with a bearer token; actor and agent-identity headers; signed approvals per call
Errorstyped errors for every daemon answer (bad request, auth, policy, approval required, not found, conflict, unsupported), plus payment required (402), org frozen (423), rate limit (429) and exec timeout (504) from kosa8 Cloud, and connection, stream and timeout errors, each with the server's own message and remediation text

kosa8 Cloud from the SDKs#

The Cloud client is a second, smaller client in the same package. It talks to kosa8 Cloud's control plane at https://api.kosa8.com (or KOSA8_CLOUD_URL) with the API key in KOSA8_API_KEY.

LanguageCreate it
Pythonfrom kosa8 import Kosa8Cloud; cloud = Kosa8Cloud()
TypeScript / JavaScriptimport { Kosa8Cloud } from '@kosa8/sdk'; const cloud = new Kosa8Cloud();
Gocloud, err := kosa8.NewCloud(kosa8.CloudOptions{})
Rubycloud = Kosa8::Cloud.new
JavaKosa8Cloud cloud = Kosa8Cloud.builder().build();

It covers: create (one or many), list and get sandboxes; run a command in one (a sleeping sandbox wakes for it), in the foreground or the background, and run code snippets; read and write files in /workspace; sleep, wake, refresh, update and delete; checkpoints, rewind, fork and snapshots; previews, terminals, egress rules, secrets, schedules, metrics and logs; deploy, list, get, delete, invoke and map functions; org templates, pipelines and RL runs; and me and usage for the account. Each language's API page lists the exact calls. Things to know:

  • A Cloud exec waits for the command and returns its whole output. The API cuts a buffered exec off after 90 seconds, and the call fails with a 504 (exec_timeout), so keep each command short or start long work in the background.
  • The default template, base, is Alpine Linux: sh is busybox, and there is no bash or python. Ask for another template (such as python) when you create the sandbox, or install what you need.
  • Execs share the sandbox's exec container while it lasts, so files outside /workspace usually carry over, but only /workspace is kept for certain (a command in another image runs in a fresh container that shares only it). Write anything you need later there, or create the sandbox with persistent set for one long-lived container.
  • A 402 means kosa8 Cloud will not start new work: no payment method on file, the last charge was declined, the spending cap is reached, or the organization has no plan (or its plan does not include what was asked for). A 429 means the organization's running-sandbox limit, or a rate limit, was reached.

A few words you will see#

Daemon
The kosa8 background program, kosa8d. The SDKs send it requests over a local socket file, ~/.kosa8/run/kosa8.sock.
Sandbox
A small virtual machine with its own disk, memory and network rules.
Image
A container image such as python:3.12-alpine. Code runs in a container made from an image, inside the sandbox.
Egress
What the sandbox may reach on the network: deny (nothing), any, fakenet (a fake internet for malware analysis) or allow:pypi.org,github.com (only those hosts).
Snapshot
A saved copy of a running sandbox: memory, running programs and disks.
Checkpoint
A snapshot on a sandbox's own undo stack, named <sandbox>-ckpt-N. Ten are kept per sandbox.
Fork
Several live copies of one sandbox, made from a single snapshot.
Approval
A signature from a person, required by your organisation's policy before some actions. You pass it with the call that needs it.

Where to go next#

Something wrong or missing? Write to contact@kosa8.com.

The kosa8 weekly

Agent security news, one industry deep-dive and a hands-on challenge, every Monday. Unsubscribe in one click.

© 2026 kosa8 · kosa8.com · Zero Trust cybersecurity infrastructure for AI agents · Local models served by llamay · Agent gateway: MAQPNA