Client
createClient(opts)
Creates the root client. All SDK operations start here.
typescript
import { createClient } from "swarmlord";
const client = createClient({
apiKey: process.env.SWARMLORD_API_KEY!,
});Parameters
apiKeystringoptional — Your swarmlord API key. Get one at swarmlord.ai. If omitted, it will readprocess.env.SWARMLORD_API_KEY.baseUrlstringoptional — API base URL. Override for self-hosted or development. Defaults toprocess.env.SWARMLORD_URLor"https://api.swarmlord.ai".
Methods
client.agent(nameOrConfig)
Create an agent handle. Everything flows from agents — sessions, tasks, and schedules.
typescript
// Built-in agent with all tools enabled
const build = client.agent("build");
// Custom configuration with specific tools
const reviewer = client.agent({
model: "anthropic/claude-sonnet-4-20250514",
instructions: ["Focus on security and correctness"],
tools: {
bash: true,
read: true,
grep: true,
glob: true,
edit: false,
write: false,
},
});nameOrConfigstring | AgentConfigrequired — Agent name ("build","plan","explore","general") or a full configuration object.
AgentConfig
namestring— Base agent type. Defaults to"build".modelstring— Model ID inprovider/modelformat (e.g.anthropic/claude-sonnet-4-20250514).instructionsstring[]— Additional instructions appended to the agent's system prompt.temperaturenumber— Sampling temperature.toolsRecord<string, boolean>— Enable or disable specific tools. Keys are tool names, values aretrue(enabled) orfalse(disabled). Unmentioned tools keep their default state.permissionPermissionConfig— Low-level permission rules. Prefertoolsfor tool-level control.configConfig— Advanced configuration including compaction settings and command templates.
Returns: AgentHandle
client.session(id)
Resume an existing session by ID. Use this when you saved a session ID and want to continue the conversation from another process.
typescript
const session = client.session("session-id");
await session.send("Pick up where we left off");idstringrequired — Session ID to resume.
Returns: SessionHandle
client.task(sessionId)
Resume a task handle by its session ID. Use this to check on a task from another process.
typescript
const task = client.task("task-session-id");
const result = await task.result();sessionIdstringrequired — The session ID of the task.
Returns: TaskHandle
client.schedule(id)
Resume a schedule handle by ID.
typescript
const schedule = client.schedule("schedule-id");
await schedule.pause();idstringrequired — Schedule ID.
Returns: ScheduleHandle
client.listSessions(opts?)
List all sessions for the authenticated user.
typescript
const sessions = await client.listSessions({ limit: 20, archived: false });limitnumber— Maximum number of sessions to return.archivedboolean— Whether to include archived sessions.
Returns: Promise<SessionInfo[]>
client.listSchedules()
List all schedules for the authenticated user.
typescript
const schedules = await client.listSchedules();Returns: Promise<ScheduleInfo[]>
client.getConfig()
Get the user-level configuration.
typescript
const config = await client.getConfig();Returns: Promise<Config>
client.updateConfig(config)
Merge-update the user-level configuration.
typescript
await client.updateConfig({
model: "anthropic/claude-sonnet-4-20250514",
instructions: ["Always write tests"],
});configPartial<Config>required — Configuration fields to merge.
Returns: Promise<void>
client.listModels()
List available models (proxied from the provider).
typescript
const { data: models } = await client.listModels();
for (const m of models) {
console.log(`${m.id} — ${m.name}`);
}Returns: Promise<{ data: ProviderModel[] }>