Quickstart
1. Get an API Key
Sign up at swarmlord.ai and create an API key from the dashboard.
2. Install the SDK
bash
npm install swarmlordbash
pnpm add swarmlordbash
bun add swarmlord3. Send Data, Get Artifacts
Start with a CSV:
csv
month,revenue,users
Jan,42000,1200
Feb,48000,1350
Mar,51000,1580
Apr,61000,1800
May,58000,2100
Jun,72000,2450Create a file called analyze.ts:
typescript
import { createClient } from "swarmlord";
import { readFileSync, writeFileSync } from "fs";
// prepare
const client = createClient({ apiKey: process.env.SWARMLORD_API_KEY! });
const session = await client.agent("build").createSession();
const csv = readFileSync("data.csv");
// run agent
await session.send(
{
parts: [
{
type: "text",
text: "Analyze this CSV. Create a matplotlib chart saved as /workspace/chart.png and a summary report at /workspace/report.html.",
},
{
type: "file",
url: `data:text/csv;base64,${csv.toString("base64")}`,
mime: "text/csv",
filename: "data.csv",
},
],
},
{ onText: delta => process.stdout.write(delta) }
);
// download artifacts
const chart = await session.getFileBuffer("/workspace/chart.png");
writeFileSync("chart.png", new Uint8Array(chart));
const report = await session.getFile("/workspace/report.html");
writeFileSync("report.html", report);
console.log("\nDownloaded chart.png and report.html");
await session.end();4. Run It
First, set your API key in your environment (e.g. in a .env file):
bash
export SWARMLORD_API_KEY="your-key-here"Then run the script:
bash
bun analyze.tsYou'll see the agent stream its work in real-time — reading the CSV, writing Python code, generating a chart, and building an HTML report. When it's done, chart.png and report.html are on your machine.

What Just Happened?
createClientauthenticated you with the swarmlord API.client.agent("build")created a handle to an agent with all built-in tools enabled — shell, file I/O, web search, browser, and more.createSession()spun up a fresh session with its own Linux sandbox.session.send()uploaded the CSV and streamed the agent's response viaonText.getFileBuffer/getFilepulled the generated artifacts from the sandbox to your local disk.session.end()cleaned up the session and its sandbox.