Getting Started

SDK Reference

Reduck provides an official TypeScript SDK. Create a client, start a run, iterate over events.

Installation

npm install @reduck-ai/sdk

ReduckClient

import { ReduckClient } from "@reduck-ai/sdk"

Constructor

// API key (recommended for server-side)
const client = new ReduckClient({ apiKey: "rk_..." })

// OAuth token (for user-facing apps)
const client = new ReduckClient({ oauthToken: "..." })

One of apiKey or oauthToken is required.

client.listDevices()

Returns Promise<Device[]> — all devices for the authenticated user.

interface Device {
  id: string
  name: string | null
  browser: string | null
  os: string | null
  reachable: boolean
  created_at: string
}

client.run()

Starts an automation and returns a Run — an AsyncIterable<RunEvent> that streams events in real-time via WebSocket.

const run = client.run(prompt: string, options: { deviceId: string, mount?: string[] })
OptionTypeDescription
deviceIdstringTarget device ID (required)
mountstring[]Local file paths to upload and make available

run.id

Promise<string> — resolves to the run ID once the server accepts it.

run.cancel()

Cancels the running automation.

client.listRuns()

Returns Promise<RunsPage> — a paginated list of runs for the authenticated user.

interface RunsPage {
  data: RunRecord[]
  hasNextPage: boolean
}
OptionTypeDefaultDescription
pagenumber0Zero-based page index

client.getRun()

Returns Promise<RunRecord> — a single run by ID.

interface RunRecord {
  id: string
  started_at: string
  finished_at: string | null
  result: {
    success?: boolean
    cancelled?: boolean
    reason?: string
    output?: string
  } | null
  resolved: {
    url?: string
    prompt?: string
  } | null
}

client.interrupt()

Cancels a run by ID (useful if you only have the ID, not the Run object):

await client.interrupt(runId: string)

Events

The run async iterable yields these events:

TypeFieldsTerminal?Description
run_startedtimestampNoAutomation has started
progresstext, timestampNoStep-by-step progress update
assistanttext, timestampNoAssistant message
turn_completedtimestampNoAgent turn completed
run_completedtimestampNoAutomation finished executing
donesuccess, output?YesFinal result
failureerrorYesAutomation failed
cancelYesAutomation was cancelled

Full example

import { ReduckClient } from "@reduck-ai/sdk"

const client = new ReduckClient({ apiKey: process.env.REDUCK_API_KEY! })

const devices = await client.listDevices()

const run = client.run("Find the cheapest flight to Tokyo next week", {
  deviceId: devices[0].id,
})

const runId = await run.id
console.log(`Started run: ${runId}`)

for await (const event of run) {
  if (event.type === "progress") console.log("→", event.text)
  if (event.type === "done") console.log(event.success ? "✓ Done" : "✗ Failed")
  if (event.type === "failure") console.error("✗", event.error)
}