Skip to main content

Setup

Installation

Install @relevanceai/sdk in Node.js, Deno, Bun, Cloudflare Workers, or the browser.

The SDK ships to both npm and JSR, and works in every major JavaScript runtime with no extra configuration.

Prerequisites

Before installing, make sure you have:

  • A Relevance AI account with access to the project dashboard
  • An API key or embed key — see Authentication
  • One of the supported runtimes below

Node.js, Bun, and Cloudflare Workers

Install from npm with any package manager.

npm install @relevanceai/sdk@latest

Then import the named exports you need:

import { createClient, Agent } from "@relevanceai/sdk";

Deno

Add the package from JSR:

deno add jsr:@relevanceai/sdk

Or import directly without a local install:

import { createClient } from "jsr:@relevanceai/sdk";

Browser via CDN

For browser apps that don’t use a bundler, load the SDK through an import map:

<script type="importmap">
  {
    "imports": {
      "@relevanceai/sdk": "https://esm.run/@relevanceai/sdk"
    }
  }
</script>
<script type="module">
  import { createClient } from "@relevanceai/sdk";
</script>

Browser bundler configuration

When bundling for the browser with Vite, Webpack, or Rollup, you may see a warning about node:crypto. The SDK uses this module for UUID generation and falls back to the native browser equivalent. To silence the warning, add a shim and point the bundler at it.

Create the shim

Save this as src/shims/crypto.ts:

export default globalThis.crypto;

Configure the bundler

Vite

In vite.config.ts, add a resolve alias:

import { defineConfig } from "vite";
import path from "node:path";

export default defineConfig({
  resolve: {
    alias: {
      "node:crypto": path.resolve(
        __dirname,
        "src/shims/crypto.ts"
      ),
    },
  },
});
Webpack

In webpack.config.js, add a resolve alias:

module.exports = {
  resolve: {
    alias: {
      "node:crypto": path.resolve(
        __dirname,
        "src/shims/crypto.js"
      ),
    },
  },
};
Rollup

Use the @rollup/plugin-alias plugin:

import alias from "@rollup/plugin-alias";
import path from "node:path";

export default {
  plugins: [
    alias({
      entries: [
        {
          find: "node:crypto",
          replacement: path.resolve(
            __dirname,
            "src/shims/crypto.js"
          ),
        },
      ],
    }),
  ],
};

Verify the installation

Run a minimal script to confirm everything is wired up. Replace the placeholder values with real credentials from the dashboard.

import { createClient, Agent, REGION_US } from "@relevanceai/sdk";

createClient({
  apiKey: "<api-key>",
  region: REGION_US,
  project: "<project-id>",
});

const agent = await Agent.get("<agent-id>");
console.log("Connected:", agent.name);

If the agent’s name prints to the console, the SDK is installed and authenticated correctly.