TypeScript SDK

Install the SDK, authenticate, and make your first call. Runs on Node, Bun, Deno and edge runtimes.

Introduction

The Runware TypeScript SDK gives you one client for the whole platform: Runware's models for image, video, audio, LLMs and 3D, and your own Serverless apps, both behind the same API key. It is TypeScript-first and ships precise types for every architecture and curated model.

This page gets you to a working client: installing the package, authenticating, and the settings that shape how it behaves. What you do with that client splits by what you are calling.

PageWhat it covers
Calling modelstransports, typed parameters, schema validation, concurrency, streaming, and the utilities around them
Calling serverless appsinvoking an endpoint on your own app and reading the task back
Errorsthe single error type and the codes to branch on

Installation

The SDK runs on Node 18+, Bun, Deno, and any V8 isolate runtime (Cloudflare Workers, Vercel Edge, etc.).

npm install @runware/sdk
pnpm add @runware/sdk
bun add @runware/sdk
yarn add @runware/sdk

Quick start

The fastest path is REST with sync delivery. The server holds the connection open until the task completes and returns the result in the same response:

import { createClient } from '@runware/sdk'

const client = await createClient({
  apiKey: process.env.RUNWARE_API_KEY,
  transport: 'rest',
})

const images = await client.run({
  taskType: 'imageInference',
  model: 'runware:101@1',
  positivePrompt: 'A serene mountain landscape at sunset',
  width: 1024,
  height: 1024,
  deliveryMethod: 'sync',
})

console.log(images[0].imageURL)

There is no connect() step for REST. The first request opens a connection if needed, the SDK reuses it for follow-ups, and Node's keep-alive handles the underlying socket pool.

Set RUNWARE_API_KEY in your environment and pass it to createClient. The SDK doesn't read from process.env automatically because edge runtimes don't always expose it.

Configuration

Most apps only need apiKey. The full createClient config accepts:

const client = await createClient({
  apiKey: process.env.RUNWARE_API_KEY,
  transport: 'websocket',
  // Timeouts (ms)
  timeout: 120_000,           // Per-request cap
  pollTimeout: 600_000,       // Async-delivery polling cap
  // Validation behavior
  validate: true,             // Toggle JSON-Schema validation (off by default)
  // Logging
  debug: true,                // Console logs; pass logSink for custom routing
})

Per-call overrides accept the same keys plus an AbortSignal for cancellation:

const controller = new AbortController()

const result = await client.run(payload, {
  timeout: 30_000,
  signal: controller.signal,
  validate: false,
})

Edge runtimes

The SDK runs unmodified on Cloudflare Workers, Vercel Edge, and Deno Deploy. REST is the right transport here. WebSocket is supported, but the per-request lifetime of edge invocations means you usually don't get the WS performance benefit.

// Cloudflare Worker
export default {
  async fetch(request: Request, env: Env): Promise<Response> {
    const client = await createClient({
      apiKey: env.RUNWARE_API_KEY,
      transport: 'rest',
    })

    const images = await client.run({
      taskType: 'imageInference',
      model: 'runware:101@1',
      positivePrompt: 'A coastal town at dusk',
      width: 1024,
      height: 1024,
      deliveryMethod: 'sync',
    })

    return Response.json({ url: images[0].imageURL })
  },
}

Source

The SDK is open source. Issues and pull requests are welcome.

Repository: github.com/runware/runware-typescript