Docs
SDKs

TypeScript SDK

Install @silos/sdk and connect with an API key to manage databases, branches, and run SQL from TypeScript.

The TypeScript SDK (@silos/sdk) is the primary client for Silos. It wraps the management API and gives you typed helpers for databases, branches, API keys, and SQL. Two companion packages extend it: @silos/schema for schema-related helpers and @silos/agent for agent-style workflows that provision and tear down databases on demand.

These packages are available and evolving. The snippets below show the minimal install-and-connect path. For the authoritative request/response shapes, see the API reference.

Install

Terminal
npm install @silos/sdk
Terminal
pnpm add @silos/sdk
Terminal
bun add @silos/sdk

Optional companions:

Terminal
npm install @silos/schema @silos/agent

Initialize the client

Create a client with your API key. Load it from the environment — never hard-code it.

silos.ts
import { Silos } from "@silos/sdk";

const silos = new Silos({
  apiKey: process.env.SILOS_API_KEY!,
});

Manage databases and branches

Use the client to provision and list databases, then branch them with copy-on-write forks.

provision.ts
// Create a database
const db = await silos.databases.create({ name: "my-app" });

// Branch it for a preview or test environment
const branch = await silos.branches.create({
  database: db.name,
  name: "preview",
});

// Tear it down when you're done — ideal for ephemeral workloads
await silos.branches.delete({ database: db.name, name: "preview" });

Method names and option shapes track the management API and may change as the SDK matures. The API reference is canonical for the exact surface.

Run SQL

For application data access you can use the SDK's query helper, or connect with a standard Postgres driver using the database's connection string.

query.ts
const result = await silos.sql`SELECT id, email FROM users LIMIT 10`;
console.log(result.rows);

Prefer a driver? Any node-postgres-compatible client works against the wire protocol:

driver.ts
import { Client } from "pg";

const client = new Client({
  connectionString: process.env.SILOS_DATABASE_URL,
});
await client.connect();
const { rows } = await client.query("SELECT now()");
await client.end();

See Connecting → Drivers for ORM guidance (Prisma, Drizzle, Kysely) — these connect to Silos the same way they connect to any Postgres.

Next steps

On this page