TypeScript@aui.io/aui-clientv3
The official TypeScript/JavaScript SDK wraps the Apollo API
with full type definitions, automatic authentication, retries, and built-in
WebSocket handling. It exposes two clients, one per credential — import the
one that matches where your code runs:
Installation
Quick start — messaging
The messaging client authenticates with your publishable key. It exchanges the key for a short-lived access token and refreshes it as needed — you never handle tokens directly, and the agent is derived from the key rather than passed in request bodies.Quick start — management
The management client authenticates with your organization API key, sent as thex-organization-api-key header on every request. It’s meant for backend
services and CI — never expose the key in the browser.
Agent runtimes: v1 and v2
Every agent runs on one of two runtime generations — v1 (the classic runtime) or v2 (the current, streaming-first generation). You never pick one when sending:sendMessage, streamMessage, rerun, and the channel
openers route automatically based on the agent behind your key. The differences
surface in a few places only:
The rule to remember: a thread lives on the runtime that created it — reading
a v2 thread without
runtime_version asks the wrong runtime and returns 404.
Pass the runtime version your agent runs on (e.g. '0.8.0'); any value outside
the 1.x family selects v2, and it doesn’t have to match the thread’s exact
build. Not sure which kind of agent you have? Check a thread id it produces:
UUIDs mean v2.
Why use the SDK?
Auth handled for you
Token exchange, refresh, and header injection are automatic — construct the
client with a key and start calling.
Type safety
Full TypeScript definitions with IntelliSense across every method and
payload, exported under the
Apollo namespace.WebSocket management
connect() returns a reconnecting socket with typed envelopes and resume
support.Typed errors
ApolloError, ApolloTimeoutError, and per-status classes like
Apollo.NotFoundError for clean handling.Automatic retries
Transient failures retry automatically (2 attempts by default, tunable per
call).
Always in sync
Generated from the live API specification, so the client tracks the API as
it evolves.
Environment
Both clients default to production — no configuration needed:baseUrl:
Resolved key context
After the first request (or an explicitgetContext() call), the messaging
client exposes the scope resolved from your publishable key:
Explore the SDK
Messaging client
Send and stream messages, read conversations, and reach users on
WhatsApp/SMS.
Management client
Operate projects, agents, versions, threads, and usage from your backend.
WebSocket
Real-time sessions with typed envelopes, reconnection, and resume.
Best practices
Error handling, timeouts, retries, and key hygiene.
API
The underlying REST + WebSocket API the SDK wraps.