@relevanceai/sdk
v3.1.0
Published
The official JavaScript/TypeScript SDK for building applications with Relevance AI agents and workforces.
Keywords
Readme
Relevance AI JavaScript SDK
The official JavaScript/TypeScript SDK for building applications with Relevance AI agents and workforces.
- Universal runtime support - Node.js, Deno, Bun, Cloudflare Workers, and browsers
- Event-driven architecture - real-time updates via the native EventTarget API
- Type-safe - full TypeScript support with comprehensive type definitions
- Zero dependencies - built entirely on web standards
Installation
npm install @relevanceai/sdk@latestFor Deno, Bun, CDN, and browser bundler setup, see the Setup guide.
Quick Start
import { Agent, createClient, REGION_US } from "@relevanceai/sdk";
createClient({
apiKey: process.env.RELEVANCE_API_KEY,
region: REGION_US,
project: process.env.PROJECT_ID,
});
const agent = await Agent.get("agent-id");
const task = await agent.sendMessage("Hello!");
task.addEventListener("message", ({ detail: { message } }) => {
if (message.isAgent()) {
console.log("Agent:", message.text);
}
});Documentation
| Guide | Description | | ----- | ----------- | | Setup | Installation and runtime configuration | | Authentication | API keys, embed keys, and regions | | Client | Client initialization and singleton pattern | | Agents | Loading agents and starting conversations | | Tasks | Task lifecycle, events, and subscriptions | | Messaging | Messages, attachments, and type guards | | Workforces | Multi-agent orchestration | | Streaming | Real-time thinking and typing tokens |
Examples
Working examples are available in internal/examples/:
- Deno (
internal/examples/deno/) - agent tasks, pagination, embed keys, image OCR, workforce tasks - Browser (
internal/examples/browser/chat/) - full chat application built with Preact
Development
The SDK is developed with Deno and published to npm and JSR.
# clone the repository
git clone https://github.com/RelevanceAI/relevance-js-sdk.git
cd relevance-js-sdk
# build the npm package
deno run -A internal/tasks/dnt.tsLicense
MIT
Security
For security vulnerabilities, please email [email protected] directly rather than using public issue trackers.
