A Node.js client for the OpenClaw Gateway WebSocket protocol, enabling communication with AI agents. Version 0.12.1 is the latest stable release, with frequent updates as the project is actively developed. Differentiators include streaming and sync chat APIs, built-in auto-reconnect, and first-class TypeScript support. Requires Node.js 20+ (22+ for built-in WebSocket) and a running OpenClaw Gateway server. The library handles WebSocket handshake, authentication, and keepalive automatically. Compared to alternatives like LangChain or Vercel AI SDK, OpenClaw focuses on persistent agents with tools and memory, running locally via a gateway.
npm install openclaw-nodeNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates connecting to the gateway, sending a streaming chat request, iterating over chunks, using sync chat, and disconnecting.
For Node 20-21, install 'ws' alongside openclaw-node: npm install openclaw-node ws. For Node 22+, no extra step needed.
Wrap client.connect() in try/catch to handle connection or authentication failures.
Always use for await...of on the stream, or consume it via a try/catch block to catch errors from the WebSocket.
Use 'autoReconnect: true' instead of 'reconnect: true'.
Update your switch/case to handle 'tool_use' instead of 'tool_call'.
Ensure the URL ends with '/ws' or is a valid WebSocket endpoint. Example: 'ws://localhost:18789'.
Start the gateway: npx openclaw gateway start (or openclaw gateway start if installed globally).
Set the same token on both sides: gateway environment variable and client constructor option.
Use: import { OpenClawClient } from 'openclaw-node'.No dependency data recorded yet.