SDK
Kiri SDK
The Kiri SDK turns an ordinary Go, Rust, TypeScript or Python program into a WebAssembly module, and Kiri runs it beside your containers. You change two lines, the one that opens the database and the one that listens, and the handler code in between stays as it is. A module starts in about a millisecond, and it can reach only what it declares in a file next to the code, kiri.yaml.
The two-line change
Here is a small service before and after, in the language you picked at the top of the page. The handler doesn’t change. The two lines that did their own wiring now ask Kiri: Kiri listens on the port and passes each request to your handler, and Kiri keeps the database and hands your code a connection to it.
package main
import (
"encoding/json"
"net/http"
"runkiri.com/go/kiri"
)
func main() {
db := kiri.DB() // was: db, _ := sql.Open("sqlite3", "shop.db")
http.HandleFunc("/orders", func(w http.ResponseWriter, r *http.Request) {
rows, err := db.Query("SELECT id, total FROM orders")
// ... unchanged ...
})
kiri.Serve(nil) // was: http.ListenAndServe(":8080", nil)
}use axum::{routing::get, Router};
fn main() -> Result<(), kiri::Error> {
let db = kiri::db(); // was: a pool opened from DATABASE_URL
let app = Router::new().route("/orders", get(move || async move {
let rows = db.query("SELECT id, total FROM orders", ()).await;
// ... unchanged ...
}));
kiri::serve(app) // was: axum::serve(listener, app).await
}import express from "express";
import * as kiri from "@kiri/sdk";
const db = kiri.db(); // was: new pg.Pool({ connectionString: process.env.DATABASE_URL })
const app = express();
app.get("/orders", async (req, res) => {
const { rows } = await db.query("SELECT id, total FROM orders");
// ... unchanged ...
});
kiri.serve(app); // was: app.listen(8080)from flask import Flask
import kiri
db = kiri.db() # was: db = sqlite3.connect("shop.db")
app = Flask(__name__)
@app.get("/orders")
def orders():
cur = db.cursor()
cur.execute("SELECT id, total FROM orders")
# ... unchanged ...
kiri.serve(app) # was: app.run(port=8080)What the database call returns is what your code already used: a *sql.DB in Go, rows shaped like the pg package’s in TypeScript, a DB-API connection in Python. So the queries and everything after them are your code as it was. The import changes too, and a driver that WebAssembly can’t run, such as a Go driver that needs cgo, comes out.
The same two lines, side by side:
| Language | Opens the database | Listens |
|---|---|---|
| Go | db := kiri.DB() |
kiri.Serve(nil) |
| Rust | let db = kiri::db(); |
kiri::serve(app) |
| TypeScript | const db = kiri.db(); |
kiri.serve(app) |
| Python | db = kiri.db() |
kiri.serve(app) |
app is what your framework already gives you: a Rust axum router, an Express app or a fetch handler, a Flask, Django or FastAPI app. The API reference has every signature.
Check, then run
Two commands do the work. kiri check reads your project and says whether each package works as WebAssembly, and what to change if it doesn’t. kiri run builds the module and starts it. There’s no Dockerfile: Kiri reads go.mod, Cargo.toml, package.json or pyproject.toml, and kiri.yaml says what the module may touch.
$ kiri check .
shop · Go 1.26 · 41 packages
✓ 41 packages work as WebAssembly · 0 to change
$ kiri run .
◆ shop building Go 1.26 → WebAssembly…
● serving on :8080 · 2.1 MB · started in 1.2 ms · needs db, port
http://shop.kiri.local
Logs show up below. Press Ctrl+C to stop.The quick start goes through it, from a plain Go program to a link you can share.
Six calls, the same names in every language
The SDK is six calls. Each one is something the host provides, so your module never needs a socket, a file or an environment variable of its own.
| Call | What it does | In kiri.yaml |
|---|---|---|
kiri.Serve |
Kiri listens on the port and your handler answers. | port |
kiri.DB |
A SQLite database kept by Kiri, or a connection to a real Postgres. | database |
kiri.HTTP |
Outbound calls, only to the sites you list. | network |
kiri.Secret |
A secret read from the system’s keychain, never from a file. | secrets |
kiri.KV |
Key-value storage that outlives the module. | kv |
kiri.Log |
Logs, shown in Kiri’s window and in your terminal. | always allowed |
The names follow each language’s style: kiri.Serve in Go, kiri::serve in Rust, kiri.serve in TypeScript and Python.
Languages
| Language | Kiri reads | Add the SDK |
|---|---|---|
| Go | go.mod |
go get runkiri.com/go/kiri |
| Rust | Cargo.toml |
cargo add kiri |
| TypeScript and JavaScript | package.json |
npm install @kiri/sdk |
| Python | pyproject.toml, or requirements.txt |
pip install kiri |
Kiri builds with the language version your project file names, in its own builder, so you don’t install a WebAssembly toolchain. Rust makes the smallest modules, then Go. A TypeScript or Python module carries its language’s engine inside it, so it’s several megabytes bigger and takes longer to start than a Go or Rust one. kiri run prints the real size and start time of yours.
Modules, containers and plugins
A module is your own workload: a web service, an API, a webhook, code you write that Kiri runs for you. It sits between two neighbours. A container runs someone else’s program. A plugin, written with the same SDK, changes Kiri itself.
Modules and containers
A module isn’t a replacement for every container. Kiri runs modules and containers in the same Linux place, so a module can use a Postgres that runs as a container, and a container can call a module at its .kiri.local name.
| Keep it a container when it… | Because |
|---|---|
is someone else’s program, such as Postgres, Redis or ffmpeg |
It’s a full Linux program, not your code. |
| needs raw sockets, its own processes or threads for heavy computing | A module has none of these. It runs on one thread and asks Kiri for the network. |
| holds WebSockets or other long-lived upgraded connections | kiri.Serve answers HTTP requests. Upgraded connections aren’t supported in 1.0. |
Heavy work stays native either way. The database is a real SQLite or Postgres, and a model can run on your computer’s GPU, as host capabilities the module calls at full speed. How modules run explains where everything runs.
Modules and plugins
The same packages write both. What differs is who the code is for.
| A module | A plugin | |
|---|---|---|
| What it is | Your workload, run beside your containers | A part of Kiri: a way to share, a place to deploy, a check, a tab |
| Its file | kiri.yaml |
kiri-plugin.toml, a list of permissions someone reads before they install it |
| How it starts | kiri run . |
kiri plugin install, then Kiri calls it when there’s a job |
| Its calls | kiri.Serve, kiri.DB and the other calls above |
plugin.check, plugin.share and the plugin API |
| Secrets | Reads the secrets it lists, with kiri.Secret |
Never reads a token you give it: Kiri adds it to requests to one site |
If you’re building something for your own app, write a module. If you want Kiri to do something new, for you or for everyone who installs it, write a plugin: see Plugins.
Open source, open standards
The SDK is open source under the Apache License 2.0, the same licence as Kiri’s engine. Modules are built on open standards: they use WASI interfaces, so the code inside isn’t tied to Kiri, and they’re stored as OCI artifacts, so any registry that holds images holds modules. A module gets the same bill of materials, scan and signature as an image, and your company’s rules apply to it. See Supply chain and policy.
© 2026 Kiri · The SDK is open source under the Apache License 2.0 · Docs · runkiri.com